admin-worker/Dockerfile

44 lines
1.6 KiB
Docker
Raw Permalink Normal View History

2023-11-23 09:36:10 +00:00
FROM rust:latest as build
# 1. Create a new empty shell project
RUN USER=root cargo new --bin nerdcult_admin_worker
WORKDIR /nerdcult_admin_worker
# 2. Copy our manifests
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
# 3. Build only the dependencies to cache them
RUN cargo build --release
RUN rm src/*.rs
# 4. Now that the dependency is built, copy your source code
COPY ./src ./src
COPY .sqlx .sqlx
# 5. Build for release.
RUN rm ./target/release/deps/admin_worker*
RUN SQLX_OFFLINE=true NC_AW_BACKUP_PATH=/data/backup NC_AW_HOST_PATH=/host cargo build --release
FROM debian:bookworm-slim
# Install Docker CE CLI
RUN apt-get update \
&& apt-get install -y apt-transport-https ca-certificates curl gnupg2 lsb-release \
&& curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | apt-key add - 2>/dev/null \
&& echo "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list \
&& apt-get update \
&& apt-get install -y docker-ce-cli
# Install Docker Compose
RUN LATEST_COMPOSE_VERSION=$(curl -sSL "https://api.github.com/repos/docker/compose/releases/latest" | grep -o -P '(?<="tag_name": ").+(?=")') \
&& curl -sSL "https://github.com/docker/compose/releases/download/${LATEST_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose \
&& chmod +x /usr/local/bin/docker-compose
2023-11-23 09:36:10 +00:00
COPY --from=build /nerdcult_admin_worker/target/release/admin-worker /bin/admin-worker
EXPOSE 6969
CMD ["/bin/admin-worker"]