tautulli-exporter/Dockerfile

46 lines
1.2 KiB
Docker
Raw Normal View History

2024-01-21 17:43:29 +00:00
FROM rust:1.75-alpine as builder
2024-01-21 15:19:30 +00:00
# update packages
RUN apk update
RUN apk add build-base ca-certificates libressl-dev
# Install rust toolchains
#RUN rustup toolchain install stable
#RUN rustup default stable
2024-01-21 15:19:30 +00:00
2024-01-21 16:06:26 +00:00
# create root application folder
WORKDIR /app
COPY ./ /app/src
2024-01-21 15:19:30 +00:00
WORKDIR /app/src
# Build dependencies only. Separate these for caches
#RUN cargo install cargo-build-deps
#RUN sh -c "cargo build-deps --release"
2024-01-21 15:19:30 +00:00
# Build the release executable.
RUN sh -c "cargo build --release"
# Runner stage. I tried using distroless (gcr.io/distroless/static-debian11), but the image was only ~3MBs smaller than
# alpine. I chose to use alpine since it makes it easier to exec into the container to debug things.
FROM alpine:latest
2024-01-21 15:19:30 +00:00
ARG UNAME=exporter
ARG UID=1000
ARG GID=1000
# Add user and copy the executable from the build stage.
RUN adduser --disabled-password --gecos "" $UNAME -s -G $GID -u $UID
COPY --from=builder --chown=$UID:$GID /app/src/target/release/tautulli-exporter /app/tautulli-exporter
# Chown everything
RUN mkdir /data && \
chown -R $UID:$GID /data && \
chown -R $UID:$GID /app
USER $UNAME
WORKDIR /app/
EXPOSE 3000
ENTRYPOINT [ "/app/tautulli-exporter", "--config", "/app/config.toml" ]