-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
25 lines (22 loc) · 964 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
FROM golang:1.13-alpine AS builder
ENV GO111MODULE=on
RUN apk update && apk add --no-cache git ca-certificates libcap && update-ca-certificates
WORKDIR /app
ADD . .
RUN go mod download
RUN go mod verify
RUN mkdir /kubedemo
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /kubedemo/kubedemo ./cmd
RUN addgroup -S -g 10101 appuser
RUN adduser -S -D -u 10101 -s /sbin/nologin -h /appuser -G appuser appuser
RUN chown -R appuser:appuser /kubedemo/kubedemo
RUN setcap 'cap_net_bind_service=+ep' /kubedemo/kubedemo
FROM scratch
EXPOSE 8080
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /etc/group /etc/passwd /etc/
COPY --from=builder /kubedemo /
USER appuser
ENTRYPOINT ["/kubedemo"]
# cap_net_bind_service çalışması için app klasör içinde olmalı, klasör kopyalanmalı.
# https://medium.com/elbstack/docker-go-and-privileged-ports-d6354db472c3