forked from stuartnelson3/passenger_exporter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
54 lines (40 loc) · 1.37 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
52
53
54
ARG GOLANG_VERSION="1.20.1"
ARG DEBIAN_VERSION="bullseye-20230227-slim"
ARG BUILDER_IMAGE="golang:${GOLANG_VERSION}"
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"
FROM ${BUILDER_IMAGE} AS builder
WORKDIR /opt/app
# Install build tools
RUN go install github.com/prometheus/[email protected]
# Add source files and build
ADD . ./
RUN make
FROM ${RUNNER_IMAGE}
RUN apt-get update -y && \
apt-get install -y \
bash \
ca-certificates \
gnupg && \
apt clean && \
rm -rf /var/lib/apt/lists/*
ARG APP_USER="exporter"
ENV APP_HOME="/opt/app"
WORKDIR ${APP_HOME}
# Create user
RUN groupadd -g 9999 ${APP_USER} && \
useradd --system --create-home -u 9999 -g 9999 ${APP_USER}
# Passenger
ARG PASSENGER_VERSION="6.0.17"
ARG PASSENGER_PKG="1:${PASSENGER_VERSION}-1~bullseye1"
RUN apt-key adv --no-tty --keyserver hkps://keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7 && \
echo 'deb https://oss-binaries.phusionpassenger.com/apt/passenger bullseye main' > /etc/apt/sources.list.d/passenger.list && \
apt-get update -y && \
apt-get install -y passenger=${PASSENGER_PKG} && \
passenger-config validate-install --auto && \
apt clean && \
rm -rf /var/lib/apt/lists/*
# Copy files from builder
COPY --from=builder --chown=${APP_USER}:${APP_USER} ${APP_HOME}/bin/ ./bin/
# Run as user
USER ${APP_USER}:${APP_USER}
ENTRYPOINT ["./bin/passenger-exporter"]