Files
crowdsec-dashy/Dockerfile
T

44 lines
1.2 KiB
Docker
Raw Normal View History

2026-05-17 04:54:34 +00:00
# -----------------------------------------------------------------------
# Stage 1: Build
# -----------------------------------------------------------------------
2026-05-17 08:28:16 +00:00
FROM golang:1.26-alpine AS builder
2026-05-17 04:54:34 +00:00
WORKDIR /build
# Copy module files first for layer caching
COPY go.mod ./
RUN go mod download
# Copy source
COPY . .
# Build a static binary (no CGO, no external dependencies)
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags="-s -w" -o crowdsec-dashy ./cmd/server
# -----------------------------------------------------------------------
# Stage 2: Minimal runtime image
# -----------------------------------------------------------------------
FROM alpine:3.19
# Install ca-certificates for HTTPS LAPI connections
RUN apk --no-cache add ca-certificates tzdata
WORKDIR /app
2026-05-17 08:28:16 +00:00
# Copy binary (web assets embedded at build time)
2026-05-17 04:54:34 +00:00
COPY --from=builder /build/crowdsec-dashy .
# Non-root user for security
2026-05-17 08:28:16 +00:00
RUN addgroup -S csui && adduser -S csui -G csui && \
mkdir -p /app/config && chown csui:csui /app/config
2026-05-17 04:54:34 +00:00
USER csui
EXPOSE 8080
2026-05-17 08:28:16 +00:00
# All settings live in app_config.conf (auto-generated on first run).
# CONFIG_FILE tells the app where to look — set in docker-compose.yml.
ENV CONFIG_FILE=/app/config/app_config.conf
2026-05-17 04:54:34 +00:00
ENTRYPOINT ["/app/crowdsec-dashy"]