From a621fdc86d548c45680b9d3a5e61a13984d9de70 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Sat, 13 Aug 2022 22:50:47 +0530 Subject: [PATCH] feat: pkg docker --- .dockerignore | 15 +++++++++++++++ Cargo.toml | 3 +-- Dockerfile | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e2422fc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,15 @@ +/target +tarpaulin-report.html +.env +cobertura.xml +prod/ +node_modules/ +/static-assets/bundle +./templates/**/*.js +/static/cache/bundle/* +src/cache_buster_data.json + +browser/target +browser/cobertura.xml +browser/docs +tmp/ diff --git a/Cargo.toml b/Cargo.toml index 2afc40d..1f758f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,8 +23,7 @@ sanitize-filename = "0.4" serde = { version = "1", features=["derive"]} tokio = { version = "1.20.1", features = ["fs"]} uuid = { version = "1", features = ["v4"] } -sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "postgres", "time", "offline, ] } - +sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "postgres", "time", "offline" ] } [build-dependencies] diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3c6d14b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,48 @@ +#FROM node:16.0.0 as frontend +#RUN set -ex; \ +# apt-get update; \ +# DEBIAN_FRONTEND=noninteractive \ +# apt-get install -y --no-install-recommends make +#RUN mkdir -p /src/docs/openapi/ +#COPY package.json yarn.lock /src/ +#COPY docs/openapi/package.json docs/openapi/yarn.lock /src/docs/openapi/ +#WORKDIR /src +#RUN yarn install && cd docs/openapi && yarn install +#WORKDIR /src +#RUN mkdir -p /src/static/cache/bundle +#COPY tsconfig.json webpack.config.js jest.config.ts /src/ +#COPY templates /src/templates/ +#COPY docs/openapi /src/docs/openapi/ +#COPY Makefile /src/ +#COPY scripts /src/scripts +#RUN make frontend + +FROM rust:latest as planner +RUN cargo install cargo-chef +WORKDIR /src +COPY . /src/ +RUN cargo chef prepare --recipe-path recipe.json + +FROM rust:latest as cacher +WORKDIR /src/ +RUN cargo install cargo-chef +COPY --from=planner /src/recipe.json recipe.json +RUN cargo chef cook --release --recipe-path recipe.json + +FROM rust:latest as rust +WORKDIR /src +COPY . . +COPY --from=cacher /src/target target +#COPY --from=frontend /src/static/cache/bundle/ /src/static/cache/bundle/ +RUN cargo --version +#RUN make cache-bust +RUN cargo build --release + +FROM debian:bullseye as dumbserve +LABEL org.opencontainers.image.source https://github.com/realaravinth/dumbserve +RUN useradd -ms /bin/bash -u 1001 dumbserve +WORKDIR /home/dumbserve +COPY --from=rust /src/target/release/dumbserve /usr/local/bin/ +#COPY --from=rust /src/config/default.toml /etc/dumbserve/config.toml +USER dumbserve +CMD [ "/usr/local/bin/dumbserve" ]