Skip to content

Commit 45fefd0

Browse files
committed
define args
1 parent ea065df commit 45fefd0

File tree

2 files changed

+12
-30
lines changed

2 files changed

+12
-30
lines changed

.github/workflows/build.yaml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,28 @@ jobs:
2727
uses: actions/checkout@v4
2828

2929
- name: Log in to the Container registry
30-
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
30+
uses: docker/login-action@v3
3131
with:
3232
registry: ${{ env.REGISTRY }}
3333
username: ${{ github.actor }}
3434
password: ${{ secrets.GITHUB_TOKEN }}
3535

3636
- name: Set up Docker Buildx
37-
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
37+
uses: docker/setup-buildx-action@v3
3838

3939
- name: Extract metadata (tags, labels) for Docker
4040
id: meta
41-
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.1.1
41+
uses: docker/metadata-action@v5
4242
with:
4343
images: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
4444

4545
- name: AMD - Build and push Docker image
46-
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
46+
uses: docker/build-push-action@v5
4747
with:
4848
context: .
4949
push: true
50-
build-args: |
51-
TARGETOS=linux
52-
TARGETARCH=amd64
53-
tags: ${{ steps.meta.outputs.tags }}
54-
labels: ${{ steps.meta.outputs.labels }}
55-
56-
- name: ARM - Build and push Docker image
57-
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
58-
with:
59-
context: .
60-
push: true
61-
build-args: |
62-
TARGETOS=linux
63-
TARGETARCH=arm64
50+
platforms: |
51+
linux/amd64
52+
linux/arm64
6453
tags: ${{ steps.meta.outputs.tags }}
6554
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
FROM --platform=$BUILDPLATFORM golang:1.22-alpine3.19 as builder
2-
3-
RUN apk update && \
4-
apk add bash jq alpine-sdk sed gawk git ca-certificates curl && \
5-
apk add --no-cache gcc musl-dev
6-
2+
# Define target arch variables so we can use them while crosscompiling, will be set automatically
3+
ARG TARGETOS
4+
ARG TARGETARCH
75
WORKDIR /go/src/
86

97
# get dependencies
@@ -14,17 +12,12 @@ RUN go mod download
1412
COPY . .
1513

1614
# Build project
17-
ARG TARGETOS=linux
18-
ARG TARGETARCH=amd64
19-
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -ldflags "-s -w" -a -installsuffix cgo -o /radix-oauth-guard
15+
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -ldflags "-s -w" -a -installsuffix cgo -o /radix-oauth-guard
2016

21-
RUN addgroup -S -g 1000 guard
22-
RUN adduser -S -u 1000 -G guard guard
2317

24-
FROM --platform=$TARGETOS/$TARGETARCH scratch
18+
FROM --platform=$TARGETPLATFORM scratch
2519

2620
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
27-
COPY --from=builder /etc/passwd /etc/passwd
2821
COPY --from=builder /radix-oauth-guard /radix-oauth-guard
2922

3023
EXPOSE 8000

0 commit comments

Comments
 (0)