Skip to content

Replace Docker Compose dev setup with a devcontainer#13570

Open
Turbo87 wants to merge 3 commits intorust-lang:mainfrom
Turbo87:devcontainer
Open

Replace Docker Compose dev setup with a devcontainer#13570
Turbo87 wants to merge 3 commits intorust-lang:mainfrom
Turbo87:devcontainer

Conversation

@Turbo87
Copy link
Copy Markdown
Member

@Turbo87 Turbo87 commented May 3, 2026

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.

@Turbo87 Turbo87 added C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear and removed A-svelte labels May 3, 2026
@Turbo87 Turbo87 requested a review from a team May 3, 2026 14:44
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@LawnGnome
Copy link
Copy Markdown
Contributor

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.)

@Turbo87
Copy link
Copy Markdown
Member Author

Turbo87 commented May 4, 2026

I do want a flag a concern on removing the Docker Compose environment

the devcontainer setup is using docker-compose underneath too though, so what specifically do you think is missing or should be integrated differently?

Comment thread .devcontainer/post-create.sh Outdated

diesel migration run

pnpm install
Copy link
Copy Markdown
Contributor

@ehuss ehuss May 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
pnpm install
pnpm install --config.confirmModulesPurge=false

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 😅

Comment thread docs/CONTRIBUTING.md Outdated
Comment on lines +110 to +111
The remaining sections describe how to set the same environment up
manually if you prefer not to use containers.
Copy link
Copy Markdown
Contributor

@ehuss ehuss May 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks! I got it working now.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

Turbo87 and others added 3 commits May 6, 2026 19:37
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.
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 6, 2026

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-svelte C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants