-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (32 loc) · 1.09 KB
/
Dockerfile
File metadata and controls
45 lines (32 loc) · 1.09 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
# Build stage
FROM registry.access.redhat.com/ubi9/go-toolset:1.24 AS builder
# Switch to root to set up workspace
USER root
WORKDIR /build
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o rosactl ./cmd/rosactl
# Runtime stage - UBI minimal for smaller image size
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
# Install AWS Lambda Runtime Interface Emulator (for local testing)
# and ca-certificates for TLS connections
RUN microdnf install -y ca-certificates tar gzip && microdnf clean all
# Copy the Go binary
COPY --from=builder /build/rosactl /usr/local/bin/rosactl
# Create non-root user
RUN useradd -u 1001 -r -g 0 -m -d /app -s /sbin/nologin \
-c "Lambda user" lambda
# Set ownership
RUN chown -R 1001:0 /app && chmod -R g=u /app
# Switch to non-root user
USER 1001
# Set working directory
WORKDIR /app
# Lambda handler entrypoint
# When Lambda invokes the container, it will call this command
ENTRYPOINT ["/usr/local/bin/rosactl"]
CMD ["handler"]