-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdockerfile
41 lines (27 loc) · 835 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
FROM golang:alpine3.20 AS build
# Set the working directory to /app
WORKDIR /app
# Copy the go.mod and go.sum files to the working directory
COPY go.mod go.sum ./
# Download and install any required Go dependencies
RUN --mount=type=cache,target=go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod download
CMD [ "make", "seed" ]
# Copy the entire source code to the working directory
COPY . .
# Build the Go application
RUN go build \
# -ldflags="-linkmode external -extldflags -static" \
-tags netgo \
-o main
# Multistage build
FROM scratch
# Copy the .env file into the image
COPY .env .env
ENV GOFIBER_MODE=release
COPY --from=build /app/main main
# Expose the port specified by the PORT environment variable
EXPOSE 8000
# Set the entry point of the container to the executable
CMD ["./main"]