-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
32 lines (23 loc) · 862 Bytes
/
Copy pathDockerfile
File metadata and controls
32 lines (23 loc) · 862 Bytes
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
# Start from the official Go image for building
FROM golang:1.24 AS builder
# Set the working directory inside the container
WORKDIR /app
# Copy the Go source code into the container
COPY . .
# Download dependencies
RUN go mod tidy
# Build the Go CLI application as a statically linked binary
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gotutor .
# Use a minimal base image for the final container
FROM alpine:latest
# Set the working directory inside the container
WORKDIR /root/
# Copy the Go binary from the builder stage
COPY --from=builder /usr/local/go/ /usr/local/go/
ENV PATH="/usr/local/go/bin:${PATH}"
# Copy the compiled binary from the builder stage
COPY --from=builder /app/gotutor .
# Make sure the binary is executable
RUN chmod +x gotutor
# Define the command to run when the container starts
ENTRYPOINT ["./gotutor"]