nats-ui/Dockerfile
admin d3b60c5a45
All checks were successful
CI/CD / Lint & Test (push) Successful in 1m0s
CI/CD / Build & Push Docker image (hub.p42.ru) (push) Successful in 2m48s
Update architecture
2026-02-09 13:36:34 +07:00

38 lines
764 B
Docker

# Build stage
FROM golang:1.21-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY main.go index.html favicon.ico ./
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o nats-ui main.go
# Runtime stage
FROM alpine:3.19
RUN apk --no-cache add ca-certificates tzdata && \
adduser -D -u 1000 -h /app appuser
WORKDIR /app
COPY --from=builder /app/nats-ui ./
# config.yaml is in .gitignore; create default in image (override via volume at runtime)
RUN printf '%s\n' \
'nats_url: "nats://localhost:4222"' \
'subjects: ">"' \
'port: "8080"' \
'max_messages: 1000' \
> config.yaml
RUN chmod +x nats-ui && chown -R appuser:appuser /app
EXPOSE 8080
USER appuser
ENTRYPOINT ["./nats-ui"]
CMD ["config.yaml"]