feat: multi platform docker build

This commit is contained in:
Hintay 2023-01-08 00:27:48 +08:00
parent f69fadc4b7
commit 41ced2ea05
No known key found for this signature in database
GPG key ID: 120FC7FF121F2F2D
3 changed files with 39 additions and 19 deletions

View file

@ -1,5 +1,8 @@
# CGO_ENABLED=1 GOOS=linux CC=x86_64-unknown-linux-gnu-gcc CXX=x86_64-unknown-linux-gnu-g++ GOARCH=amd64 go build -ldflags "-X 'github.com/0xJacky/Nginx-UI/server/settings.buildTime=$(date +%s)'" -o nginx-ui -v main.go
FROM --platform=linux/amd64 uozi/nginx-ui-base:latest
FROM --platform=$TARGETPLATFORM uozi/nginx-ui-base:latest
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
WORKDIR /app
EXPOSE 80
@ -9,7 +12,7 @@ COPY resources/demo/demo.db /etc/nginx-ui/database.db
COPY resources/docker/nginx.conf /etc/nginx/nginx.conf
COPY resources/docker/nginx-ui.conf /etc/nginx/conf.d/nginx-ui.conf
COPY resources/docker/start.sh /app/start.sh
COPY nginx-ui /app/nginx-ui
COPY nginx-ui-$TARGETOS-$TARGETARCH$TARGETVARIANT/nginx-ui /app/nginx-ui
RUN cd /app && chmod a+x start.sh && rm -f /etc/nginx/conf.d/default.conf