bot-mastodon-image-uploader/Dockerfile

42 lines
845 B
Docker

# syntax=docker/dockerfile:1
FROM rust:1.83.0-slim-bullseye AS deps
RUN apt update && apt install pkg-config openssl libssl-dev -y
WORKDIR /app
COPY src src
COPY Cargo.toml Cargo.toml
COPY Cargo.lock Cargo.lock
FROM deps AS test
COPY .cargo .cargo
COPY config.toml config.toml
COPY mastodon-data.toml mastodon-data.toml
RUN cargo build
FROM deps AS build
ARG APP_NAME=mastodon-image-uploader-bot
WORKDIR /app
RUN <<EOF
set -e
cargo build --locked --release
ls ./target/release/$APP_NAME
cp ./target/release/$APP_NAME /bin/bot
EOF
FROM debian:bullseye-slim AS final
WORKDIR /app
RUN apt update && apt install pkg-config openssl libssl-dev -y
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--shell "/sbin/nologin" \
--uid "${UID}" \
botuser
USER botuser
COPY --from=build /bin/bot /bin/
CMD ["/bin/bot"]