general: fix incorrect name for pushed docker images

This commit is contained in:
Lan Tian
2021-03-06 21:41:44 +08:00
parent 4413f1032f
commit 28a7d2a53f
2 changed files with 40 additions and 26 deletions

View File

@@ -12,7 +12,8 @@ workflows:
matrix:
parameters:
program: [frontend, proxy]
image_arch: [i386, amd64, arm32v7, arm64v8, ppc64le, s390x]
# latest is amd64 arch + push to default latest tag
image_arch: [latest, i386, arm32v7, arm64v8, ppc64le, s390x]
filters:
branches:
only: master

View File

@@ -1,6 +1,6 @@
# Basic definitions
DOCKER_USERNAME := xddxdd
ARCHITECTURES := amd64 i386 arm32v7 arm64v8 ppc64le s390x riscv64 x32
ARCHITECTURES := amd64 i386 arm32v7 arm64v8 ppc64le s390x
IMAGES := frontend proxy
# General Purpose Preprocessor config
@@ -12,17 +12,30 @@ GPP_FLAGS := -I ${GPP_INCLUDE_DIR} --nostdinc -U ${GPP_FLAGS_U} -M ${GPP_FLAGS_M
BUILD_ID ?= $(shell date +%Y%m%d%H%M)
# Function to create targets for image/architecture combos
define create-image-arch-target
$1/Dockerfile.$2: $1/template.Dockerfile
@gpp ${GPP_FLAGS} -D ARCH_$(shell echo $2 | tr a-z A-Z) -o $1/Dockerfile.$2 $1/template.Dockerfile || rm -rf $1/Dockerfile.$2
frontend/Dockerfile.$1: frontend/template.Dockerfile
@gpp ${GPP_FLAGS} -D ARCH_$(shell echo $1 | tr a-z A-Z) -o frontend/Dockerfile.$1 frontend/template.Dockerfile || rm -rf frontend/Dockerfile.$1
$1/$2: $1/Dockerfile.$2
@if [ -f $1/Dockerfile.$2 ]; then \
docker build --pull --no-cache -t ${DOCKER_USERNAME}/$1:$2-${BUILD_ID} -f $1/Dockerfile.$2 $1 || exit 1; \
docker push ${DOCKER_USERNAME}/$1:$2-${BUILD_ID} || exit 1; \
docker tag ${DOCKER_USERNAME}/$1:$2-${BUILD_ID} ${DOCKER_USERNAME}/$1:$2 || exit 1; \
docker push ${DOCKER_USERNAME}/$1:$2 || exit 1; \
frontend/$1: frontend/Dockerfile.$1
@if [ -f frontend/Dockerfile.$1 ]; then \
docker build --pull --no-cache -t ${DOCKER_USERNAME}/bird-lg-go:$1-${BUILD_ID} -f frontend/Dockerfile.$1 frontend || exit 1; \
docker push ${DOCKER_USERNAME}/bird-lg-go:$1-${BUILD_ID} || exit 1; \
docker tag ${DOCKER_USERNAME}/bird-lg-go:$1-${BUILD_ID} ${DOCKER_USERNAME}/bird-lg-go:$1 || exit 1; \
docker push ${DOCKER_USERNAME}/bird-lg-go:$1 || exit 1; \
else \
echo "Dockerfile generation failed, see error above"; \
exit 1; \
fi
proxy/Dockerfile.$1: proxy/template.Dockerfile
@gpp ${GPP_FLAGS} -D ARCH_$(shell echo $1 | tr a-z A-Z) -o proxy/Dockerfile.$1 proxy/template.Dockerfile || rm -rf proxy/Dockerfile.$1
proxy/$1: proxy/Dockerfile.$1
@if [ -f proxy/Dockerfile.$1 ]; then \
docker build --pull --no-cache -t ${DOCKER_USERNAME}/bird-lgproxy-go:$1-${BUILD_ID} -f proxy/Dockerfile.$1 proxy || exit 1; \
docker push ${DOCKER_USERNAME}/bird-lgproxy-go:$1-${BUILD_ID} || exit 1; \
docker tag ${DOCKER_USERNAME}/bird-lgproxy-go:$1-${BUILD_ID} ${DOCKER_USERNAME}/bird-lgproxy-go:$1 || exit 1; \
docker push ${DOCKER_USERNAME}/bird-lgproxy-go:$1 || exit 1; \
else \
echo "Dockerfile generation failed, see error above"; \
exit 1; \
@@ -30,28 +43,28 @@ $1/$2: $1/Dockerfile.$2
endef
# Function to create targets for images
define create-image-target
$1:$(foreach arch,latest ${ARCHITECTURES},$1/${arch})
$(foreach arch,${ARCHITECTURES},$(eval $(call create-image-arch-target,$(arch))))
# Target for latest image, mapping to amd64
$1/latest: $1/amd64
@docker tag ${DOCKER_USERNAME}/$1:amd64-${BUILD_ID} ${DOCKER_USERNAME}/$1:${BUILD_ID} || exit 1
docker push ${DOCKER_USERNAME}/$1:${BUILD_ID} || exit 1
@docker tag ${DOCKER_USERNAME}/$1:amd64-${BUILD_ID} ${DOCKER_USERNAME}/$1:latest || exit 1
docker push ${DOCKER_USERNAME}/$1:latest || exit 1
frontend:$(foreach arch,latest ${ARCHITECTURES},frontend/${arch})
$(foreach arch,${ARCHITECTURES},$(eval $(call create-image-arch-target,$1,$(arch))))
endef
frontend/latest: frontend/amd64
@docker tag ${DOCKER_USERNAME}/bird-lg-go:amd64-${BUILD_ID} ${DOCKER_USERNAME}/bird-lg-go:${BUILD_ID} || exit 1
@docker push ${DOCKER_USERNAME}/bird-lg-go:${BUILD_ID} || exit 1
@docker tag ${DOCKER_USERNAME}/bird-lg-go:amd64-${BUILD_ID} ${DOCKER_USERNAME}/bird-lg-go:latest || exit 1
@docker push ${DOCKER_USERNAME}/bird-lg-go:latest || exit 1
proxy:$(foreach arch,latest ${ARCHITECTURES},proxy/${arch})
proxy/latest: proxy/amd64
@docker tag ${DOCKER_USERNAME}/bird-lgproxy-go:amd64-${BUILD_ID} ${DOCKER_USERNAME}/bird-lgproxy-go:${BUILD_ID} || exit 1
@docker push ${DOCKER_USERNAME}/bird-lgproxy-go:${BUILD_ID} || exit 1
@docker tag ${DOCKER_USERNAME}/bird-lgproxy-go:amd64-${BUILD_ID} ${DOCKER_USERNAME}/bird-lgproxy-go:latest || exit 1
@docker push ${DOCKER_USERNAME}/bird-lgproxy-go:latest || exit 1
# By default, build docker images, and do not delete intermediate files
.DEFAULT_GOAL := images
.DELETE_ON_ERROR:
.SECONDARY:
# Create all targets for image/architecture combos
$(foreach image,${IMAGES},$(eval $(call create-image-target,${image})))
# Target to enable multiarch support
_crossbuild:
@docker run --rm --privileged multiarch/qemu-user-static --reset -p yes >/dev/null