Skip to content

Commit ff59b04

Browse files
committed
Address feedback, fix local run, separate final steps per crate
1 parent d7d4926 commit ff59b04

File tree

10 files changed

+38
-47
lines changed

10 files changed

+38
-47
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
**/target/
66
# Ignore the cargo lockfiles not in the workspace root
77
*/**/Cargo.lock
8+
# cargo-chef testing
9+
recipe.json
810

911
# These are backup files generated by rustfmt
1012
**/*.rs.bk

Containerfile

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,45 @@ RUN cargo build \
5050
--bin shuttle-next -F next
5151

5252

53-
# The final image for running each "shuttle-..." binary
53+
# Base image for running each "shuttle-..." binary
5454
ARG RUSTUP_TOOLCHAIN
55-
FROM docker.io/library/rust:${RUSTUP_TOOLCHAIN}-buster as shuttle-crate
55+
FROM docker.io/library/rust:${RUSTUP_TOOLCHAIN}-buster as shuttle-crate-base
5656
ARG CARGO_PROFILE
5757
ARG folder
5858
ARG crate
5959
ARG prepare_args
60-
# used as env variable in prepare script
60+
# Fixes some dependencies compiled with incompatible versions of rustc
61+
ENV RUSTUP_TOOLCHAIN=${RUSTUP_TOOLCHAIN}
62+
# Used as env variable in prepare script
6163
ARG PROD
6264

63-
# Individual preparation of images
64-
COPY ${folder}/prepare.sh /prepare.sh
65-
RUN /prepare.sh "${prepare_args}"
66-
67-
# shuttle-next is only needed in deployer but is now installed in all images.
68-
# can be improved, but does not hurt much.
69-
COPY --from=builder /build/target/${CARGO_PROFILE}/shuttle-next /usr/local/cargo/bin/
65+
# Some crates need additional libs
66+
COPY ${folder}/*.so /usr/lib/
67+
ENV LD_LIBRARY_PATH=/usr/lib/
7068

7169
COPY --from=builder /build/target/${CARGO_PROFILE}/${crate} /usr/local/bin/service
7270
ENTRYPOINT ["/usr/local/bin/service"]
71+
72+
73+
# Targets for each crate
74+
75+
FROM shuttle-crate-base AS shuttle-auth
76+
FROM shuttle-auth AS shuttle-auth-dev
77+
78+
FROM shuttle-crate-base AS shuttle-deployer
79+
ARG CARGO_PROFILE
80+
COPY --from=builder /build/target/${CARGO_PROFILE}/shuttle-next /usr/local/cargo/bin/
81+
COPY deployer/prepare.sh /prepare.sh
82+
RUN /prepare.sh "${prepare_args}"
83+
FROM shuttle-deployer AS shuttle-deployer-dev
84+
# Source code needed for compiling with [patch.crates-io]
85+
COPY --from=planner /build /usr/src/shuttle/
86+
87+
FROM shuttle-crate-base AS shuttle-gateway
88+
FROM shuttle-gateway AS shuttle-gateway-dev
89+
90+
FROM shuttle-crate-base AS shuttle-provisioner
91+
FROM shuttle-provisioner AS shuttle-provisioner-dev
92+
93+
FROM shuttle-crate-base AS shuttle-resource-recorder
94+
FROM shuttle-resource-recorder AS shuttle-resource-recorder-dev

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ PROVISIONER_TAG?=$(TAG)
2828
RESOURCE_RECORDER_TAG?=$(TAG)
2929

3030
DOCKER_BUILD?=docker buildx build
31-
3231
ifeq ($(CI),true)
3332
DOCKER_BUILD+= --progress plain
3433
endif
@@ -67,6 +66,7 @@ USE_TLS?=disable
6766
# default for local run
6867
CARGO_PROFILE?=debug
6968
RUST_LOG?=shuttle=debug,info
69+
DEV_SUFFIX=-dev
7070
DEPLOYS_API_KEY?=gateway4deployes
7171
endif
7272

@@ -179,6 +179,7 @@ down: $(DOCKER_COMPOSE_FILES)
179179

180180
shuttle-%:
181181
$(DOCKER_BUILD) \
182+
--target $(@)$(DEV_SUFFIX) \
182183
--build-arg folder=$(*) \
183184
--build-arg crate=$(@) \
184185
--build-arg prepare_args=$(PREPARE_ARGS) \

auth/prepare.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

deployer/prepare.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
###############################################################################
44
# This file is used by our common Containerfile incase the container for this #

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ services:
7777
- ${DOCKER_SOCK}:/var/run/docker.sock
7878
environment:
7979
- RUST_LOG=${RUST_LOG}
80-
- LD_LIBRARY_PATH=/usr/src/shuttle/gateway
8180
command:
8281
- "--state=/var/lib/shuttle"
8382
- "start"

gateway/prepare.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

gateway/src/project.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,8 +750,7 @@ impl ProjectCreating {
750750
self.project_id.to_string()
751751
],
752752
"Env": [
753-
"RUST_LOG=debug,shuttle=trace,h2=warn",
754-
"LD_LIBRARY_PATH=/usr/src/shuttle/deployer"
753+
"RUST_LOG=debug,shuttle=trace,h2=warn"
755754
]
756755
})
757756
});

provisioner/prepare.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

resource-recorder/prepare.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)