-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (39 loc) · 1.29 KB
/
Dockerfile
File metadata and controls
52 lines (39 loc) · 1.29 KB
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
45
46
47
48
49
50
51
52
# Build stage
FROM golang:1.24-alpine AS builder
# Install build dependencies
RUN apk add --no-cache git ca-certificates
WORKDIR /build
# Copy dependency files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code and assets
COPY . .
# Build arguments
ARG VERSION=dev
# Build the application with version info
# Static binary with embedded assets (JS dependencies in assets/js/)
RUN CGO_ENABLED=0 GOOS=linux go build \
-mod=mod \
-ldflags="-w -s -X main.version=${VERSION}" \
-a -installsuffix cgo \
-o lsget .
# Runtime stage - Distroless for maximum security
# No shell, no package manager, minimal attack surface
FROM gcr.io/distroless/static-debian12:nonroot
# Copy CA certificates for HTTPS
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# Copy binary from builder
COPY --from=builder /build/lsget /app/lsget
# Distroless runs as nonroot user (UID 65532) by default
# No need to create user or switch
# Expose default port
EXPOSE 8080
# Set volumes for data and logs
# Note: Volumes must be writable by UID 65532 (nonroot user)
VOLUME ["/data", "/logs"]
# Run lsget directly - no entrypoint script needed
# Configuration via environment variables:
# LSGET_ADDR=0.0.0.0:8080
# LSGET_DIR=/data
# LSGET_LOGFILE=/logs/access.log
ENTRYPOINT ["/app/lsget"]