diff options
author | Kristóf Marussy <kristof@marussy.com> | 2023-09-13 01:34:08 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2023-09-13 01:34:08 +0200 |
commit | 45832ce1b8ad6c2d118a290b0e25825e45e6891a (patch) | |
tree | 56b786f4c6acc4cfb106ac285c135edc97397ca9 | |
parent | refactor(frontend): generation appearance fixes (diff) | |
download | refinery-45832ce1b8ad6c2d118a290b0e25825e45e6891a.tar.gz refinery-45832ce1b8ad6c2d118a290b0e25825e45e6891a.tar.zst refinery-45832ce1b8ad6c2d118a290b0e25825e45e6891a.zip |
build: fix Dockerfile
* Automatically invoke the distTar Gradle task before building the container.
* Avoid cache mounts for package managers, because they don't support ARG
interpolation and may lead to locking conflicts when a cache is accidentally
shared between containers.
-rw-r--r-- | docker/Dockerfile | 15 | ||||
-rwxr-xr-x | docker/build.sh | 2 |
2 files changed, 9 insertions, 8 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile index a94e3fe8..79a5eacf 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile | |||
@@ -19,16 +19,16 @@ FROM --platform=$BUILDPLATFORM jlink-base AS jlink-arm64-on-amd64 | |||
19 | # When cross-building the Docker image, we have the wrong toolchain for the | 19 | # When cross-building the Docker image, we have the wrong toolchain for the |
20 | # target architecture. We forcibly override the target for the objcopy tool. | 20 | # target architecture. We forcibly override the target for the objcopy tool. |
21 | # The cross toolchain is not available in Amazon Linux 2023. | 21 | # The cross toolchain is not available in Amazon Linux 2023. |
22 | RUN --mount=type=cache,target=/var/cache/apt \ | 22 | RUN apt-get update && \ |
23 | apt-get update && \ | ||
24 | apt-get install binutils-aarch64-linux-gnu && \ | 23 | apt-get install binutils-aarch64-linux-gnu && \ |
25 | ln -sf /usr/bin/aarch64-linux-gnu-objcopy /usr/bin/objcopy | 24 | ln -sf /usr/bin/aarch64-linux-gnu-objcopy /usr/bin/objcopy && \ |
25 | rm -rf /var/lib/apt/lists/* | ||
26 | 26 | ||
27 | FROM --platform=$BUILDPLATFORM jlink-base AS jlink-amd64-on-arm64 | 27 | FROM --platform=$BUILDPLATFORM jlink-base AS jlink-amd64-on-arm64 |
28 | RUN --mount=type=cache,target=/var/cache/apt \ | 28 | RUN apt-get update && \ |
29 | apt-get update && \ | ||
30 | apt-get install binutils-x86-64-linux-gnu && \ | 29 | apt-get install binutils-x86-64-linux-gnu && \ |
31 | ln -sf /usr/bin/x86_64-linux-gnu-objcopy /usr/bin/objcopy | 30 | ln -sf /usr/bin/x86_64-linux-gnu-objcopy /usr/bin/objcopy && \ |
31 | rm -rf /var/lib/apt/lists/* | ||
32 | 32 | ||
33 | FROM --platform=$BUILDPLATFORM jlink-$TARGETARCH-on-$BUILDARCH as jlink | 33 | FROM --platform=$BUILDPLATFORM jlink-$TARGETARCH-on-$BUILDARCH as jlink |
34 | RUN jlink --no-header-files --no-man-pages --compress=2 \ | 34 | RUN jlink --no-header-files --no-man-pages --compress=2 \ |
@@ -38,8 +38,7 @@ RUN jlink --no-header-files --no-man-pages --compress=2 \ | |||
38 | 38 | ||
39 | FROM public.ecr.aws/amazonlinux/amazonlinux:2023-minimal AS base | 39 | FROM public.ecr.aws/amazonlinux/amazonlinux:2023-minimal AS base |
40 | # The launcher script generated by Gradle uses xargs to parse the argument list. | 40 | # The launcher script generated by Gradle uses xargs to parse the argument list. |
41 | RUN --mount=type=cache,id=yum-$TARGETARCH,target=/var/cache/apt \ | 41 | RUN dnf install -y findutils && \ |
42 | dnf install -y findutils && \ | ||
43 | dnf clean all | 42 | dnf clean all |
44 | # The first layer contains the slimmed down JRE. | 43 | # The first layer contains the slimmed down JRE. |
45 | COPY --link --from=jlink /jlink /usr/lib/java | 44 | COPY --link --from=jlink /jlink /usr/lib/java |
diff --git a/docker/build.sh b/docker/build.sh index 5c25bb5f..5e0c2425 100755 --- a/docker/build.sh +++ b/docker/build.sh | |||
@@ -6,6 +6,8 @@ | |||
6 | 6 | ||
7 | set -euo pipefail | 7 | set -euo pipefail |
8 | 8 | ||
9 | (cd .. && ./gradlew :refinery-language-web:distTar) | ||
10 | |||
9 | refinery_version="$(grep '^version=' ../gradle.properties | cut -d'=' -f2)" | 11 | refinery_version="$(grep '^version=' ../gradle.properties | cut -d'=' -f2)" |
10 | distribution_name="refinery-language-web-${refinery_version}" | 12 | distribution_name="refinery-language-web-${refinery_version}" |
11 | rm -rf "${distribution_name}" dist app_lib app_{amd64,arm64}_bin lib lib_{amd64,arm64} | 13 | rm -rf "${distribution_name}" dist app_lib app_{amd64,arm64}_bin lib lib_{amd64,arm64} |