prometheus-mastodon-exporter/Dockerfile

31 lines
622 B
Docker
Raw Normal View History

2023-12-18 00:50:28 +01:00
# syntax=docker/dockerfile:1
2022-11-04 21:02:52 +01:00
2023-12-18 00:50:28 +01:00
# Build the application from source
FROM golang:1.21.4 AS build-stage
2022-11-04 21:02:52 +01:00
2023-12-18 00:50:28 +01:00
WORKDIR /app
2022-11-04 21:02:52 +01:00
2023-12-18 00:50:28 +01:00
COPY go.mod go.sum ./
RUN go mod download
2022-11-04 21:02:52 +01:00
2023-12-18 00:50:28 +01:00
COPY *.go ./
2022-11-04 21:02:52 +01:00
2023-12-18 00:50:28 +01:00
RUN CGO_ENABLED=0 GOOS=linux go build -o /prometheus-mastodon-exporter
2022-11-04 21:02:52 +01:00
2023-12-18 00:50:28 +01:00
# Run the tests in the container
FROM build-stage AS run-test-stage
RUN go test -v ./...
2022-11-04 21:02:52 +01:00
2023-12-18 00:50:28 +01:00
# Deploy the application binary into a lean image
FROM gcr.io/distroless/base-debian11 AS build-release-stage
WORKDIR /
COPY --from=build-stage /prometheus-mastodon-exporter /prometheus-mastodon-exporter
2022-11-04 21:02:52 +01:00
EXPOSE 13120
2023-12-18 00:50:28 +01:00
USER nonroot:nonroot
2022-11-04 21:10:15 +01:00
ENTRYPOINT ["/prometheus-mastodon-exporter"]