-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathdockerfile
More file actions
38 lines (29 loc) · 1.42 KB
/
Copy pathdockerfile
File metadata and controls
38 lines (29 loc) · 1.42 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
# ╔═════════════════════════════════════════════════╗
# ║ BUILD STAGE ║
# ╚═════════════════════════════════════════════════╝
FROM golang:1.23.1-alpine3.20 AS build
# Install the dependencies
RUN apk add upx
COPY go.mod go.sum ./
RUN go mod download
# Build static binary
COPY . .
RUN CGO_ENABLED=0 go build -ldflags "-s -w" -o /tinyfeed
RUN upx /tinyfeed
# Create the user file
RUN adduser -H -D feed
# USER feed
# ╔═════════════════════════════════════════════════╗
# ║ PRODUCTION STAGE ║
# ╚═════════════════════════════════════════════════╝
FROM scratch AS production
# Create a user to avoid runing as root
COPY --from=build /etc/passwd /etc/passwd
USER feed
# Where the input and output files are
WORKDIR /app
# Copy the dependencies
COPY --chown=feed:feed --from=build /tinyfeed /usr/local/bin/tinyfeed
# Copy the certificates authorities
COPY --from=alpine:latest /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
ENTRYPOINT ["/usr/local/bin/tinyfeed"]