forked from bitvora/wot-relay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-optimized
44 lines (31 loc) · 1005 Bytes
/
Dockerfile-optimized
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
# Stage 1: Build the Go application
FROM golang:bookworm AS builder
# Set the working directory within the container
WORKDIR /app
# Copy go.mod and go.sum files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy the rest of the application source code
COPY . .
# Set fixed environment variables for build
ENV DB_PATH="db"
ENV INDEX_PATH="templates/index.html"
ENV STATIC_PATH="templates/static"
# touch a .env
RUN touch .env
# Build the Go application
RUN go build -o main .
# Stage 2: Create a minimal image to run the Go application
FROM debian:bookworm-slim
# Set the working directory within the container
WORKDIR /app
# Copy the Go binary from the builder stage
COPY --from=builder /app/main /app/
# Copy any necessary files like templates, static assets, etc.
COPY --from=builder /app/templates /app/templates
COPY --from=builder /app/.env /app/
# Expose the port that the application will run on
EXPOSE 3334
# Set the command to run the executable
CMD ["./main"]