-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.worker
More file actions
45 lines (30 loc) · 1.1 KB
/
Dockerfile.worker
File metadata and controls
45 lines (30 loc) · 1.1 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# syntax=docker/dockerfile:1
ARG GO_VERSION=1.26.2
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS builder
WORKDIR /src
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
ARG ARCH
ARG UID=10001
ARG VERSION=""
ENV VERSION=${VERSION}
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download -x
COPY . .
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build \
GOARCH_TARGET=${ARCH:-${TARGETARCH:-amd64}}; \
CGO_ENABLED=0 GOARCH=${GOARCH_TARGET} go build \
-ldflags="all=-s -w -X main.Version=${VERSION} -X main.BuildTime=$(date +%FT%T%z)" \
-trimpath -o /out/worker-service ./cmd/worker-service
FROM gcr.io/distroless/base-debian13:nonroot AS runtime
COPY --from=builder /out/worker-service /usr/local/bin/worker-service
EXPOSE 50052
ENTRYPOINT ["/usr/local/bin/worker-service"]
FROM alpine:3.23.4 AS runtime-docker
RUN apk add --no-cache ca-certificates docker-cli docker-cli-buildx git
COPY --from=builder /out/worker-service /usr/local/bin/worker-service
EXPOSE 50052
ENTRYPOINT ["/usr/local/bin/worker-service"]