From 44793eb8d49abb7c9f1c3cfe824aa32cbb648905 Mon Sep 17 00:00:00 2001 From: Philippe Loctaux
Date: Mon, 27 Feb 2023 16:48:42 +0100 Subject: [PATCH] docker --- .dockerignore | 13 +++++++++++++ Dockerfile | 30 ++++++++++++++++++++++++++++++ justfile | 16 ++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100755 justfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..75d9e5c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +# Docker +Dockerfile +.dockerignore + +# ide and os +.idea/ +.DS_Store + +# database +/database/ + +# rust +target/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9f68c02 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +LABEL maintainer="Philippe Loctaux
" + +FROM clux/muslrust:1.67.0-stable as chef +USER root +RUN cargo install cargo-chef +WORKDIR /ezidam + +FROM chef AS planner +COPY Cargo.toml . +COPY Cargo.lock . +COPY crates crates +RUN cargo chef prepare --recipe-path recipe.json + +FROM chef AS builder +COPY --from=planner /ezidam/recipe.json recipe.json +RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json +COPY --from=planner /ezidam/Cargo.toml . +COPY --from=planner /ezidam/Cargo.lock . +COPY --from=planner /ezidam/crates crates +COPY logo logo +RUN cargo build --release --target x86_64-unknown-linux-musl --package ezidam --bin ezidam + +FROM scratch +COPY --from=builder /ezidam/target/x86_64-unknown-linux-musl/release/ezidam /ezidam +ENV ROCKET_CLI_COLORS=0 +ENV ROCKET_ADDRESS=0.0.0.0 +ENV ROCKET_PORT=8000 +ENV ROCKET_DATABASES='{ezidam={url="/database/ezidam.sqlite"}}' +EXPOSE 8000 +ENTRYPOINT ["/ezidam"] diff --git a/justfile b/justfile new file mode 100755 index 0000000..319d110 --- /dev/null +++ b/justfile @@ -0,0 +1,16 @@ +#!/usr/bin/env just --justfile + +database_path := "/tmp/ezidam/docker" + +# list recipes +default: + just --list + +docker_build: + docker build --progress=plain --platform linux/amd64 -t ezidam . + +docker_run: + mkdir -p {{database_path}} + docker run --rm -p 8000:8000 -v {{database_path}}:/database --platform linux/amd64 ezidam + +docker_all: docker_build docker_run