-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
47 lines (30 loc) · 828 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
##
## STEP 1 - BUILD
##
# the base image to be used for the application
FROM golang:1.18-alpine AS build
RUN adduser -u 1001 -D gouser
RUN apk add --no-cache git ca-certificates
ENV GO111MODULE=on GOOS=linux
# create a working directory inside the image
WORKDIR /app
# copy Go modules and dependencies to image
COPY go.mod ./
COPY go.sum ./
# download Go modules and dependencies
RUN go mod download
# copy all files and folders
COPY ./ ./
# compile application
RUN CGO_ENABLED=0 go build -o /company-service -ldflags="-w -s"
##
## STEP 2 - DEPLOY
##
FROM scratch
WORKDIR /
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build /company-service /company-service
COPY --from=build /etc/passwd /etc/passwd
USER 1001
EXPOSE 8080
ENTRYPOINT ["/company-service"]