-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
31 lines (22 loc) · 806 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# syntax=docker/dockerfile:1
# Build stage: use native architecture and Go's cross-compilation
FROM --platform=$BUILDPLATFORM golang:1.22.2@sha256:450e3822c7a135e1463cd83e51c8e2eb03b86a02113c89424e6f0f8344bb4168 AS build
# Set destination for COPY
WORKDIR /app
# For better layer caching, copy and install dependencies first then build app
COPY go.mod go.sum ./
RUN go mod download
# Note the slash at the end, as explained in
# https://docs.docker.com/engine/reference/builder/#copy
COPY . ./
# Set by docker automatically
ARG TARGETOS TARGETARCH
ARG GOOS=$TARGETOS
ARG GOARCH=$TARGETARCH
RUN make build
# Final stage
FROM alpine:3.20.0@sha256:77726ef6b57ddf65bb551896826ec38bc3e53f75cdde31354fbffb4f25238ebd
WORKDIR /bin
COPY --from=build /app/bin/testbed ./
# Run
ENTRYPOINT [ "/bin/testbed" ]