Fix building Docker image for arm and i386

This commit is contained in:
Lan Tian 2021-01-15 01:00:54 +08:00
parent 8d0618fed9
commit 8d5eb56199
No known key found for this signature in database
GPG Key ID: 3D2E9DC81E5791C7

View File

@ -46,6 +46,7 @@ jobs:
environment:
IMAGE_ARCH: << parameters.image_arch >>
PROGRAM: << parameters.program >>
BUILD_ID: << pipeline.number >>
command: |
if [ "$PROGRAM" = "frontend" ]; then
export IMAGE_NAME="bird-lg-go"
@ -53,8 +54,13 @@ jobs:
export IMAGE_NAME="bird-lgproxy-go"
fi
export IMAGE_ARCH_GO=$IMAGE_ARCH
if [ "$IMAGE_ARCH" = "i386" ]; then export IMAGE_ARCH_GO="386" ; fi
if [ "$IMAGE_ARCH" = "arm32v7" ]; then export IMAGE_ARCH_GO="arm" ; fi
if [ "$IMAGE_ARCH" = "arm64v8" ]; then export IMAGE_ARCH_GO="arm64"; fi
docker build \
--build-arg IMAGE_ARCH=$IMAGE_ARCH \
--build-arg IMAGE_ARCH=$IMAGE_ARCH_GO \
-t $DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_ARCH \
-f $PROGRAM/Dockerfile \
$PROGRAM
@ -63,12 +69,12 @@ jobs:
# Tag image :{arch} and :{arch}-build{build number}
docker push $DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_ARCH
docker tag $DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_ARCH $DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_ARCH-build$CIRCLE_BUILD_NUM
docker push $DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_ARCH-build$CIRCLE_BUILD_NUM
docker tag $DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_ARCH $DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_ARCH-circleci-build$BUILD_ID
docker push $DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_ARCH-circleci-build$BUILD_ID
if [ "$IMAGE_ARCH" = "amd64" ]; then
# Tag as latest for amd64 images
docker tag $DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_ARCH $DOCKER_USERNAME/$IMAGE_NAME:latest
docker push $DOCKER_USERNAME/$IMAGE_NAME:latest
docker tag $DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_ARCH $DOCKER_USERNAME/$IMAGE_NAME:build$CIRCLE_BUILD_NUM
docker tag $DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_ARCH $DOCKER_USERNAME/$IMAGE_NAME:circleci-build$BUILD_ID
docker push $DOCKER_USERNAME/$IMAGE_NAME:latest
fi