-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
43 lines (28 loc) · 1001 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
FROM golang:alpine AS builder
LABEL maintainer="Nanang Suryadi <[email protected]>"
RUN set -eux && apk --update --no-cache add ca-certificates upx
WORKDIR /project
COPY cmd cmd
COPY pkg pkg
# Copy and download dependencies.
COPY go.mod go.sum ./
RUN go mod tidy
# Build the binary.
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -tags dynamic -ldflags="-s -w" -o ./build/app ./cmd/bin/main.go
COPY ./config.yaml ./config.yaml
# Compress binary
RUN set -eux && upx "./build/app" && upx -t "./build/app" && chmod +x "./build/app"
# Clear cache and app files
RUN set -eux && apk del ca-certificates upx && rm -rf /var/cache/apk/*
FROM alpine:3.16
RUN date
ENV TZ=Asia/Jakarta
RUN apk add -U tzdata
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN date
RUN apk add --no-cache
RUN mkdir /.data
COPY --from=builder ["/project/build/app", "/app"]
COPY --from=builder ["/project/config.yaml", "/config.yaml"]
EXPOSE 8007
CMD [ "./app" ]