-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
58 lines (35 loc) · 837 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# #### - DEV - ####
# FROM golang:1.22.3 AS dev
# WORKDIR /cmd
# COPY cmd/go.mod go.mod
# COPY cmd/go.sum go.sum
# RUN go mod download
# COPY cmd/ ./
# CMD ["go", "run", "."]
# #### - TESTS - ####
# FROM golang:1.22.3 AS tester
# WORKDIR /cmd
# COPY cmd/go.mod go.mod
# COPY cmd/go.sum go.sum
# RUN go mod download
# COPY cmd/ ./
# CMD ["go", "test", "-v", "./..."]
#### - BUILDER - ####
FROM golang:1.22.3 AS builder
WORKDIR /usr
COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download
COPY . .
RUN go build -o /bin/main main.go
#### - SERVER - ####
FROM alpine:3.19.1 as server
RUN apk add --no-cache \
gcompat=1.1.0-r4 \
libstdc++=13.2.1_git20231014-r0
WORKDIR /srv
COPY --from=builder /bin/main ./main
RUN adduser --system --no-create-home nonroot
USER nonroot
ENV TERM=xterm
ENTRYPOINT [ "./main" ]