chore: replace docker shell script with js CLI commands and use for dev and test environments #2130
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This closes #2121 by replacing the
run-with-dependencies.sh
script I added with arunWithServices
function inscripts/cmds/services.js
.This does essentially the same thing as the shell script, which is to run
docker compose up
to bring up the services, get the local ports for the running services and override some config variables, then run the action you give it. It also registers a cleanup hook to rundocker compose down
whenever the process exits (including abnormal exit, Ctrl+C, etc).I replaced the existing
services start
andservices stop
commands withservices exec
, which does therunWithServices
thing to an arbitrary shell command you give it. The motivation here is to allow using a unique docker compose project name for each run (except in persistent mode, where the project name is alwaysnft-storage-dev-persistent
). With separatestart
andstop
commands, you would need to write the project name to a file or something to keep track of it between invocations, but with the start and cleanup commands in the same process you can just keep the project name in memory. If you want something like the old behavior (because you want to manually poke at the db, say), you can runcli.js services exec bash
to run a shell, and then run whatever you want inside the shell.I also wired this up to
yarn dev
and added a newyarn dev:persist
command, which I believe meets the requirements we were trying to hit in #1888, but with less boilerplate and without putting miniflare or the test runner into a container.The persistent mode works by creating named docker volumes on the host, and using the
docker-compose-volumes.yml
file to point the services at those long-lived volumes instead of the ephemeral volumes specified in the maindocker-compose.yml
.