-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.extractor
More file actions
68 lines (54 loc) · 2.01 KB
/
Copy pathDockerfile.extractor
File metadata and controls
68 lines (54 loc) · 2.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Multi-stage Chainguard build for the TMI Extractor worker
#
# This image is run by the TMIComponent controller with a read-only root
# filesystem and an `egress: none` NetworkPolicy. The extractor worker only
# talks to NATS (cluster-internal) and performs no outbound network access.
#
# Stage 1: Build environment using Chainguard Go image
FROM cgr.dev/chainguard/go:latest AS builder
# Metadata for tracking
LABEL security.scan-date="AUTO_GENERATED"
LABEL security.patch-level="high-critical"
LABEL maintainer="TMI Security Team"
# Set working directory
WORKDIR /app
# Copy go mod files
COPY go.mod go.sum ./
# Download dependencies with security verification
RUN go mod download && \
go mod verify
# Copy source code
COPY . .
# Build the worker (CGO disabled for a static binary)
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags "-s -w" \
-trimpath \
-buildmode=exe \
-o tmi-extractor \
./cmd/extractor
# Stage 2: Chainguard static runtime (minimal attack surface)
FROM cgr.dev/chainguard/static:latest
# Metadata for tracking security patches
LABEL security.chainguard="true"
LABEL security.scan-date="AUTO_GENERATED"
LABEL security.patch-level="minimal-attack-surface"
LABEL maintainer="TMI Security Team"
LABEL org.opencontainers.image.title="TMI Extractor Worker"
LABEL org.opencontainers.image.description="TMI Extractor Worker on Chainguard static base"
LABEL org.opencontainers.image.name="tmi/tmi-extractor"
# Copy binary from builder
COPY --from=builder /app/tmi-extractor /tmi-extractor
# Set working directory
WORKDIR /
# Set secure environment variables
ENV ENV=development
ENV LOG_LEVEL=info
ENV GOLANG_PROTOBUF_REGISTRATION_CONFLICT=warn
# Note: Chainguard static doesn't include a shell.
# This worker has no HTTP port and needs no writable filesystem; the
# TMIComponent controller runs it with a read-only root filesystem and an
# `egress: none` NetworkPolicy.
# Run as non-root user (Chainguard static runs as nonroot by default)
USER nonroot:nonroot
# Run the worker
ENTRYPOINT ["/tmi-extractor"]