build: Switch to build args in Dockerfile
`--env` is a podman-specific feature. While it is clear that podman is a requirement here, switching these to build arguments better expresses intent. These values are meant to be configurable at build time, which is exactly what build arguments are for, while environment variables are meant to persist in the image built. Signed-off-by: Yorgos Saslis <yorgos.work@proton.me>
This commit is contained in:
parent
ce99f7e7e4
commit
6966c97194
|
|
@ -4,6 +4,11 @@ LABEL maintainer="Radicle Team <team@radicle.xyz>"
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
ARG TZ
|
||||||
|
ARG LC_ALL
|
||||||
|
ARG SOURCE_DATE_EPOCH
|
||||||
|
ARG RADICLE_VERSION
|
||||||
|
|
||||||
# Copy cargo configuration we're going to use to specify compiler options.
|
# Copy cargo configuration we're going to use to specify compiler options.
|
||||||
RUN mkdir -p .cargo && cp build/config.toml .cargo/config.toml
|
RUN mkdir -p .cargo && cp build/config.toml .cargo/config.toml
|
||||||
# Install dependencies.
|
# Install dependencies.
|
||||||
|
|
@ -51,6 +56,10 @@ RUN cargo zigbuild --locked --release \
|
||||||
# Now copy the files to a new image without all the intermediary artifacts to
|
# Now copy the files to a new image without all the intermediary artifacts to
|
||||||
# save some space.
|
# save some space.
|
||||||
FROM alpine:3.19 as packager
|
FROM alpine:3.19 as packager
|
||||||
|
|
||||||
|
ARG RADICLE_VERSION
|
||||||
|
ARG SOURCE_DATE_EPOCH
|
||||||
|
|
||||||
COPY --from=builder \
|
COPY --from=builder \
|
||||||
/src/target/x86_64-unknown-linux-musl/release/rad \
|
/src/target/x86_64-unknown-linux-musl/release/rad \
|
||||||
/src/target/x86_64-unknown-linux-musl/release/git-remote-rad \
|
/src/target/x86_64-unknown-linux-musl/release/git-remote-rad \
|
||||||
|
|
@ -84,7 +93,7 @@ RUN find * -maxdepth 0 -type d -exec mv '{}' "radicle-$RADICLE_VERSION-{}" \; &&
|
||||||
find * -maxdepth 0 -type d -exec tar \
|
find * -maxdepth 0 -type d -exec tar \
|
||||||
--sort=name \
|
--sort=name \
|
||||||
--verbose \
|
--verbose \
|
||||||
--mtime="@$GIT_COMMIT_TIME" \
|
--mtime="@$SOURCE_DATE_EPOCH" \
|
||||||
--owner=0 \
|
--owner=0 \
|
||||||
--group=0 \
|
--group=0 \
|
||||||
--numeric-owner \
|
--numeric-owner \
|
||||||
|
|
|
||||||
10
build/build
10
build/build
|
|
@ -40,12 +40,10 @@ main() {
|
||||||
|
|
||||||
echo "Building image ($image).."
|
echo "Building image ($image).."
|
||||||
podman --cgroup-manager=cgroupfs build \
|
podman --cgroup-manager=cgroupfs build \
|
||||||
--env SOURCE_DATE_EPOCH \
|
--build-arg SOURCE_DATE_EPOCH \
|
||||||
--env TZ \
|
--build-arg TZ \
|
||||||
--env LC_ALL \
|
--build-arg LC_ALL \
|
||||||
--env GIT_COMMIT_TIME=$SOURCE_DATE_EPOCH \
|
--build-arg RADICLE_VERSION=$version \
|
||||||
--env GIT_HEAD=$rev \
|
|
||||||
--env RADICLE_VERSION=$version \
|
|
||||||
--arch amd64 --tag $image -f ./build/Dockerfile - < $gitarchive
|
--arch amd64 --tag $image -f ./build/Dockerfile - < $gitarchive
|
||||||
|
|
||||||
echo "Creating container (radicle-build-container).."
|
echo "Creating container (radicle-build-container).."
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue