Skip to content

Commit 9330f4a

Browse files
committed
Add docker releases for scep Docker builds
1 parent 72f493e commit 9330f4a

3 files changed

Lines changed: 82 additions & 13 deletions

File tree

.github/workflows/CI.yml

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
6+
tags: ["v*.*.*"]
67
pull_request:
78
types: [opened, reopened, synchronize]
89

@@ -15,19 +16,59 @@ jobs:
1516
platform: [ubuntu-latest, macos-latest, windows-latest]
1617
runs-on: ${{ matrix.platform }}
1718
steps:
18-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v2
1920

20-
- name: setup go
21-
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
22-
with:
23-
go-version: ${{ matrix.go-version }}
21+
- name: setup go
22+
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
23+
with:
24+
go-version: ${{ matrix.go-version }}
2425

25-
- name: Build
26-
run: go build -v ./...
26+
- name: Build
27+
run: go build -v ./...
2728

28-
- name: Test
29-
run: go test -v ./...
29+
- name: Test
30+
run: go test -v ./...
3031

31-
- name: Format
32-
if: matrix.platform == 'ubuntu-latest'
33-
run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi
32+
- name: Format
33+
if: matrix.platform == 'ubuntu-latest'
34+
run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi
35+
docker-build-push:
36+
if: github.event_name != 'pull_request'
37+
needs: build-test
38+
runs-on: ubuntu-latest
39+
permissions:
40+
contents: read
41+
packages: write
42+
steps:
43+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
44+
with:
45+
fetch-depth: 0
46+
47+
- uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
48+
with:
49+
registry: ghcr.io
50+
username: ${{ github.actor }}
51+
password: ${{ secrets.GITHUB_TOKEN }}
52+
53+
- uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
54+
55+
- uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
56+
id: meta
57+
with:
58+
images: |
59+
ghcr.io/${{ github.repository }}
60+
tags: |
61+
type=ref,event=branch
62+
type=semver,pattern={{version}}
63+
type=semver,pattern={{major}}.{{minor}}
64+
type=semver,pattern={{major}}
65+
type=sha
66+
67+
- uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6.16.0
68+
with:
69+
context: .
70+
push: true
71+
file: Dockerfile.buildx
72+
platforms: linux/amd64,linux/arm64,linux/arm
73+
tags: ${{ steps.meta.outputs.tags }}
74+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile.buildx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM --platform=$BUILDPLATFORM golang:1.21 AS builder
2+
3+
WORKDIR /go/app
4+
5+
COPY . .
6+
7+
ARG TARGETOS TARGETARCH
8+
9+
RUN --mount=type=cache,target=/root/.cache/go-build \
10+
--mount=type=cache,target=/go/pkg \
11+
CGO_ENABLED=0 make \
12+
scepclient-$TARGETOS-$TARGETARCH \
13+
scepserver-$TARGETOS-$TARGETARCH
14+
15+
FROM alpine:3
16+
17+
ARG TARGETOS TARGETARCH
18+
19+
COPY --from=builder /go/app/scepclient-$TARGETOS-$TARGETARCH /usr/bin/scepclient
20+
COPY --from=builder /go/app/scepserver-$TARGETOS-$TARGETARCH /usr/bin/scepserver
21+
22+
EXPOSE 8080
23+
24+
VOLUME ["/depot"]
25+
26+
ENTRYPOINT ["scepserver"]

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ OSARCH=$(shell go env GOHOSTOS)-$(shell go env GOHOSTARCH)
44

55
SCEPCLIENT=\
66
scepclient-linux-amd64 \
7+
scepclient-linux-arm64 \
78
scepclient-linux-arm \
89
scepclient-darwin-amd64 \
910
scepclient-darwin-arm64 \
@@ -12,6 +13,7 @@ SCEPCLIENT=\
1213

1314
SCEPSERVER=\
1415
scepserver-linux-amd64 \
16+
scepserver-linux-arm64 \
1517
scepserver-linux-arm \
1618
scepserver-darwin-amd64 \
1719
scepserver-darwin-arm64 \

0 commit comments

Comments
 (0)