From 92a3ba527f4ebeb4d01ce99cb115c51dbf61f0de Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sat, 29 Oct 2022 12:20:16 +0200 Subject: [PATCH] ci: use cargo check to cache dockerfile #828 --- Dockerfile | 79 +++++++++++++++++------------------------------------- 1 file changed, 24 insertions(+), 55 deletions(-) diff --git a/Dockerfile b/Dockerfile index 69a838932e..a370605c7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,23 @@ RUN git clone -b master --single-branch https://github.com/google/nsjail.git . \ && git checkout dccf911fd2659e7b08ce9507c25b2b38ec2c5800 RUN make +FROM rust:slim-buster AS rust_base + +RUN apt-get update && apt-get install -y git libssl-dev pkg-config npm + +RUN apt-get -y update \ + && apt-get install -y \ + curl lld nodejs npm + +RUN rustup component add rustfmt + +RUN cargo install cargo-chef + +WORKDIR /windmill + +ENV SQLX_OFFLINE=true +ENV CARGO_INCREMENTAL=1 + FROM node:19-alpine as frontend # install dependencies @@ -36,69 +53,21 @@ ENV NODE_OPTIONS "--max-old-space-size=8192" RUN npm run build RUN npm run check -FROM rust:slim-buster as builder -RUN apt-get update && apt-get install -y git libssl-dev pkg-config npm - -RUN apt-get -y update \ - && apt-get install -y \ - curl lld nodejs npm - -RUN rustup component add rustfmt - -RUN USER=root cargo new --bin windmill -WORKDIR /windmill +FROM rust_base AS planner COPY ./openflow.openapi.yaml /openflow.openapi.yaml +COPY ./backend ./ -RUN USER=root cargo new --bin windmill -RUN USER=root cargo new --lib windmill-api -RUN USER=root cargo new --lib windmill-audit -RUN USER=root cargo new --lib windmill-queue -RUN USER=root cargo new --lib windmill-worker -WORKDIR /windmill/parsers -RUN USER=root cargo new --lib windmill-parser -RUN USER=root cargo new --lib windmill-parser-go -RUN USER=root cargo new --lib windmill-parser-py -RUN USER=root cargo new --lib windmill-parser-ts -WORKDIR /windmill +RUN cargo chef prepare --recipe-path recipe.json -ENV SQLX_OFFLINE=true +FROM rust_base AS builder -# COPY ./backend/Cargo.toml . -# COPY ./backend/windmill-api/Cargo.toml ./windmill-api/ -# COPY ./backend/windmill-audit/Cargo.toml ./windmill-audit/ -# COPY ./backend/sqlx-data.json ./ -# COPY ./backend/windmill-common ./windmill-common -# COPY ./backend/windmill-queue/Cargo.toml ./windmill-common/ -# COPY ./backend/windmill-queue/Cargo.toml ./windmill-queue/ -# COPY ./backend/windmill-worker/Cargo.toml ./windmill-worker/ -# COPY ./backend/parsers/windmill-parser/Cargo.toml ./parsers/windmill-parser/ -# COPY ./backend/parsers/windmill-parser-go/Cargo.toml ./parsers/windmill-parser-go/ -# COPY ./backend/parsers/windmill-parser-py/Cargo.toml ./parsers/windmill-parser-py/ -# COPY ./backend/parsers/windmill-parser-ts/Cargo.toml ./parsers/windmill-parser-ts/ -# COPY ./backend/.cargo/ .cargo/ +COPY --from=planner /windmill/recipe.json recipe.json -# COPY ./backend/windmill-api-client/ ./windmill-api-client/ -# COPY ./backend/windmill-api/openapi.yaml ./windmill-api/openapi.yaml - -ENV CARGO_INCREMENTAL=1 - -# RUN cargo build --release -# RUN rm ./src/*.rs -# RUN rm ./windmill-api/src/*.rs -# RUN rm ./windmill-api-client/src/*.rs -# RUN rm ./windmill-audit/src/*.rs -# RUN rm ./windmill-common/src/*.rs -# RUN rm ./windmill-queue/src/*.rs -# RUN rm ./windmill-worker/src/*.rs -# RUN rm ./parsers/windmill-parser/src/*.rs -# RUN rm ./parsers/windmill-parser-go/src/*.rs -# RUN rm ./parsers/windmill-parser-py/src/*.rs -# RUN rm ./parsers/windmill-parser-ts/src/*.rs - -# RUN rm -r ./target/release/deps/windmill* +RUN cargo chef cook --release --recipe-path recipe.json +COPY ./openflow.openapi.yaml /openflow.openapi.yaml COPY ./backend ./ COPY --from=frontend /frontend /frontend