-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into chore/workspace-eve…
…rything
- Loading branch information
Showing
9 changed files
with
139 additions
and
105 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
Oops, something went wrong.