feat: Enable Docker deployment and CD
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 8m1s
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 8m1s
Closes #8, partially addresses #6
This commit is contained in:
46
Dockerfile
Normal file
46
Dockerfile
Normal file
@@ -0,0 +1,46 @@
|
||||
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 build --locked --release
|
||||
cargo install --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" ]
|
||||
Reference in New Issue
Block a user