diff --git a/.github/workflows/test-cross-build.yaml b/.github/workflows/test-cross-build.yaml new file mode 100644 index 0000000..e5e77f8 --- /dev/null +++ b/.github/workflows/test-cross-build.yaml @@ -0,0 +1,27 @@ +name: Test Cross Build + + +on: + push: + branches: [ main ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ main ] + schedule: + - cron: "0 0 * * 0" + workflow_dispatch: + +jobs: + publish-images: + runs-on: ubuntu-latest + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Release the Docker image + run: make cross-build-container diff --git a/Dockerfile.nginx b/Dockerfile.nginx index daa380e..627b0bc 100644 --- a/Dockerfile.nginx +++ b/Dockerfile.nginx @@ -1,12 +1,18 @@ # Using a compact OS -# FROM docker.m.daocloud.io/nginx:1.23.1-alpine -ARG BASEIMAGE +# FROM nginx:1.23.1-alpine +# ARG BASEIMAGE -FROM $BASEIMAGE +FROM nginx:1.23.3-alpine AS base-amd64 +FROM nginx:1.23.3-alpine AS base-arm64 +FROM nginx:1.23.3-alpine AS base-arm +FROM mips64le/nginx:1.23.3 AS base-mips64le +FROM cr.loongnix.cn/library/nginx:1.23.1-alpine AS base-loongnix + +FROM base-$TARGETARCH # RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk -U upgrade --available +# RUN apk -U upgrade --available # RUN apk add --no-cache bash # Add 2048 stuff into Nginx server diff --git a/Makefile b/Makefile index b9ff3b7..16767fd 100644 --- a/Makefile +++ b/Makefile @@ -27,12 +27,12 @@ GIT_TAG ?= $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null) GIT_TAG_SHA ?= $(shell git describe --tags --dirty 2>/dev/null) MACHINE_TYPE := $(shell uname -m) -NGINX_BASEIMAGE=nginx:1.23.2-alpine +# NGINX_BASEIMAGE=nginx:1.23.2-alpine # Clear the "unreleased" string in BuildMetadata -ifeq ($(MACHINE_TYPE),loongarch64) - NGINX_BASEIMAGE = cr.loongnix.cn/library/nginx:1.23.1-alpine -endif +# ifeq ($(MACHINE_TYPE),loongarch64) +# NGINX_BASEIMAGE = cr.loongnix.cn/library/nginx:1.23.1-alpine +# endif # TAG is the tag of the container image, default to binary version. TAG?=$(GIT_TAG_SHA) @@ -54,12 +54,13 @@ IMAGE_ARCH:=$(REGISTRY)/dao-2048-$(MACHINE_TYPE):$(TAG) # export TRIVY_DB_REPOSITORY=ghcr.m.daocloud.io/aquasecurity/trivy-db TRIVY_DB_REPOSITORY?=ghcr.io/aquasecurity/trivy-db -TARGETS?=linux/arm,linux/arm64,linux/amd64 +TARGETS?=linux/arm,linux/arm64,linux/amd64,linux/mips64le +TARGETS_STATIC?=linux/arm,linux/arm64,linux/amd64 build-container: @echo "Build Image: $(IMAGE)" - @docker build -t "$(IMAGE_NGINX)" --file ./Dockerfile.nginx --build-arg BASEIMAGE=$(NGINX_BASEIMAGE) . - @docker build -t "$(IMAGE_STATIC)" --file ./Dockerfile.static . + @DOCKER_BUILDKIT=1 docker build -t "$(IMAGE_NGINX)" --file ./Dockerfile.nginx . + @DOCKER_BUILDKIT=1 docker build -t "$(IMAGE_STATIC)" --file ./Dockerfile.static . @docker tag $(IMAGE_NGINX) $(IMAGE) release-container: build-container @@ -69,7 +70,7 @@ release-container: build-container release-special-arch: @echo "Build Image: $(IMAGE_ARCH)" - @docker build -t "$(IMAGE_ARCH)" --file ./Dockerfile.nginx --build-arg BASEIMAGE=$(NGINX_BASEIMAGE) . + @DOCKER_BUILDKIT=1 docker build -t "$(IMAGE_ARCH)" --file ./Dockerfile.nginx --build-arg BASEIMAGE=$(NGINX_BASEIMAGE) . @docker push $(IMAGE_ARCH) test: build-container @@ -89,11 +90,11 @@ cve-scan: build-container cross-build-container: @docker buildx build --platform $(TARGETS) -t "$(IMAGE_NGINX)" --file ./Dockerfile.nginx --build-arg BASEIMAGE=$(NGINX_BASEIMAGE) . - @docker buildx build --platform $(TARGETS) -t "$(IMAGE_STATIC)" --file ./Dockerfile.static . + @docker buildx build --platform $(TARGETS_STATIC) -t "$(IMAGE_STATIC)" --file ./Dockerfile.static . cross-release-container: cross-build-container @docker buildx build --platform $(TARGETS) -t "$(IMAGE_NGINX)" --push --file ./Dockerfile.nginx --build-arg BASEIMAGE=$(NGINX_BASEIMAGE) . - @docker buildx build --platform $(TARGETS) -t "$(IMAGE_STATIC)" --push --file ./Dockerfile.static . + @docker buildx build --platform $(TARGETS_STATIC) -t "$(IMAGE_STATIC)" --push --file ./Dockerfile.static . @docker buildx build --platform $(TARGETS) -t "$(IMAGE)" --push --file ./Dockerfile.nginx --build-arg BASEIMAGE=$(NGINX_BASEIMAGE) . GITHUB_OWNER?=daocloud