generated from GalvinGao/gofiber-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
33 lines (24 loc) · 792 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
FROM golang:1.22.1-alpine AS base
WORKDIR /app
# builder
FROM base AS builder
ENV GOOS linux
ENV GOARCH amd64
# build-args
ARG VERSION
RUN apk --no-cache add bash git openssh
# modules: utilize build cache
COPY go.mod ./
COPY go.sum ./
RUN go mod download
COPY . .
# inject versioning information & build the binary
RUN export BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ"); go build -o app -ldflags "-X github.com/GalvinGao/gofiber-template/internal/app/appbundle.Version=$VERSION -X github.com/GalvinGao/gofiber-template/internal/app/appbundle.BuildTimeString=$BUILD_TIME" .
# runner
FROM base AS runner
RUN apk add --no-cache libc6-compat tini
# Tini is now available at /sbin/tini
COPY --from=builder /app/app /app/app
EXPOSE 8080
ENTRYPOINT ["/sbin/tini", "--"]
CMD [ "/app/app" ]