diff --git a/Containerfile b/Containerfile index 2989c9800..c50c13692 100644 --- a/Containerfile +++ b/Containerfile @@ -18,8 +18,8 @@ FROM shuttle-build AS builder COPY --from=planner /build/recipe.json recipe.json RUN cargo chef cook --recipe-path recipe.json COPY --from=cache /build . -ARG crate -RUN cargo build --bin ${crate} +ARG folder +RUN cargo build --bin shuttle-${folder} FROM rust:1.63.0-buster as shuttle-common RUN apt-get update &&\ @@ -28,14 +28,8 @@ RUN rustup component add rust-src COPY --from=cache /build/ /usr/src/shuttle/ FROM shuttle-common -ARG crate -SHELL ["/bin/bash", "-c"] -RUN mkdir -p $CARGO_HOME; \ -echo $'[patch.crates-io] \n\ -shuttle-service = { path = "/usr/src/shuttle/service" } \n\ -shuttle-aws-rds = { path = "/usr/src/shuttle/resources/aws-rds" } \n\ -shuttle-persist = { path = "/usr/src/shuttle/resources/persist" } \n\ -shuttle-shared-db = { path = "/usr/src/shuttle/resources/shared-db" } \n\ -shuttle-secrets = { path = "/usr/src/shuttle/resources/secrets" }' > $CARGO_HOME/config.toml -COPY --from=builder /build/target/debug/${crate} /usr/local/bin/service +ARG folder +COPY ${folder}/prepare.sh /prepare.sh +RUN /prepare.sh +COPY --from=builder /build/target/debug/shuttle-${folder} /usr/local/bin/service ENTRYPOINT ["/usr/local/bin/service"] diff --git a/Makefile b/Makefile index 9b502aa35..c41a139da 100644 --- a/Makefile +++ b/Makefile @@ -89,7 +89,7 @@ down: docker-compose.rendered.yml shuttle-%: ${SRC} Cargo.lock docker buildx build \ - --build-arg crate=shuttle-$(*) \ + --build-arg folder=$(*) \ --tag $(CONTAINER_REGISTRY)/$(*):$(COMMIT_SHA) \ --tag $(CONTAINER_REGISTRY)/$(*):$(TAG) \ --tag $(CONTAINER_REGISTRY)/$(*):latest \ diff --git a/deployer/prepare.sh b/deployer/prepare.sh new file mode 100755 index 000000000..c12581b19 --- /dev/null +++ b/deployer/prepare.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env sh + +############################################################################### +# This file is used by our common Containerfile incase the container for this # +# service might need some extra preparation steps for its final image # +############################################################################### + +# Patch crates to be on same versions +mkdir -p $CARGO_HOME; \ +echo '[patch.crates-io] +shuttle-service = { path = "/usr/src/shuttle/service" } +shuttle-aws-rds = { path = "/usr/src/shuttle/resources/aws-rds" } +shuttle-persist = { path = "/usr/src/shuttle/resources/persist" } +shuttle-shared-db = { path = "/usr/src/shuttle/resources/shared-db" } +shuttle-secrets = { path = "/usr/src/shuttle/resources/secrets" }' > $CARGO_HOME/config.toml + +# Prefetch crates.io index +cd /usr/src/shuttle/service +cargo fetch diff --git a/gateway/prepare.sh b/gateway/prepare.sh new file mode 100755 index 000000000..6a52d3030 --- /dev/null +++ b/gateway/prepare.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +############################################################################### +# This file is used by our common Containerfile incase the container for this # +# service might need some extra preparation steps for its final image # +############################################################################### + +# Nothing to prepare in container image here diff --git a/provisioner/prepare.sh b/provisioner/prepare.sh new file mode 100755 index 000000000..6a52d3030 --- /dev/null +++ b/provisioner/prepare.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +############################################################################### +# This file is used by our common Containerfile incase the container for this # +# service might need some extra preparation steps for its final image # +############################################################################### + +# Nothing to prepare in container image here