Skip to content

Commit

Permalink
Optimize Release Script for Docker Builds in BookKeeper (#4428)
Browse files Browse the repository at this point in the history
### Changes

- Replaced `docker build` with `docker buildx build` to enhance cross-platform compatibility.
- Modified Dockerfile commands to conditionally create user and group only if they do not already exist, preventing errors during the build process.

(cherry picked from commit 88bcdc9)
  • Loading branch information
ZhangJian He authored and lhotari committed Jun 13, 2024
1 parent 4c1919a commit e69dc98
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions dev/release/000-run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export IMAGE_NAME="bookkeeper-release-build"

pushd ${SCRIPT_DIR}

docker build --rm=true -t ${IMAGE_NAME} .
docker build --platform linux/amd64 --rm=true -t ${IMAGE_NAME} .

popd

Expand All @@ -47,10 +47,10 @@ else # boot2docker uid and gid
GROUP_ID=50
fi

docker build -t "${IMAGE_NAME}-${USER_NAME}" - <<UserSpecificDocker
FROM --platform=linux/amd64 ${IMAGE_NAME}
RUN groupadd --non-unique -g ${GROUP_ID} ${USER_NAME} && \
useradd -l -g ${GROUP_ID} -u ${USER_ID} -k /root -m ${USER_NAME} && \
docker buildx build --platform linux/amd64 -t "${IMAGE_NAME}-${USER_NAME}" - <<UserSpecificDocker
FROM ${IMAGE_NAME}
RUN if ! getent group ${GROUP_ID} > /dev/null; then groupadd --non-unique -g ${GROUP_ID} ${USER_NAME}; fi && \
if ! getent passwd ${USER_NAME} > /dev/null; then useradd -l -g ${GROUP_ID} -u ${GROUP_ID} -k /root -m ${USER_NAME}; fi && \
([ "$(dirname "$HOME")" = "/home" ] || ln -s /home $(dirname "$HOME")) && \
mkdir -p /gpg && chown ${USER_ID}:${GROUP_ID} /gpg && chmod 700 /gpg
ENV HOME /home/${USER_NAME}
Expand Down

0 comments on commit e69dc98

Please sign in to comment.