-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
34 lines (24 loc) · 851 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
FROM --platform=$BUILDPLATFORM golang:1.23 AS builder
# Set the Current Working Directory inside the container
WORKDIR /app
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download and verify dependencies
RUN go mod download
RUN go mod verify
# Copy the source from the current directory to the Working Directory inside the container
COPY ./cmd ./cmd
COPY ./internal ./internal
COPY ./ui ./ui
# Build the Go app
RUN env ${opts} go build -v -o /app/snippetbox ./cmd/web
# Use a minimal image to run the binary
FROM --platform=$BUILDPLATFORM ubuntu:24.10
# Copy the pre-built binary from the dist directory to the container
COPY --from=builder /app/snippetbox /app/snippetbox
# Copy the UI files
COPY --from=builder /app/ui /ui
# Expose the port that the service will run on
EXPOSE 4000
# Command to run the binary
CMD ["/app/snippetbox"]