Dockerfile 641 B

123456789101112131415161718192021222324252627282930313233343536
  1. FROM golang:1.22-alpine AS builder
  2. WORKDIR /app
  3. # Install deps
  4. RUN apk add --no-cache git
  5. # Copy Go modules
  6. COPY go.mod go.sum ./
  7. RUN go mod download
  8. # Copy source
  9. COPY . .
  10. # Build
  11. RUN CGO_ENABLED=0 GOOS=linux go build -o /client2server-server .
  12. # === Production ===
  13. FROM alpine:3.19
  14. WORKDIR /app
  15. # Install CA certs for HTTPS
  16. RUN apk add --no-cache ca-certificates tzdata
  17. # Copy binary
  18. COPY --from=builder /client2server-server .
  19. # Single port serves both WebSocket and HTTP API (Caddy fronts everything)
  20. EXPOSE 3843
  21. ENV TOKEN=change_me_in_production
  22. ENV REDPANDA_BROKERS=redpanda:9092
  23. ENV PORT=3843
  24. CMD ["/client2server-server"]