mirror of
https://github.com/nitnelave/lldap.git
synced 2023-04-12 14:25:13 +00:00
docker: add cargo chef to the dockerfile to cache dependencies
This commit is contained in:
parent
dfe1607a3e
commit
9e3315e09f
24
Dockerfile
24
Dockerfile
@ -1,5 +1,5 @@
|
|||||||
# Build image
|
# Build image
|
||||||
FROM rust:alpine AS builder
|
FROM rust:alpine AS chef
|
||||||
|
|
||||||
RUN set -x \
|
RUN set -x \
|
||||||
# Add user
|
# Add user
|
||||||
@ -17,15 +17,27 @@ USER app
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN set -x \
|
RUN set -x \
|
||||||
# Install build tools
|
# Install build tools
|
||||||
&& RUSTFLAGS=-Ctarget-feature=-crt-static cargo install wasm-pack \
|
&& RUSTFLAGS=-Ctarget-feature=-crt-static cargo install wasm-pack cargo-chef \
|
||||||
&& npm install rollup
|
&& npm install rollup \
|
||||||
# Build
|
&& rustup target add wasm32-unknown-unknown
|
||||||
COPY --chown=app:app . /app
|
|
||||||
|
# Prepare the dependency list.
|
||||||
|
FROM chef AS planner
|
||||||
|
COPY . .
|
||||||
|
RUN cargo chef prepare --recipe-path recipe.json
|
||||||
|
|
||||||
|
# Build dependencies
|
||||||
|
FROM chef AS builder
|
||||||
|
COPY --from=planner /app/recipe.json recipe.json
|
||||||
|
RUN cargo chef cook --release -p lldap --recipe-path recipe.json \
|
||||||
|
&& cargo chef cook --release -p lldap_app --target wasm32-unknown-unknown
|
||||||
|
|
||||||
|
# Copy the source and build the app.
|
||||||
|
COPY --chown=app:app . .
|
||||||
RUN cargo build --release -p lldap
|
RUN cargo build --release -p lldap
|
||||||
# TODO: release mode.
|
# TODO: release mode.
|
||||||
RUN ./app/build.sh
|
RUN ./app/build.sh
|
||||||
|
|
||||||
|
|
||||||
# Final image
|
# Final image
|
||||||
FROM alpine
|
FROM alpine
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user