From e69dc98fb221af530c053615ff87e12e87342ecf Mon Sep 17 00:00:00 2001 From: ZhangJian He Date: Wed, 12 Jun 2024 23:08:31 +0800 Subject: [PATCH] Optimize Release Script for Docker Builds in BookKeeper (#4428) ### 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 88bcdc981f8daf42a1a011f0e2db72a134b86218) --- dev/release/000-run-docker.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dev/release/000-run-docker.sh b/dev/release/000-run-docker.sh index 495227a7e9c..845b17ec7e1 100755 --- a/dev/release/000-run-docker.sh +++ b/dev/release/000-run-docker.sh @@ -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 @@ -47,10 +47,10 @@ else # boot2docker uid and gid GROUP_ID=50 fi -docker build -t "${IMAGE_NAME}-${USER_NAME}" - < /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}