mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-10 18:05:48 +02:00
feat: multi platform docker build
This commit is contained in:
parent
f69fadc4b7
commit
41ced2ea05
3 changed files with 39 additions and 19 deletions
43
.github/workflows/build.yml
vendored
43
.github/workflows/build.yml
vendored
|
@ -106,10 +106,6 @@ jobs:
|
|||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Get the version
|
||||
id: get_version
|
||||
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
|
@ -131,10 +127,12 @@ jobs:
|
|||
export _NAME=nginx-ui-$(jq ".$GOOS[\"$GOARCH$GOARM\"].name" -r < .github/build/build_info.json)
|
||||
export _ARCH=$(jq ".$GOOS[\"$GOARCH$GOARM\"].arch" -r < .github/build/build_info.json)
|
||||
export _ABI=$(jq ".$GOOS[\"$GOARCH$GOARM\"].abi // \"\"" -r < .github/build/build_info.json)
|
||||
echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, ABI: $_ABI, RELEASE_NAME: $_NAME"
|
||||
export _ARTIFACT=nginx-ui-$GOOS-$GOARCH$(if [[ "$GOARM" ]]; then echo "v$GOARM"; fi)
|
||||
echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, ABI: $_ABI, RELEASE_NAME: $_NAME, ARTIFACT_NAME: $_ARTIFACT"
|
||||
echo "ARCH_NAME=$_ARCH" >> $GITHUB_ENV
|
||||
echo "ABI=$_ABI" >> $GITHUB_ENV
|
||||
echo "DIST=$_NAME" >> $GITHUB_ENV
|
||||
echo "ARTIFACT=$_ARTIFACT" >> $GITHUB_ENV
|
||||
|
||||
- name: Install musl cross compiler
|
||||
if: env.GOOS == 'linux'
|
||||
|
@ -176,7 +174,7 @@ jobs:
|
|||
- name: Archive backend artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.DIST }}
|
||||
name: ${{ env.ARTIFACT }}
|
||||
path: dist/nginx-ui
|
||||
|
||||
- name: Prepare publish
|
||||
|
@ -191,49 +189,66 @@ jobs:
|
|||
with:
|
||||
files: ${{ env.DIST }}.tar.gz
|
||||
|
||||
docker-build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
env:
|
||||
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/arm/v5
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Get the version
|
||||
id: get_version
|
||||
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
path: ./dist
|
||||
|
||||
- name: Prepare Artifacts
|
||||
run: chmod +x ./dist/nginx-ui-*/nginx-ui
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
if: env.GOOS == 'linux' && env.GOARCH == 'amd64'
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Login to DockerHub
|
||||
if: env.GOOS == 'linux' && env.GOARCH == 'amd64'
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USER }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Prepare Dockerfile
|
||||
if: github.event_name == 'release' && env.GOOS == 'linux' && env.GOARCH == 'amd64'
|
||||
if: github.event_name == 'release'
|
||||
run: |
|
||||
cp ./Dockerfile ./dist
|
||||
cp -rp ./resources ./dist
|
||||
|
||||
- name: Build and push
|
||||
if: github.event_name == 'release' && env.GOOS == 'linux' && env.GOARCH == 'amd64'
|
||||
if: github.event_name == 'release'
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: ./dist
|
||||
file: ./dist/Dockerfile
|
||||
platforms: linux/amd64
|
||||
platforms: ${{ env.PLATFORMS }}
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: |
|
||||
uozi/nginx-ui:latest
|
||||
uozi/nginx-ui:${{ steps.get_version.outputs.VERSION }}
|
||||
|
||||
- name: Prepare Demo Dockerfile
|
||||
if: env.GOOS == 'linux' && env.GOARCH == 'amd64'
|
||||
run: |
|
||||
cp ./demo.Dockerfile ./dist
|
||||
cp -rp ./resources ./dist
|
||||
|
||||
- name: Build and push demo
|
||||
if: env.GOOS == 'linux' && env.GOARCH == 'amd64'
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: ./dist
|
||||
file: ./dist/demo.Dockerfile
|
||||
platforms: linux/amd64
|
||||
platforms: ${{ env.PLATFORMS }}
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: |
|
||||
uozi/nginx-ui-demo:latest
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# 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 443
|
||||
|
||||
|
@ -7,7 +9,7 @@ COPY resources/docker/start.sh /app/start.sh
|
|||
COPY resources/docker/nginx.conf /usr/etc/nginx/nginx.conf
|
||||
COPY resources/docker/nginx-ui.conf /usr/etc/nginx/conf.d/nginx-ui.conf
|
||||
COPY resources/docker/nginx-ui.conf /etc/nginx/conf.d/nginx-ui.conf
|
||||
COPY nginx-ui /app/nginx-ui
|
||||
COPY nginx-ui-$TARGETOS-$TARGETARCH$TARGETVARIANT/nginx-ui /app/nginx-ui
|
||||
|
||||
RUN cd /app && chmod a+x /app/start.sh \
|
||||
&& rm -f /etc/nginx/conf.d/default.conf \
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue