-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: dockerfile and ci improvements (#989)
* cleanup in dockerfiles and ci * minor builder fixes * add sccache to deployer + cleanup * fmt * docs: install with --locked * Add comments, move arg statements * Leave out the sccache * clarify * Run prepare script before loading src cache * Delay src-dependent preparation to after cache * explicit docker.io, move curl installation --------- Co-authored-by: oddgrd <29732646+oddgrd@users.noreply.github.com>
- v0.52.0
- v0.51.0
- v0.50.0
- v0.49.0
- v0.48.3
- v0.48.2
- v0.48.1
- v0.48.0
- v0.47.0
- v0.46.0
- v0.45.0
- v0.44.0
- v0.43.0
- v0.42.0
- v0.41.0
- v0.40.0
- v0.39.0
- v0.38.0
- v0.37.0
- v0.36.0
- v0.35.2
- v0.35.1
- v0.35.0
- v0.34.1
- v0.34.0
- v0.33.0
- v0.32.0
- v0.31.0
- v0.30.1
- v0.30.0
- v0.29.1
- v0.29.0
- v0.28.1
- v0.28.0
- v0.27.0
- v0.26.0
- v0.25.1
- v0.25.0
- v0.24.0
- v0.23.0
- v0.22.0
- v0.21.0
- v0.20.0
Showing
9 changed files
with
142 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,63 @@ | ||
#syntax=docker/dockerfile-upstream:1.4.0-rc1 | ||
#syntax=docker/dockerfile-upstream:1.4 | ||
|
||
|
||
# Base image for builds and cache | ||
ARG RUSTUP_TOOLCHAIN | ||
FROM docker.io/library/rust:${RUSTUP_TOOLCHAIN}-buster as shuttle-build | ||
RUN apt-get update &&\ | ||
apt-get install -y curl | ||
|
||
RUN cargo install cargo-chef | ||
RUN cargo install cargo-chef --locked | ||
WORKDIR /build | ||
|
||
|
||
# Stores source cache | ||
FROM shuttle-build as cache | ||
ARG CARGO_PROFILE | ||
WORKDIR /src | ||
COPY . . | ||
RUN find ${SRC_CRATES} \( -name "*.proto" -or -name "*.rs" -or -name "*.toml" -or -name "Cargo.lock" -or -name "README.md" -or -name "*.sql" \) -type f -exec install -D \{\} /build/\{\} \; | ||
# This is used to carry over in the docker images any *.pem files from shuttle root directory, to be used for TLS testing, as described | ||
# here in the admin README.md. | ||
RUN [ "$CARGO_PROFILE" != "release" ] && find ${SRC_CRATES} -name "*.pem" -type f -exec install -D \{\} /build/\{\} \; | ||
# This is used to carry over in the docker images any *.pem files from shuttle root directory, | ||
# to be used for TLS testing, as described here in the admin README.md. | ||
RUN [ "$CARGO_PROFILE" != "release" ] && \ | ||
find ${SRC_CRATES} -name "*.pem" -type f -exec install -D \{\} /build/\{\} \; | ||
|
||
|
||
# Stores cargo chef recipe | ||
FROM shuttle-build AS planner | ||
COPY --from=cache /build . | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
|
||
# Builds crate according to cargo chef recipe | ||
FROM shuttle-build AS builder | ||
COPY --from=planner /build/recipe.json recipe.json | ||
ARG CARGO_PROFILE | ||
RUN cargo chef cook $(if [ "$CARGO_PROFILE" = "release" ]; then echo --${CARGO_PROFILE}; fi) --recipe-path recipe.json | ||
COPY --from=cache /build . | ||
ARG folder | ||
# if CARGO_PROFILE is release, pass --release, else use default debug profile | ||
RUN cargo build --bin shuttle-${folder} $(if [ "$CARGO_PROFILE" = "release" ]; then echo --${CARGO_PROFILE}; fi) | ||
|
||
ARG RUSTUP_TOOLCHAIN | ||
FROM rust:${RUSTUP_TOOLCHAIN}-buster as shuttle-common | ||
RUN rustup component add rust-src | ||
COPY --from=planner /build/recipe.json recipe.json | ||
RUN cargo chef cook \ | ||
# if CARGO_PROFILE is release, pass --release, else use default debug profile | ||
$(if [ "$CARGO_PROFILE" = "release" ]; then echo --release; fi) \ | ||
--recipe-path recipe.json | ||
COPY --from=cache /build . | ||
RUN cargo build --bin shuttle-${folder} \ | ||
$(if [ "$CARGO_PROFILE" = "release" ]; then echo --release; fi) | ||
|
||
COPY --from=cache /build/ /usr/src/shuttle/ | ||
|
||
FROM shuttle-common | ||
# The final image for this "shuttle-..." crate | ||
ARG RUSTUP_TOOLCHAIN | ||
FROM docker.io/library/rust:${RUSTUP_TOOLCHAIN}-buster as shuttle-crate | ||
ARG folder | ||
ARG prepare_args | ||
# used as env variable in prepare script | ||
ARG PROD | ||
COPY ${folder}/prepare.sh /prepare.sh | ||
RUN /prepare.sh "${prepare_args}" | ||
ARG CARGO_PROFILE | ||
COPY --from=builder /build/target/${CARGO_PROFILE}/shuttle-${folder} /usr/local/bin/service | ||
ARG RUSTUP_TOOLCHAIN | ||
ENV RUSTUP_TOOLCHAIN=${RUSTUP_TOOLCHAIN} | ||
|
||
COPY ${folder}/prepare.sh /prepare.sh | ||
RUN /prepare.sh "${prepare_args}" | ||
|
||
COPY --from=cache /build /usr/src/shuttle/ | ||
|
||
# Any prepare steps that depend on the COPY from src cache | ||
RUN /prepare.sh --after-src "${prepare_args}" | ||
|
||
COPY --from=builder /build/target/${CARGO_PROFILE}/shuttle-${folder} /usr/local/bin/service | ||
ENTRYPOINT ["/usr/local/bin/service"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters