-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (44 loc) · 1.62 KB
/
Dockerfile
File metadata and controls
59 lines (44 loc) · 1.62 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
# Multi-stage Dockerfile for SAI CLI
# Build stage
FROM golang:1.21-alpine AS builder
# Install build dependencies
RUN apk add --no-cache git ca-certificates tzdata
# Set working directory
WORKDIR /app
# Copy go mod files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy source code
COPY . .
# Build the binary
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags="-s -w -X main.version=$(git describe --tags --always --dirty 2>/dev/null || echo 'dev') -X main.buildTime=$(date -u '+%Y-%m-%d_%H:%M:%S') -X main.commit=$(git rev-parse --short HEAD 2>/dev/null || echo 'unknown')" \
-a -installsuffix cgo \
-o sai \
./cmd/sai
# Final stage
FROM scratch
# Import from builder
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
# Copy the binary
COPY --from=builder /app/sai /usr/local/bin/sai
# Copy configuration files
COPY --from=builder /app/providers /usr/share/sai/providers
COPY --from=builder /app/schemas /usr/share/sai/schemas
# Create non-root user
USER nobody:nobody
# Set entrypoint
ENTRYPOINT ["/usr/local/bin/sai"]
# Default command
CMD ["--help"]
# Labels
LABEL org.opencontainers.image.title="SAI CLI"
LABEL org.opencontainers.image.description="Universal software management CLI tool"
LABEL org.opencontainers.image.url="https://github.com/example42/sai"
LABEL org.opencontainers.image.source="https://github.com/example42/sai"
LABEL org.opencontainers.image.vendor="SAI CLI Team"
LABEL org.opencontainers.image.licenses="MIT"