-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
28 lines (22 loc) · 817 Bytes
/
Copy pathDockerfile
File metadata and controls
28 lines (22 loc) · 817 Bytes
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
# syntax=docker/dockerfile:1
ARG GO_VERSION=1.22
ARG ALPINE_VERSION=3.20
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS build
WORKDIR /src
ARG TARGETOS=linux
ARG TARGETARCH
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN targetos="${TARGETOS:-linux}" \
&& targetarch="${TARGETARCH:-$(go env GOARCH)}" \
&& CGO_ENABLED=0 GOOS="${targetos}" GOARCH="${targetarch}" \
go build -trimpath -ldflags="-s -w" -o /out/airpc ./cmd/airpc \
&& CGO_ENABLED=0 GOOS="${targetos}" GOARCH="${targetarch}" \
go build -trimpath -ldflags="-s -w" -o /out/airpc-e2e ./cmd/airpc-e2e
FROM alpine:${ALPINE_VERSION}
RUN adduser -D -H -u 10001 appuser
COPY --from=build /out/airpc /usr/local/bin/airpc
COPY --from=build /out/airpc-e2e /usr/local/bin/airpc-e2e
USER appuser
CMD ["/usr/local/bin/airpc"]