File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
common-lib/securestore/rollback Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ FROM golang:1.24-alpine AS builder
2+
3+ # Install git for go mod dependencies
4+ RUN apk add --no-cache git
5+
6+ # Create non-root user for build
7+ RUN addgroup -g 1001 -S appgroup && \
8+ adduser -u 1001 -S appuser -G appgroup
9+
10+ # Set working directory
11+ WORKDIR /app
12+
13+ # Copy go mod files
14+ COPY go.mod go.sum ./
15+
16+ # Download dependencies
17+ RUN go mod download
18+
19+ # Copy source code
20+ COPY . .
21+
22+ # Build the application
23+ RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o rollback .
24+
25+ # Final stage
26+ FROM alpine:latest
27+
28+ # Install ca-certificates for HTTPS requests
29+ RUN apk --no-cache add ca-certificates
30+
31+ # Create non-root user
32+ RUN addgroup -g 1001 -S appgroup && \
33+ adduser -u 1001 -S appuser -G appgroup
34+
35+ # Set working directory
36+ WORKDIR /app
37+
38+ # Copy binary from builder stage
39+ COPY --from=builder /app/rollback .
40+
41+ # Change ownership to non-root user
42+ RUN chown -R appuser:appgroup /app
43+
44+ # Switch to non-root user
45+ USER appuser
46+
47+ # Expose any necessary ports (if needed)
48+ # EXPOSE 8080
49+
50+ # Set entrypoint
51+ ENTRYPOINT ["./rollback" ]
You can’t perform that action at this time.
0 commit comments