Skip to content

Commit e62a3c5

Browse files
committed
Add frontend deps caching in Dockerfile (#11)
1 parent 1c877df commit e62a3c5

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

Dockerfile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@ RUN cargo install cargo-chef
33
RUN cargo install trunk
44
RUN rustup target add wasm32-unknown-unknown
55

6-
FROM base as planner
7-
WORKDIR /usr/src/sumi
8-
COPY . .
9-
RUN cargo chef prepare --recipe-path recipe.json
10-
116
FROM base as cacher
127
WORKDIR /usr/src/sumi
13-
COPY --from=planner /usr/src/sumi/recipe.json recipe.json
14-
RUN cargo chef cook --release --recipe-path recipe.json
8+
COPY ./Cargo.lock ./
9+
COPY ./Cargo.toml ./
10+
COPY ./frontend/Cargo.toml ./frontend/Cargo.toml
11+
COPY ./backend/Cargo.toml ./backend/Cargo.toml
12+
COPY ./frontend/.cargo ./frontend/.cargo
13+
RUN mkdir ./backend/src && mkdir ./frontend/src && echo 'fn main() { println!("Dummy"); }' > ./backend/src/main.rs && echo 'fn main() { println!("Dummy"); } ' > ./frontend/src/lib.rs
14+
RUN cargo build --release --manifest-path ./backend/Cargo.toml
15+
WORKDIR /usr/src/sumi/frontend
16+
RUN cargo build --release
1517

1618
FROM base as builder
1719
WORKDIR /usr/src/sumi
18-
COPY . .
1920
COPY --from=cacher /usr/src/sumi/target target
21+
COPY . .
2022
RUN trunk build -d dist ./frontend/index.html --release
2123
RUN cargo build --manifest-path ./backend/Cargo.toml --release
2224

frontend/.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build]
2+
target = "wasm32-unknown-unknown"

0 commit comments

Comments
 (0)