46 lines
1.2 KiB
Docker
46 lines
1.2 KiB
Docker
ARG RUST_VERSION=1.73.0
|
|
FROM rust:${RUST_VERSION}-slim-bullseye AS build
|
|
|
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
|
cargo install sqlx-cli --no-default-features --features rustls,sqlite && \
|
|
cp /usr/local/cargo/bin/sqlx /bin/sqlx
|
|
|
|
ENV DATABASE_URL=sqlite:/var/p4bl0t.db
|
|
|
|
WORKDIR /app
|
|
RUN --mount=type=bind,source=src,target=src \
|
|
--mount=type=bind,source=Cargo.toml,target=Cargo.toml \
|
|
--mount=type=bind,source=Cargo.lock,target=Cargo.lock \
|
|
--mount=type=bind,source=migrations,target=migrations \
|
|
--mount=type=cache,target=/app/target/ \
|
|
--mount=type=cache,target=/usr/local/cargo/registry \
|
|
<<EOF
|
|
set -e
|
|
sqlx database create
|
|
sqlx migrate run
|
|
cargo install --locked --path .
|
|
EOF
|
|
|
|
|
|
FROM debian:bullseye-slim AS final
|
|
|
|
RUN apt-get update && apt-get install -qqy ca-certificates
|
|
ARG UID=10001
|
|
RUN adduser \
|
|
--disabled-password \
|
|
--gecos "" \
|
|
--home "/nonexistent" \
|
|
--shell "/sbin/nologin" \
|
|
--no-create-home \
|
|
--uid "${UID}" \
|
|
appuser
|
|
USER appuser
|
|
|
|
ENV DATABASE_URL=sqlite:/var/p4bl0t.db
|
|
ENV DISCORD_TOKEN=changeme
|
|
|
|
COPY --from=build /usr/local/cargo/bin/p4bl0t /bin
|
|
COPY --chown=appuser --from=build /var/p4bl0t.db /var/p4bl0t.db
|
|
|
|
CMD [ "p4bl0t" ]
|