-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
33 lines (28 loc) · 916 Bytes
/
Dockerfile
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
# build
FROM golang:1.22 AS builder
WORKDIR /link-checker-service/
# cache dependencies
COPY go.mod go.sum ./
RUN go mod download
# now build the whole thing
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go test -v ./...
RUN CGO_ENABLED=0 GOOS=linux go build -v -o link-checker-service
RUN ./link-checker-service version
# TLS certificates & user
FROM alpine:latest as alpine
RUN apk --no-cache add ca-certificates
# create a user
RUN addgroup -S lcsgroup && adduser -S lcsuser -G lcsgroup
# run
FROM scratch
EXPOSE 8080
WORKDIR /
# copy tls certificates
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# copy the user
COPY --from=alpine /etc/passwd /etc/passwd
USER lcsuser
COPY --from=builder /link-checker-service/link-checker-service .
COPY .link-checker-service.toml .
ENTRYPOINT ["/link-checker-service", "serve", "--config", "./.link-checker-service.toml"]