-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
31 lines (23 loc) · 929 Bytes
/
Dockerfile
File metadata and controls
31 lines (23 loc) · 929 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
29
30
31
FROM golang:alpine AS buildstage
# Declare build platform arguments (automatically populated by BuildKit)
ARG TARGETARCH
ARG TARGETOS=linux
WORKDIR /app
# Copy dependency files first for better caching
COPY go.mod go.sum ./
# Use mount cache for go modules to speed up downloads
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
# Copy source code
COPY . .
# build arguments for version information
ARG VERSION=dev
ARG COMMIT_SHA=unknown
# Use mount cache for both go modules and build cache
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -ldflags="-X 'main.version=$VERSION' -X 'main.commit=$COMMIT_SHA'" -o polylang-detector ./cmd/main.go
FROM alpine:latest
COPY --from=buildstage /app/polylang-detector ./polylang-detector
RUN chmod +x polylang-detector
ENTRYPOINT ["./polylang-detector"]