-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.Template
48 lines (36 loc) · 1.07 KB
/
Dockerfile.Template
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
ARG GO_VERSION=1.14.3
FROM golang:${GO_VERSION}-alpine AS builder
RUN apk update && apk add alpine-sdk git && rm -rf /var/cache/apk/*
# install UPX
ADD https://github.com/upx/upx/releases/download/v3.95/upx-3.95-amd64_linux.tar.xz /usr/local
RUN xz -d -c /usr/local/upx-3.95-amd64_linux.tar.xz | \
tar -xOf - upx-3.95-amd64_linux/upx > /bin/upx && \
chmod a+x /bin/upx
RUN mkdir -p /api
WORKDIR /api
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main ./main.go
RUN strip --strip-unneeded main
RUN upx main
FROM alpine:latest
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
RUN mkdir -p /api
WORKDIR /api
COPY --from=builder /api/main .
# Set Env
ENV GIN_MODE=release
ENV OTP_SECRET=4S62BZNFXXSZLCRO
ENV DB_TYPE=postgres
ENV DB_HOST=localhost
ENV DB_PORT=5432
ENV DB_NAME=generic-otp
ENV DB_USER=postgres
ENV DB_PASSWORD=<insert password here>
ENV DB_POSTGRES_SSL_SETTING=disable
ENV OTP_REQUEST_LOGGING_ENABLED=1
ENV OTP_VERIFICATION_LOGGING_ENABLED=0
EXPOSE 3000
CMD ["./main"]