-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (23 loc) · 851 Bytes
/
Dockerfile
File metadata and controls
34 lines (23 loc) · 851 Bytes
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
# Stage 1: Install dependencies
FROM golang:1.21 as installer
WORKDIR /app
COPY go.mod /app
COPY go.sum /app
RUN go mod download
# Stage 2: Build the application
FROM installer as builder
COPY . /app
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /app/main ./main.go
# Stage 3: Create a lightweight runtime image
FROM ubuntu:20.04 as runner
ENV ENV=local
ENV CLOUDINARY_URL=cloudinary://991793784142871:oZ47iHrgrFQq4fe7ksKKlo7tg4A@dsr2xnaj7
WORKDIR /app
COPY --from=builder /app/main /app/main
COPY --from=builder /app/config/config.yml /app/config/config.yml
RUN apt-get update \
&& DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata ca-certificates --no-install-recommends \
&& ln -fs /usr/share/zoneinfo/Asia/Ho_Chi_Minh /etc/localtime \
&& rm -fr /var/lib/apt/lists/*
EXPOSE $PORT
ENTRYPOINT ["/app/main"]