Files
go-weatherstation/Dockerfile
2026-01-27 16:51:58 +11:00

37 lines
798 B
Docker

# ---- build stage ----
FROM golang:1.25-alpine AS build
WORKDIR /src
# Git CA certs (for go modules / HTTPS)
RUN apk add --no-cache ca-certificates
# Copy mod files first for better caching
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the source
COPY . .
# Build a static-ish binary (alpine musl)
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -trimpath -ldflags="-s -w" -o /out/ingestd ./cmd/ingestd
# ---- runtime stage ----
FROM alpine:3.22
WORKDIR /app
RUN apk add --no-cache ca-certificates && \
adduser -D -H -u 10001 appuser
# Copy binary + schema file used at startup
COPY --from=build /out/ingestd /app/ingestd
USER appuser
# Web UI
EXPOSE 8080
# default config path inside container
ENTRYPOINT ["/app/ingestd"]
CMD ["-config", "/app/config.yaml"]