-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (35 loc) · 1.4 KB
/
Dockerfile
File metadata and controls
44 lines (35 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
############################
# Multi-stage build for StackScout
# 1. Builder: compile static Go binary
# 2. Runner: minimal image with CA certificates
############################
# syntax=docker/dockerfile:1.7
ARG GO_VERSION=1.24.9
ARG ALPINE_VERSION=3.22
############################
# Builder Stage
############################
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder
WORKDIR /src
RUN apk add --no-cache git ca-certificates build-base
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
COPY . .
# Set environment for static build (CGO disabled)
ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -trimpath -ldflags "-s -w" -o /out/stackscout ./cmd/stackscout
############################
# Runtime Stage
############################
FROM gcr.io/distroless/static AS runtime
LABEL org.opencontainers.image.source="https://github.com/ItsEcholot/StackScout" \
org.opencontainers.image.title="StackScout" \
org.opencontainers.image.description="StackScout monitors your containerized services for available image updates and reports metrics to InfluxDB." \
org.opencontainers.image.licenses="MIT"
WORKDIR /app
COPY --from=builder /out/stackscout /app/stackscout
# Expose no ports (service pushes metrics externally)
ENTRYPOINT ["/app/stackscout"]