-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
56 lines (37 loc) · 1.04 KB
/
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
FROM alpine:latest as certs
# getting certs
RUN apk update && apk upgrade && apk add --no-cache ca-certificates
FROM node:22 as build_assets
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build
FROM golang:latest as build
# set work dir
WORKDIR /app
# copy the source files
COPY . .
# disable crosscompiling
ENV CGO_ENABLED=0
# compile linux only
ENV GOOS=linux
# build the binary with debug information removed
RUN go build -ldflags '-w -s -X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn' -a -installsuffix cgo -o server
FROM alpine:latest
# set work dir
WORKDIR /app
# copy our static linked library
COPY --from=build /app/server .
# copy templates
COPY --from=build /app/templates ./templates
# copy pub
COPY --from=build /app/pub ./pub
# copy assets
COPY --from=build_assets /app/assets/dist ./assets/dist
# copy certs
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# tell we are exposing our service on ports 8080 8081
EXPOSE 8080 8081
ENV GIN_MODE=release
# run it!
CMD ["./server", "serve"]