-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.dev
More file actions
47 lines (36 loc) · 1.24 KB
/
Dockerfile.dev
File metadata and controls
47 lines (36 loc) · 1.24 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
# audit-worker - Development Dockerfile for Tilt Live Update
# Uses Debian bookworm for CGO support (required by confluent-kafka-go/librdkafka)
FROM golang:1.26.2-bookworm AS builder
# Install build dependencies for CGO (librdkafka)
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
tzdata \
bash \
librdkafka-dev \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user for security
RUN useradd -u 65532 -s /bin/false nonroot
# Set working directory
WORKDIR /app
# Copy go mod files first for better caching
COPY go.mod go.sum* ./
RUN go mod download && go mod verify
# Copy source code
COPY . .
# Build binary with CGO enabled for Kafka support
ARG VERSION=dev
ARG COMMIT=unknown
ARG BUILD_DATE=unknown
# TARGETARCH is automatically set by Docker Buildx based on --platform flag
# No default - let the build system determine the correct architecture
ARG TARGETARCH
RUN CGO_ENABLED=1 GOOS=linux GOARCH=${TARGETARCH} go build \
-ldflags="-X main.Version=${VERSION} -X main.Commit=${COMMIT} -X main.BuildDate=${BUILD_DATE}" \
-o audit-worker \
./services/audit-worker/cmd
# Switch to non-root user
USER nonroot:nonroot
# Expose port
EXPOSE 8080
# Run the binary
ENTRYPOINT ["/app/audit-worker"]