Replace Docker Compose dev setup with a devcontainer#13570
Replace Docker Compose dev setup with a devcontainer#13570Turbo87 wants to merge 3 commits intorust-lang:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I'm not going to do a full review on this right now, but I do want a flag a concern on removing the Docker Compose environment — dev containers are still pretty tied to the Microsoft ecosystem of developer tooling, and might not be as useful to people not using VSCode (or Zed, which apparently has some level of support). I have no problem adding a dev container environment as well, but I am interested in how others are developing crates.io. (That said, I'll immediately undercut my own argument — I wrote my own Docker Compose environment for crates.io development because I didn't really like how the in-repo compose environment worked, so I'm not actually particularly tied to it either in its current state. I just don't want to increase friction for anyone wanting to make a drive-by contribution.) |
the devcontainer setup is using docker-compose underneath too though, so what specifically do you think is missing or should be integrated differently? |
|
|
||
| diesel migration run | ||
|
|
||
| pnpm install |
There was a problem hiding this comment.
Just FYI, I tried this on my system and this step hung waiting for user input to confirm some action. I think I unblocked it with this change:
| pnpm install | |
| pnpm install --config.confirmModulesPurge=false |
There was a problem hiding this comment.
oh, good catch! I guess I didn't have a conflicting node_modules on my system that it needed to purge, so I didn't run into this issue 😅
| The remaining sections describe how to set the same environment up | ||
| manually if you prefer not to use containers. |
There was a problem hiding this comment.
It's pretty unclear to me what to do next at this stage. It created the devcontainer, and there are some ports open, but loading them returns an empty page.
I was thinking maybe I need to manually start the server, but trying that fails:
vscode ➜ /workspaces/crates.io (devcontainer) $ pnpm dev:local
ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL Command "dev:local" not found
At this point, I'm pretty lost on how to get it running.
There was a problem hiding this comment.
thanks for the review! :)
I've added another commit on top with cross links to the relevant docs sections, which should hopefully make this clearer.
Command "dev:local" not found
the issue here is that this "script" is defined in the svelte subfolder, so you'd need to cd svelte before trying that, or use pnpm --dir svelte dev:local from the root.
There was a problem hiding this comment.
Nice, thanks! I got it working now.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Drops the standalone `docker-compose.yml`, `backend.Dockerfile`,
`frontend.Dockerfile`, `docker_entrypoint.sh`, and the postgres init
script in favor of a single full-stack devcontainer under
`.devcontainer/` that provides Rust, Node.js 24, pnpm, Postgres 16,
`diesel_cli`, and Playwright in one container. It works with VS Code
"Reopen in Container", GitHub Codespaces, and the standalone
`devcontainer` CLI, so contributors can get a working environment
without installing the toolchain locally.
`postCreateCommand` initializes the local git index, creates the test
database, runs migrations, installs JavaScript dependencies and the
Playwright Chromium headless shell, pre-fetches Rust crates, and
seeds `.env` from `.env.sample` if missing so the backend boots out
of the box. `postStartCommand` reruns `diesel migration run` on every
container start, and the `db` service has a `pg_isready` healthcheck
so the app waits for Postgres to actually accept connections.
Named volumes keyed by `${devcontainerId}` persist the cargo target
dir, cargo registry, pnpm store, and `local_uploads/` across
rebuilds without bleeding into the host worktree. Backend, Svelte
dev server, and Storybook ports are published on `127.0.0.1` via
compose so non-VS-Code clients reach them too. The Vite config now
honors the existing `DEV_DOCKER` env var and binds `0.0.0.0` when
it is set, matching the backend's behavior, so the published Svelte
port actually reaches a listener inside the container.
`docs/CONTRIBUTING.md` documents the new quick-start path and
`.devcontainer/README.md` covers the details and troubleshooting.
The existing manual setup instructions remain as the alternative.
# Conflicts:
# .gitignore
# docker-compose.yml
…all` Without it, `pnpm install` hangs waiting for confirmation when it wants to recreate `node_modules` and there is no TTY attached to the post-create script.
The Quick start section in `CONTRIBUTING.md` and the devcontainer README both stop short of telling users how to actually start the backend and Svelte dev server once the container is up. Add explicit links to the existing "Building and serving the frontend" and "Starting the server and the frontend" sections from both entry points.
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Drops the standalone
docker-compose.yml,backend.Dockerfile,frontend.Dockerfile,docker_entrypoint.sh, and the postgres init script in favor of a single full-stack devcontainer under.devcontainer/that provides Rust, Node.js 24, pnpm, Postgres 16,diesel_cli, and Playwright in one container. It works with VS Code "Reopen in Container", GitHub Codespaces, and the standalonedevcontainerCLI, so contributors can get a working environment without installing the toolchain locally.postCreateCommandinitializes the local git index, creates the test database, runs migrations, installs JavaScript dependencies and the Playwright Chromium headless shell, pre-fetches Rust crates, and seeds.envfrom.env.sampleif missing so the backend boots out of the box.postStartCommandrerunsdiesel migration runon every container start, and thedbservice has apg_isreadyhealthcheck so the app waits for Postgres to actually accept connections.Named volumes keyed by
${devcontainerId}persist the cargo target dir, cargo registry, pnpm store, andlocal_uploads/across rebuilds without bleeding into the host worktree. Backend, Svelte dev server, and Storybook ports are published on127.0.0.1via compose so non-VS-Code clients reach them too. The Vite config now honors the existingDEV_DOCKERenv var and binds0.0.0.0when it is set, matching the backend's behavior, so the published Svelte port actually reaches a listener inside the container.docs/CONTRIBUTING.mddocuments the new quick-start path and.devcontainer/README.mdcovers the details and troubleshooting. The existing manual setup instructions remain as the alternative.