-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
37 lines (24 loc) · 790 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
#syntax=docker/dockerfile:1.2
# build static binary
FROM golang:1.19.0-alpine3.16 as builder
WORKDIR /go/src/go-tg-bot
# download dependencies
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ARG BUILD_VERSION
ARG BUILD_REF
ARG BUILD_TIME
# compile
RUN CGO_ENABLED=0 go build \
-ldflags="-w -s -extldflags \"-static\" -X \"main.buildVersion=${BUILD_VERSION}\" -X \"main.buildCommit=${BUILD_REF}\" -X \"main.buildTime=${BUILD_TIME}\"" \
-a \
-tags timetzdata \
-o /bin/go-tg-bot .
# run
FROM alpine:3.16
COPY --from=builder /bin/go-tg-bot /bin/go-tg-bot
EXPOSE 8000
# Reference: https://github.com/opencontainers/image-spec/blob/master/annotations.md
LABEL org.opencontainers.image.source="https://github.com/mr-linch/go-tg-bot"
ENTRYPOINT [ "/bin/go-tg-bot" ]