-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (38 loc) · 1.03 KB
/
Dockerfile
File metadata and controls
51 lines (38 loc) · 1.03 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
46
47
48
49
50
51
# Use the official golang image to create a binary.
# This is based on Debian and sets the GOPATH to /go.
# https://hub.docker.com/_/golang
FROM --platform=$BUILDPLATFORM golang:1.24-bookworm AS builder
# Create and change to the app directory.
WORKDIR /app
# Cache deps
COPY go.mod go.sum ./
RUN go mod download
# Copy source
COPY . .
# Build args from buildx
ARG TARGETOS
ARG TARGETARCH
# Build static binary for correct platform
RUN CGO_ENABLED=0 \
GOOS=$TARGETOS \
GOARCH=$TARGETARCH \
go build \
-trimpath \
-ldflags="-s -w" \
-o mpa-service \
./cmd/mpa
RUN chmod 755 /app/mpa-service
# Use scratch image for smallest possible container
FROM scratch
WORKDIR /app
# CA certs
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# App
COPY --from=builder /app/mpa-service /app/mpa-service
COPY --from=builder /app/configs /app/configs
USER 1000
EXPOSE 80
LABEL maintainer="Space-DF" \
description="Multi-Protocol Agent (MPA) service" \
version="1.0"
CMD ["/app/mpa-service", "serve"]