-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
32 lines (23 loc) · 698 Bytes
/
Dockerfile
File metadata and controls
32 lines (23 loc) · 698 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
# Use official Golang image as a builder
FROM golang:1.24 AS builder
# Set working directory
WORKDIR /app
# Copy go modules and download dependencies
COPY go.mod go.sum ./
RUN go mod tidy
# Copy application source
COPY . .
# Ensure the binary is built for Alpine Linux
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o server ./cmd/server/main.go
# Use a lightweight Alpine Linux image
FROM alpine:latest
WORKDIR /root/
# Install dependencies
RUN apk --no-cache add ca-certificates
# Copy the compiled binary and grant execution permissions
COPY --from=builder /app/server .
RUN chmod +x /root/server
# Expose the application port
EXPOSE 8080
# Run the application
CMD ["/root/server"]