Skip to content

Commit

Permalink
build: switch to build args over env vars in dockerfile
Browse files Browse the repository at this point in the history
`--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.

Additionally, this removes a couple of unused env vars.

Signed-off-by: Yorgos Saslis <[email protected]>
  • Loading branch information
gsaslis committed Jun 7, 2024
1 parent e03277e commit e549b52
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
7 changes: 7 additions & 0 deletions http-server/build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ LABEL maintainer="Radicle Team <[email protected]>"
WORKDIR /src
COPY . .

ARG TZ
ARG LC_ALL
ENV TZ=$TZ
ENV LC_ALL=$LC_ALL

# Copy cargo configuration we're going to use to specify compiler options.
RUN mkdir -p .cargo && cp build/config.toml .cargo/config.toml
# Install dependencies.
Expand Down Expand Up @@ -50,6 +55,8 @@ RUN cargo zigbuild --locked --release \
# Now copy the files to a new image without all the intermediary artifacts to
# save some space.
FROM alpine:3.19 as packager
ARG RADICLE_VERSION
ARG GIT_COMMIT_TIME
COPY --from=builder \
/src/target/x86_64-unknown-linux-musl/release/rad \
/src/target/x86_64-unknown-linux-musl/release/radicle-httpd \
Expand Down
24 changes: 10 additions & 14 deletions http-server/build/build
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,19 @@ main() {
case "$OS" in
Darwin)
podman build \
--env SOURCE_DATE_EPOCH \
--env TZ \
--env LC_ALL \
--env GIT_COMMIT_TIME=$SOURCE_DATE_EPOCH \
--env GIT_HEAD=$rev \
--env RADICLE_VERSION=$version \
--build-arg TZ=$TZ \
--build-arg LC_ALL=$LC_ALL \
--build-arg GIT_COMMIT_TIME=$SOURCE_DATE_EPOCH \
--build-arg RADICLE_VERSION=$version \
--arch aarch64 --tag $image -f ./build/Dockerfile - <$gitarchive
;;
*)
podman --cgroup-manager=cgroupfs build \
--env SOURCE_DATE_EPOCH \
--env TZ \
--env LC_ALL \
--env GIT_COMMIT_TIME=$SOURCE_DATE_EPOCH \
--env GIT_HEAD=$rev \
--env RADICLE_VERSION=$version \
--arch amd64 --tag $image -f ./build/Dockerfile - <$gitarchive
podman --cgroup-manager=cgroupfs build \
--build-arg TZ=$TZ \
--build-arg LC_ALL=$LC_ALL \
--build-arg GIT_COMMIT_TIME=$SOURCE_DATE_EPOCH \
--build-arg RADICLE_VERSION=$version \
--arch amd64 --tag $image -f ./build/Dockerfile - < $gitarchive
;;
esac

Expand Down

0 comments on commit e549b52

Please sign in to comment.