-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
51 lines (38 loc) · 1.22 KB
/
Dockerfile
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
45
46
47
48
49
50
51
# Copyright (c) VirtualTam
# SPDX-License-Identifier: MIT
# Step 1: Build Go binaries
FROM golang:1.23-bookworm AS builder
ARG CGO_ENABLED=1
WORKDIR /app
COPY go.mod go.sum ./
RUN --mount=type=cache,sharing=locked,target=/go/pkg/mod go mod download
ADD . .
RUN make common-build
# Step 2: build the actual image
FROM debian:bookworm-slim
RUN --mount=type=cache,sharing=locked,target=/var/lib/apt/lists \
--mount=type=cache,sharing=locked,target=/var/cache/apt \
rm -f /etc/apt/apt.conf.d/docker-clean \
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache \
&& apt-get update \
&& apt-get install -y ccache
RUN groupadd \
--gid 1000 \
exporter \
&& useradd \
--create-home \
--home-dir /var/lib/exporter \
--shell /bin/bash \
--uid 1000 \
--gid exporter \
exporter
COPY --from=builder /app/build/ccache_exporter /usr/local/bin/ccache_exporter
USER exporter
WORKDIR /var/lib/exporter
ENV \
CCACHE_EXPORTER_LISTEN_ADDR="0.0.0.0:9508" \
CCACHE_EXPORTER_LOG_FORMAT="json" \
CCACHE_EXPORTER_LOG_LEVEL="info"
EXPOSE 9508
VOLUME /var/lib/exporter/.ccache
CMD ["/usr/local/bin/ccache_exporter", "run"]