-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
33 lines (24 loc) · 697 Bytes
/
Dockerfile
File metadata and controls
33 lines (24 loc) · 697 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
33
# Build and run stage
FROM golang:1.25.3-alpine
WORKDIR /app
# Install dependencies
RUN apk add --no-cache git ca-certificates
# Copy go mod files and download dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy source code (use .dockerignore to exclude sensitive files)
# Copy only source code (not the entire directory)
COPY cmd/ ./cmd/
COPY docs/ ./docs/
COPY internal/ ./internal/
COPY pkg/ ./pkg/
COPY api/ ./api/
# Build the application and create non-root user in one layer
RUN CGO_ENABLED=0 GOOS=linux go build -o server ./cmd/app/main.go && \
adduser -D appuser
# Switch to non-root user
USER appuser
# Expose port
EXPOSE 8080
# Run the application
CMD ["./server"]