-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (33 loc) · 1.01 KB
/
Copy pathDockerfile
File metadata and controls
46 lines (33 loc) · 1.01 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
# Build stage
FROM golang:1.26.5-alpine AS builder
# Install git and ca-certificates
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 && go mod verify
# Copy source code
COPY . .
# Build the binary with optimizations
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags="-s -w -extldflags '-static'" \
-a -installsuffix cgo \
-o bucketsyncd .
# Final stage
FROM scratch
# Copy certificates and timezone data
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
# Copy the binary
COPY --from=builder /app/bucketsyncd /bucketsyncd
# Create non-root user
USER 65534:65534
# Expose port if needed (adjust based on your application)
# EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD ["/bucketsyncd", "-h"] || exit 1
# Run the binary
ENTRYPOINT ["/bucketsyncd"]