mirror of
https://git.verdigado.com/NB-Public/simple-wkd.git
synced 2024-12-06 14:52:41 +01:00
Improve docker build speed
This commit is contained in:
parent
ed6ade53d8
commit
692b5e6cd1
3 changed files with 54 additions and 15 deletions
11
Dockerfile
11
Dockerfile
|
@ -2,26 +2,29 @@ ARG base="alpine:3.17"
|
|||
|
||||
FROM ${base} AS bin-builder
|
||||
|
||||
# Disable static linking, see: https://users.rust-lang.org/t/sigsegv-with-program-linked-against-openssl-in-an-alpine-container/52172
|
||||
# Enable cargo sparse index for faster update times, see: https://blog.rust-lang.org/inside-rust/2023/01/30/cargo-sparse-protocol.html
|
||||
ENV RUSTFLAGS='-C target-feature=-crt-static' \
|
||||
CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
|
||||
RUN apk add --no-cache cargo openssl-dev musl-dev
|
||||
# This will build all dependencies and store them in docker's cache.
|
||||
# This way, it won't be necessary to recompile everything everytime
|
||||
# It also disables static linking, see: https://users.rust-lang.org/t/sigsegv-with-program-linked-against-openssl-in-an-alpine-container/52172
|
||||
COPY backend/Cargo.toml .
|
||||
COPY backend/Cargo.lock .
|
||||
RUN echo '[[bin]]' >> Cargo.toml && \
|
||||
echo 'name = "cache"' >> Cargo.toml && \
|
||||
echo 'path = "cache.rs"' >> Cargo.toml && \
|
||||
echo 'fn main() {eprintln!("Caching crates...")}' > cache.rs && \
|
||||
RUSTFLAGS='-C target-feature=-crt-static' cargo build --release
|
||||
cargo build --release
|
||||
RUN rm cache.rs && \
|
||||
rm Cargo.toml
|
||||
# Build wimple-wkd
|
||||
COPY backend/Cargo.toml .
|
||||
COPY backend/src src
|
||||
RUN RUSTFLAGS='-C target-feature=-crt-static' cargo build --release
|
||||
RUN cargo build --release
|
||||
|
||||
|
||||
FROM ${base} AS webpage-builder
|
||||
FROM --platform=$BUILDPLATFORM ${base} AS webpage-builder
|
||||
|
||||
RUN apk add --no-cache npm
|
||||
COPY website .
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue