Skip to content

Commit

Permalink
Merge pull request #78 from yankay/support-mips
Browse files Browse the repository at this point in the history
support mips
  • Loading branch information
yankay authored Dec 20, 2022
2 parents e95de6f + d18359a commit 5cd5361
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 14 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/test-cross-build.yaml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 10 additions & 4 deletions Dockerfile.nginx
Original file line number Diff line number Diff line change
@@ -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
Expand Down
21 changes: 11 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 5cd5361

Please sign in to comment.