generated from WildEgor/e-shop-fiber-microservice-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
38 lines (31 loc) · 923 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
# Base Stage
FROM golang:1.22-alpine AS base
LABEL maintainer="YOUR_NAME <YOUR_EMAIL>"
# if use private libs
#ARG GITHUB_TOKEN
#RUN apk update && apk add ca-certificates git openssh
#RUN git configs --global url."https://${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download && mkdir -p dist
# Development Stage
FROM base as dev
WORKDIR /app
COPY . .
RUN go install -mod=mod github.com/cosmtrek/air
CMD ["air", "-c", ".air-unix.toml", "-d"]
# # Test Stage
# FROM base as test
# ENTRYPOINT make test
# Build Production Stage
FROM base as builder
WORKDIR /app
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o dist/app cmd/main.go
# Production Stage
FROM cgr.dev/chainguard/busybox:latest-glibc as production
WORKDIR /app/
COPY --from=builder /app/dist/app .
# Specify method fetch .env!
COPY --from=builder /app/.env.local .
CMD ["./app"]