Skip to content

Commit

Permalink
chore: opt out of panamax (#576)
Browse files Browse the repository at this point in the history
* chore: opt out of panamax

* panamax link

* fix link

* feat: opt out of starting panamax container

* fix: typos in contributing.md

* refactor: skip panamax by default for make up

* fix: make up override needs to go after `make`

---------

Co-authored-by: oddgrd <29732646+oddgrd@users.noreply.github.com>
  • Loading branch information
brokad and oddgrd authored Mar 2, 2023
1 parent 2e4f904 commit 631ee96
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 13 deletions.
8 changes: 6 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ You should now be ready to setup a local environment to test code changes to cor
From the root of the shuttle repo, build the required images with:

```bash
make images
USE_PANAMAX=disable make images
```

> Note: The stack uses [panamax](https://github.com/panamax-rs/panamax) by default to mirror crates.io content. We do this in order to avoid overloading upstream mirrors and hitting rate limits. After syncing the cache, expect to see the panamax volume take about 100GiB of space. This may not be desirable for local testing. To avoid using panamax, run `USE_PANAMAX=disable make images` instead.
The images get built with [cargo-chef](https://github.com/LukeMathWalker/cargo-chef) and therefore support incremental builds (most of the time). So they will be much faster to re-build after an incremental change in your code - should you wish to deploy it locally straight away.

You can now start a local deployment of shuttle and the required containers with:
Expand All @@ -40,6 +42,8 @@ You can now start a local deployment of shuttle and the required containers with
make up
```

> Note: `make up` does not start [panamax](https://github.com/panamax-rs/panamax) by default, if you do need to start panamax for local development, run this command with `make COMPOSE_PROFILES=panamax up`.
> Note: Other useful commands can be found within the [Makefile](https://github.com/shuttle-hq/shuttle/blob/main/Makefile).
The API is now accessible on `localhost:8000` (for app proxies) and `localhost:8001` (for the control plane). When running `cargo run --bin cargo-shuttle` (in a debug build), the CLI will point itself to `localhost` for its API calls.
Expand All @@ -59,7 +63,7 @@ shuttle-static-folder = { path = "[base]/shuttle/resources/static-folder" }
```

Before we can login to our local instance of shuttle, we need to create a user.
The following command inserts a user into the gateway state with admin privileges:
The following command inserts a user into the `auth` state with admin privileges:

```bash
docker compose --file docker-compose.rendered.yml --project-name shuttle-dev exec auth /usr/local/bin/service --state=/var/lib/shuttle-auth init --name admin --key test-key
Expand Down
3 changes: 2 additions & 1 deletion Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ COPY --from=cache /build/ /usr/src/shuttle/

FROM shuttle-common
ARG folder
ARG prepare_args
COPY ${folder}/prepare.sh /prepare.sh
RUN /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
Expand Down
28 changes: 20 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ PANAMAX_TAG?=1.0.12
OTEL_EXTRA_PATH?=./extras/otel
OTEL_TAG?=0.72.0

DOCKER_COMPOSE_ENV=STACK=$(STACK) BACKEND_TAG=$(BACKEND_TAG) DEPLOYER_TAG=$(DEPLOYER_TAG) PROVISIONER_TAG=$(PROVISIONER_TAG) POSTGRES_TAG=${POSTGRES_TAG} PANAMAX_TAG=${PANAMAX_TAG} OTEL_TAG=${OTEL_TAG} APPS_FQDN=$(APPS_FQDN) DB_FQDN=$(DB_FQDN) POSTGRES_PASSWORD=$(POSTGRES_PASSWORD) RUST_LOG=$(RUST_LOG) CONTAINER_REGISTRY=$(CONTAINER_REGISTRY) MONGO_INITDB_ROOT_USERNAME=$(MONGO_INITDB_ROOT_USERNAME) MONGO_INITDB_ROOT_PASSWORD=$(MONGO_INITDB_ROOT_PASSWORD) DD_ENV=$(DD_ENV) USE_TLS=$(USE_TLS)
USE_PANAMAX?=enable
ifeq ($(USE_PANAMAX), enable)
PREPARE_ARGS+=-p
COMPOSE_PROFILES+=panamax
endif

DOCKER_COMPOSE_ENV=STACK=$(STACK) BACKEND_TAG=$(BACKEND_TAG) DEPLOYER_TAG=$(DEPLOYER_TAG) PROVISIONER_TAG=$(PROVISIONER_TAG) POSTGRES_TAG=${POSTGRES_TAG} PANAMAX_TAG=${PANAMAX_TAG} OTEL_TAG=${OTEL_TAG} APPS_FQDN=$(APPS_FQDN) DB_FQDN=$(DB_FQDN) POSTGRES_PASSWORD=$(POSTGRES_PASSWORD) RUST_LOG=$(RUST_LOG) CONTAINER_REGISTRY=$(CONTAINER_REGISTRY) MONGO_INITDB_ROOT_USERNAME=$(MONGO_INITDB_ROOT_USERNAME) MONGO_INITDB_ROOT_PASSWORD=$(MONGO_INITDB_ROOT_PASSWORD) DD_ENV=$(DD_ENV) USE_TLS=$(USE_TLS) COMPOSE_PROFILES=$(COMPOSE_PROFILES)

.PHONY: images clean src up down deploy shuttle-% postgres docker-compose.rendered.yml test bump-% deploy-examples publish publish-% --validate-version

Expand All @@ -91,12 +97,14 @@ postgres:
$(POSTGRES_EXTRA_PATH)

panamax:
docker buildx build \
--build-arg PANAMAX_TAG=$(PANAMAX_TAG) \
--tag $(CONTAINER_REGISTRY)/panamax:$(PANAMAX_TAG) \
$(BUILDX_FLAGS) \
-f $(PANAMAX_EXTRA_PATH)/Containerfile \
$(PANAMAX_EXTRA_PATH)
if [ $(USE_PANAMAX) = "enable" ]; then \
docker buildx build \
--build-arg PANAMAX_TAG=$(PANAMAX_TAG) \
--tag $(CONTAINER_REGISTRY)/panamax:$(PANAMAX_TAG) \
$(BUILDX_FLAGS) \
-f $(PANAMAX_EXTRA_PATH)/Containerfile \
$(PANAMAX_EXTRA_PATH); \
fi

otel:
docker buildx build \
Expand All @@ -115,6 +123,9 @@ deploy: docker-compose.yml
test:
cd e2e; POSTGRES_PASSWORD=$(POSTGRES_PASSWORD) APPS_FQDN=$(APPS_FQDN) cargo test $(CARGO_TEST_FLAGS) -- --nocapture

# Start the containers locally. This does not start panamax by default,
# to start panamax locally run this command with the COMPOSE_PROFILES=panamax
# environment variable.
up: docker-compose.rendered.yml
CONTAINER_REGISTRY=$(CONTAINER_REGISTRY) $(DOCKER_COMPOSE) -f $< -p $(STACK) up -d $(DOCKER_COMPOSE_FLAGS)

Expand All @@ -124,7 +135,8 @@ down: docker-compose.rendered.yml
shuttle-%: ${SRC} Cargo.lock
docker buildx build \
--build-arg folder=$(*) \
--build-arg RUSTUP_TOOLCHAIN=$(RUSTUP_TOOLCHAIN) \
--build-arg prepare_args=$(PREPARE_ARGS) \
--build-arg RUSTUP_TOOLCHAIN=$(RUSTUP_TOOLCHAIN) \
--build-arg CARGO_PROFILE=$(CARGO_PROFILE) \
--tag $(CONTAINER_REGISTRY)/$(*):$(COMMIT_SHA) \
--tag $(CONTAINER_REGISTRY)/$(*):$(TAG) \
Expand Down
12 changes: 10 additions & 2 deletions deployer/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ shuttle-shared-db = { path = "/usr/src/shuttle/resources/shared-db" }
shuttle-secrets = { path = "/usr/src/shuttle/resources/secrets" }
shuttle-static-folder = { path = "/usr/src/shuttle/resources/static-folder" }' > $CARGO_HOME/config.toml

# Make future crates requests to our own mirror
echo '
while getopts "p," o; do
case $o in
"p")
# Make future crates requests to our own mirror
echo '
[source.shuttle-crates-io-mirror]
registry = "http://panamax:8080/git/crates.io-index"
[source.crates-io]
replace-with = "shuttle-crates-io-mirror"' >> $CARGO_HOME/config.toml
;;
*)
;;
esac
done

# Prefetch crates.io index from our mirror
# TODO: restore when we know how to prefetch from our mirror
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ services:
constraints:
- node.hostname==controller
panamax:
profiles:
- panamax
image: "${CONTAINER_REGISTRY}/panamax:${PANAMAX_TAG}"
restart: always
networks:
Expand All @@ -189,6 +191,8 @@ services:
constraints:
- node.hostname==controller
deck-chores:
profiles:
- panamax
image: funkyfuture/deck-chores:1
restart: unless-stopped
environment:
Expand Down

0 comments on commit 631ee96

Please sign in to comment.