chore(docker): support multiple platform
fix https://github.com/appleboy/gorush/issues/720
This commit is contained in:
parent
a493ed67ba
commit
f434c97a68
|
@ -6,22 +6,13 @@ on:
|
||||||
- master
|
- master
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-docker:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
max-parallel: 3
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest]
|
|
||||||
system: [linux]
|
|
||||||
arch: [amd64, arm, arm64]
|
|
||||||
# support windows build and push?
|
|
||||||
# see the issue: https://github.com/docker/build-push-action/issues/18
|
|
||||||
# include:
|
|
||||||
# - os: windows-2022
|
|
||||||
# system: windows
|
|
||||||
# arch: amd64
|
|
||||||
steps:
|
steps:
|
||||||
- name: Setup go
|
- name: Setup go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
|
@ -34,13 +25,9 @@ jobs:
|
||||||
|
|
||||||
- name: Build binary
|
- name: Build binary
|
||||||
run : |
|
run : |
|
||||||
make build_${{ matrix.system }}_${{ matrix.arch }}
|
make build_linux_amd64
|
||||||
|
make build_linux_arm
|
||||||
- name: Check binary
|
make build_linux_arm64
|
||||||
if: matrix.system == 'linux' && matrix.arch == 'amd64'
|
|
||||||
run : |
|
|
||||||
./release/${{ matrix.system }}/${{ matrix.arch }}/${GITHUB_REPOSITORY#*/} --help
|
|
||||||
|
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v2
|
||||||
|
@ -65,30 +52,26 @@ jobs:
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
-
|
-
|
||||||
name: Docker meta for ${{ matrix.system }} ${{ matrix.arch }}
|
name: Docker meta
|
||||||
id: docker-meta
|
id: docker-meta
|
||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v4
|
||||||
with:
|
with:
|
||||||
flavor: |
|
|
||||||
latest=false
|
|
||||||
suffix=${{ matrix.system }}-${{ matrix.arch }}
|
|
||||||
images: |
|
images: |
|
||||||
${{ github.repository }}
|
${{ github.repository }}
|
||||||
ghcr.io/${{ github.repository }}
|
ghcr.io/${{ github.repository }}
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=,enable={{is_default_branch}}
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
type=raw,value=latest,suffix=,enable={{is_default_branch}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,event=tag,pattern={{version}},suffix=-${{ matrix.system }}-${{ matrix.arch }}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=semver,event=tag,pattern={{major}}.{{minor}},suffix=-${{ matrix.system }}-${{ matrix.arch }}
|
type=semver,pattern={{major}}
|
||||||
type=semver,event=tag,pattern={{major}},suffix=-${{ matrix.system }}-${{ matrix.arch }}
|
|
||||||
|
|
||||||
-
|
-
|
||||||
name: Build and push ${{ matrix.system }} ${{ matrix.arch }}
|
name: Build and push
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: docker/Dockerfile.${{ matrix.system }}.${{ matrix.arch }}
|
platforms: linux/amd64,linux/arm,linux/arm64
|
||||||
platforms: ${{ matrix.system }}/${{ matrix.arch }}
|
file: docker/Dockerfile
|
||||||
push: true
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.docker-meta.outputs.tags }}
|
tags: ${{ steps.docker-meta.outputs.tags }}
|
||||||
labels: ${{ steps.docker-meta.outputs.labels }}
|
labels: ${{ steps.docker-meta.outputs.labels }}
|
||||||
|
|
|
@ -24,17 +24,9 @@ jobs:
|
||||||
args: --verbose
|
args: --verbose
|
||||||
|
|
||||||
- uses: hadolint/hadolint-action@v3.1.0
|
- uses: hadolint/hadolint-action@v3.1.0
|
||||||
name: hadolint for Dockerfile.linux.amd64
|
name: hadolint for Dockerfile
|
||||||
with:
|
with:
|
||||||
dockerfile: docker/Dockerfile.linux.amd64
|
dockerfile: docker/Dockerfile
|
||||||
- uses: hadolint/hadolint-action@v3.1.0
|
|
||||||
name: hadolint for Dockerfile.linux.arm64
|
|
||||||
with:
|
|
||||||
dockerfile: docker/Dockerfile.linux.arm64
|
|
||||||
- uses: hadolint/hadolint-action@v3.1.0
|
|
||||||
name: hadolint for Dockerfile.linux.arm
|
|
||||||
with:
|
|
||||||
dockerfile: docker/Dockerfile.linux.arm
|
|
||||||
|
|
||||||
testing:
|
testing:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
FROM alpine:3.15.4@sha256:a777c9c66ba177ccfea23f2a216ff6721e78a662cd17019488c417135299cd89
|
FROM alpine:3.17
|
||||||
|
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
||||||
org.label-schema.name="Gorush" \
|
org.label-schema.name="Gorush" \
|
||||||
|
@ -6,9 +9,9 @@ LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
||||||
org.label-schema.schema-version="1.0"
|
org.label-schema.schema-version="1.0"
|
||||||
|
|
||||||
RUN apk add --no-cache ca-certificates mailcap && \
|
RUN apk add --no-cache ca-certificates mailcap && \
|
||||||
echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
|
rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
COPY release/linux/arm/gorush /bin/
|
COPY release/${TARGETOS}/${TARGETARCH}/gorush /bin/
|
||||||
|
|
||||||
EXPOSE 8088 9000
|
EXPOSE 8088 9000
|
||||||
HEALTHCHECK --start-period=1s --interval=10s --timeout=5s \
|
HEALTHCHECK --start-period=1s --interval=10s --timeout=5s \
|
|
@ -1,17 +0,0 @@
|
||||||
FROM alpine:3.15.4@sha256:a777c9c66ba177ccfea23f2a216ff6721e78a662cd17019488c417135299cd89
|
|
||||||
|
|
||||||
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
|
||||||
org.label-schema.name="Gorush" \
|
|
||||||
org.label-schema.vendor="Bo-Yi Wu" \
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
RUN apk add --no-cache ca-certificates mailcap && \
|
|
||||||
echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
|
|
||||||
|
|
||||||
COPY release/linux/amd64/gorush /bin/
|
|
||||||
|
|
||||||
EXPOSE 8088 9000
|
|
||||||
HEALTHCHECK --start-period=1s --interval=10s --timeout=5s \
|
|
||||||
CMD ["/bin/gorush", "--ping"]
|
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/gorush"]
|
|
|
@ -1,17 +0,0 @@
|
||||||
FROM alpine:3.15.4@sha256:a777c9c66ba177ccfea23f2a216ff6721e78a662cd17019488c417135299cd89
|
|
||||||
|
|
||||||
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
|
||||||
org.label-schema.name="Gorush" \
|
|
||||||
org.label-schema.vendor="Bo-Yi Wu" \
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
RUN apk add --no-cache ca-certificates mailcap && \
|
|
||||||
echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
|
|
||||||
|
|
||||||
COPY release/linux/arm64/gorush /bin/
|
|
||||||
|
|
||||||
EXPOSE 8088 9000
|
|
||||||
HEALTHCHECK --start-period=1s --interval=10s --timeout=5s \
|
|
||||||
CMD ["/bin/gorush", "--ping"]
|
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/gorush"]
|
|
|
@ -1,14 +0,0 @@
|
||||||
FROM mcr.microsoft.com/windows/nanoserver:1809-amd64
|
|
||||||
|
|
||||||
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
|
||||||
org.label-schema.name="Gorush" \
|
|
||||||
org.label-schema.vendor="Bo-Yi Wu" \
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
COPY release/gorush.exe C:/bin/gorush.exe
|
|
||||||
|
|
||||||
EXPOSE 8088 9000
|
|
||||||
HEALTHCHECK --start-period=1s --interval=10s --timeout=5s \
|
|
||||||
CMD ["\\gorush.exe", "--ping"]
|
|
||||||
|
|
||||||
ENTRYPOINT [ "C:\\bin\\gorush.exe" ]
|
|
|
@ -1,25 +0,0 @@
|
||||||
image: appleboy/gorush:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
|
||||||
{{#if build.tags}}
|
|
||||||
tags:
|
|
||||||
{{#each build.tags}}
|
|
||||||
- {{this}}
|
|
||||||
{{/each}}
|
|
||||||
{{/if}}
|
|
||||||
manifests:
|
|
||||||
-
|
|
||||||
image: appleboy/gorush:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
|
|
||||||
platform:
|
|
||||||
architecture: amd64
|
|
||||||
os: linux
|
|
||||||
-
|
|
||||||
image: appleboy/gorush:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
|
|
||||||
platform:
|
|
||||||
architecture: arm64
|
|
||||||
os: linux
|
|
||||||
variant: v8
|
|
||||||
-
|
|
||||||
image: appleboy/gorush:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
|
|
||||||
platform:
|
|
||||||
architecture: arm
|
|
||||||
os: linux
|
|
||||||
variant: v7
|
|
Loading…
Reference in New Issue