forked from dezh-tech/immortal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerfile
41 lines (30 loc) · 985 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
# --------------------------
#! Stage 1: Build the Go binary
# --------------------------
FROM golang:1.22.5-alpine AS builder
WORKDIR /app
#* Install required build tools
RUN apk --no-cache add build-base git
#* Cache dependencies by copying go.mod and go.sum first
COPY go.mod go.sum ./
RUN go mod download
#* Copy the rest of the application source code
COPY . .
#* Build the Go binary using the provided Makefile
RUN make build
# --------------------------
#! Stage 2: Create the runtime image
# --------------------------
FROM alpine:latest
WORKDIR /app
#* Define build-time arguments and environment variables
ARG IMMO_MONGO_URI
ENV IMMO_MONGO_URI=${IMMO_MONGO_URI}
#* Copy the compiled binary from the builder stage
COPY --from=builder /app/build/immortal .
COPY --from=builder /app/config/config.yml .
#* Expose necessary ports for the application
EXPOSE 9090
EXPOSE 8080
#* Set the entrypoint to run the application
ENTRYPOINT ["./immortal", "run", "./config.yml"]