-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
30 lines (21 loc) · 795 Bytes
/
Dockerfile
File metadata and controls
30 lines (21 loc) · 795 Bytes
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
FROM golang:1.25-alpine AS builder
WORKDIR /app
# Copy go.mod and go.sum first to leverage Docker cache
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the application source code
COPY . .
# Build the ralph binary
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /ralph cmd/ralph/main.go
# --- Main image ---
FROM alpine:3.21
# Install shells and git for testing
RUN apk add --no-cache bash zsh fish git
# Copy the ralph binary from the builder stage
COPY --from=builder /ralph /usr/local/bin/ralph
# Set up a non-root user for tests to run as (good practice)
RUN addgroup -S testgroup && adduser -S testuser -G testgroup
USER testuser
WORKDIR /home/testuser
# Default entrypoint (can be overridden by docker run commands)
ENTRYPOINT ["/usr/local/bin/ralph"]