Skip to content

Commit e871d6d

Browse files
committed
update dockerfile to support kafka
1 parent 89a781a commit e871d6d

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

Dockerfile

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
FROM golang:1.21-alpine AS builder
1+
FROM golang:1.23 AS builder
22

33
WORKDIR /app
44

5-
# Install build dependencies
6-
RUN apk add --no-cache gcc musl-dev
5+
# Install build dependencies including librdkafka
6+
RUN apt-get update && apt-get install -y \
7+
gcc \
8+
librdkafka-dev \
9+
pkg-config \
10+
&& rm -rf /var/lib/apt/lists/*
711

812
# Copy go mod files
913
COPY go.mod go.sum ./
@@ -12,20 +16,25 @@ RUN go mod download
1216
# Copy source code
1317
COPY . .
1418

15-
# Build the application
16-
RUN CGO_ENABLED=0 GOOS=linux go build -o main .
19+
# Build the application with CGO enabled
20+
RUN CGO_ENABLED=1 GOOS=linux go build -o main .
1721

1822
# Final stage
19-
FROM alpine:latest
23+
FROM debian:bookworm-slim
2024

2125
WORKDIR /app
2226

27+
# Install runtime dependency
28+
RUN apt-get update && apt-get install -y \
29+
librdkafka1 \
30+
&& rm -rf /var/lib/apt/lists/*
31+
2332
# Copy the binary from builder
2433
COPY --from=builder /app/main .
2534
COPY views/ views/
2635

2736
# Run as non-root user
28-
RUN adduser -D appuser
37+
RUN useradd -r appuser
2938
USER appuser
3039

3140
EXPOSE 3000

docker-compose.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,16 @@ services:
1717
- ./secrets/tesla-ssl/tls.crt:/secrets/tesla-ssl/tls.crt:ro
1818
- ./secrets/tesla-ssl/tls.key:/secrets/tesla-ssl/tls.key:ro
1919
- ./secrets/fleet-api/private-key.pem:/secret/private-key.pem:ro
20-
# fleet-telemetry-consumer:
21-
# build:
22-
# context: .
23-
# dockerfile: Dockerfile
24-
# ports:
25-
# - "3000:3000"
26-
# depends_on:
27-
# - tesla-http-proxy
20+
fleet-telemetry-consumer:
21+
build:
22+
context: .
23+
dockerfile: Dockerfile
24+
ports:
25+
- "3000:3000"
26+
depends_on:
27+
- tesla-http-proxy
28+
volumes:
29+
- ./secrets/fleet-telemetry-ssl/:/app/secrets/fleet-telemetry-ssl:ro
30+
- ./secrets/pg/:/app/secrets/pg:ro
31+
- ./secrets/fleet-api/:/app/secrets/fleet-api:ro
32+
- ./secrets/tesla-ssl/:/app/secrets/tesla-ssl:ro

0 commit comments

Comments
 (0)