-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDockerfile.bitswap-monitoring-client
65 lines (54 loc) · 2.21 KB
/
Dockerfile.bitswap-monitoring-client
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
55
56
57
58
59
60
61
62
63
64
65
# Implements an image to run the bitswap-monitoring-client tool.
# This will expose port 8088 for prometheus.
# The executable is placed in /ipfs-tools, the config in /ipfs-tools/config/.
# The config is copied from the builder stage (and thus verbose from the sources).
# You can override it by mounting your own.
# First build su-exec
FROM ubuntu:jammy AS builder
RUN apt-get update && apt-get install -y \
curl \
build-essential \
git \
wget
# Get su-exec, a very minimal tool for dropping privileges.
ENV SUEXEC_VERSION=v0.2
RUN set -eux; \
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
"amd64" | "armhf" | "arm64") tiniArch="tini-static-$dpkgArch" ;;\
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
esac; \
cd /tmp \
&& git clone https://github.com/ncopa/su-exec.git \
&& cd su-exec \
&& git checkout -q $SUEXEC_VERSION \
&& make su-exec-static
# Get yq
ENV YQ_VERSION=v4.44.3
RUN set -eux; \
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
"amd64" | "arm" | "armhf" | "arm64") tiniArch="tini-static-$dpkgArch" ;;\
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
esac; \
wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${dpkgArch} -O /usr/bin/yq &&\
chmod +x /usr/bin/yq
# Get some small base image to run things on.
FROM ubuntu:jammy AS runtime
# Enter our working directory.
WORKDIR ipfs-tools
# Copy compiled binaries from builder.
COPY --from=ipfs-tools-builder /ipfs-tools/target/release/bitswap-monitoring-client .
COPY --from=ipfs-tools-builder /ipfs-tools/bitswap-monitoring-client/config.yaml ./config/bitswap-monitoring-client-config.yaml
COPY --from=ipfs-tools-builder /ipfs-tools/bitswap-monitoring-client/docker-entrypoint.sh .
COPY --from=0 /tmp/su-exec/su-exec-static /sbin/su-exec
COPY --from=0 /usr/bin/yq /usr/bin/yq
# Make sure our entrypoint is executable.
RUN chmod 755 ./docker-entrypoint.sh
# Set log level.
ENV RUST_LOG=info
# Expose Prometheus endpoint.
EXPOSE 8088
# Run the script.
# This will fix permissions on the temporary file storage directory, drop root, and then run the binary.
ENTRYPOINT ["./docker-entrypoint.sh"]