Skip to content

Commit 20b19c5

Browse files
committed
adding dockerfile for rollback job
1 parent fcdc16a commit 20b19c5

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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"]

0 commit comments

Comments
 (0)