Repository navigation
Expand file tree
/
Copy pathContainerfile
More file actions
62 lines (44 loc) · 1.53 KB
/
Copy pathContainerfile
File metadata and controls
62 lines (44 loc) · 1.53 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
53
54
55
56
57
58
59
60
61
62
# Build stage
FROM golang:1.25-alpine AS builder
# Install git and ca-certificates
RUN apk add --no-cache git ca-certificates
# Set working directory
WORKDIR /app
# Copy go mod files first for better caching
COPY sync/go.mod sync/go.sum ./
# Download dependencies
RUN go mod download
# Copy source code
COPY sync/ .
# Copy email templates from backend (single source of truth)
RUN mkdir -p internal/sync/templates
COPY backend/services/email/templates/ internal/sync/templates/
# Build the CLI application with version information
ARG VERSION=dev
ARG COMMIT=unknown
ARG BUILD_TIME=unknown
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo \
-ldflags "-X github.com/nethesis/my/sync/pkg/version.Version=${VERSION} \
-X github.com/nethesis/my/sync/pkg/version.Commit=${COMMIT} \
-X github.com/nethesis/my/sync/pkg/version.BuildTime=${BUILD_TIME}" \
-o sync ./cmd/sync/main.go
# Final stage
FROM alpine:3.24
# Install ca-certificates for HTTPS requests to Logto API
RUN apk --no-cache add ca-certificates
# Create non-root user
RUN addgroup -g 1001 -S appgroup && \
adduser -u 1001 -S appuser -G appgroup
# Create directory for configs
RUN mkdir -p /app/configs && chown appuser:appgroup /app/configs
WORKDIR /app
# Copy the binary from builder stage
COPY --from=builder /app/sync .
# Copy configuration files
COPY --from=builder /app/configs/ ./configs/
# Change ownership
RUN chown -R appuser:appgroup /app
# Switch to non-root user
USER appuser
# Default command shows help
CMD ["./sync", "--help"]