-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.Dockerfile
51 lines (34 loc) · 1.06 KB
/
api.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
42
43
44
45
46
47
48
49
50
51
# Use the official Golang base image for compilation
FROM golang:alpine as builder
# Install entr
RUN apk add fd entr make curl
# Set the working directory inside the container
WORKDIR /app
# Set the go binary directory
ENV GOBIN /usr/local/bin/
# Copy the Go module files to the container
COPY go.mod go.sum ./
# Download the Go module dependencies
RUN go mod download
# Copy the source code to the container
COPY . .
# Build the binaries
RUN CGO_ENABLED=0 GOOS=linux go install ./cmd/...
###
# Use a minimal base image for the final container
FROM scratch as deployment
# Set the working directory inside the container
WORKDIR /app
# Copy executables from the builder stage
COPY --from=builder /usr/local/bin/* /usr/local/bin/
# Expose the port on which the application listens
EXPOSE 8080
# Start the Go Fiber application
CMD ["api"]
###
# Use a minimal base image for the final container
FROM alpine as ctl
# Set the working directory inside the container
WORKDIR /app
# Copy executables from the builder stage
COPY --from=builder /usr/local/bin/* /usr/local/bin/