Dev Container Setup#
Sure's dev container is the recommended way for contributors to get a fully wired local environment without manually installing PostgreSQL, Redis, or a browser driver. Opening the repo in VS Code (or a compatible editor) automatically builds the environment defined in .devcontainer/.
How It Works#
The entry point is .devcontainer/devcontainer.json, which wires three things together:
| Setting | Value |
|---|---|
dockerComposeFile | .devcontainer/docker-compose.yml |
service (primary container) | app |
runServices (auto-started) | db, redis, selenium |
On container creation, VS Code automatically runs bundle install && npm install via postCreateCommand. After that, run bin/setup (or bin/rails db:prepare directly) to finish initializing the database.
The app service is built from .devcontainer/Dockerfile, which is based on ruby:3.4.9-slim-bookworm and pre-installs system packages for PostgreSQL (libpq-dev, postgresql-client), Node.js 20, libvips42 (ActiveStorage image variants), and ImageMagick .
Docker Compose Services#
All services are defined in .devcontainer/docker-compose.yml:
| Service | Image | Purpose |
|---|---|---|
app | Custom (.devcontainer/Dockerfile) | Rails dev server — sleeps; started manually via bin/dev |
worker | Same as app | Sidekiq background jobs (bundle exec sidekiq) |
db | postgres:16 | PostgreSQL, port 5432 |
redis | redis:latest | Job queue / cache |
selenium | selenium/standalone-chromium:latest | Browser automation for system tests, ports 4444 / 7900 |
Environment variables are injected via two YAML anchors :
x-db-env— setsPOSTGRES_USER: postgres,POSTGRES_DB: postgres,POSTGRES_PASSWORD: postgreson thedbcontainer.x-rails-env— setsDB_HOST: db,POSTGRES_USER/PASSWORD,REDIS_URL: redis://redis:6379/1, andSELENIUM_REMOTE_URL: http://selenium:4444onappandworker.
A named bundle_cache volume is shared between app and worker to avoid re-fetching gems .
The app container binds BINDING: "0.0.0.0" so the Rails server inside Docker is reachable on the host at http://localhost:3000 .
Database Initialization#
bin/setup is the canonical first-run script. It:
- Installs Ruby gems (
bundle install) - Installs Node packages and builds design tokens (
npm install && npm run tokens:build) - Runs
bin/rails db:prepareto create and migratesure_development - Clears logs/tmp and restarts the server
db:prepare creates the database if it does not exist, then runs pending migrations — safe to re-run. The development database defaults to sure_development via config/database.yml (overridable with POSTGRES_DB).
VS Code Extensions#
devcontainer.json automatically installs three extensions :
biomejs.biome— JS/TS linter and formatterEditorConfig.EditorConfig— enforces project.editorconfigrulesShopify.ruby-extensions-pack— Ruby/Rails language support
Environment Variables#
Copy .env.local.example to .env.local before first run — referenced in the README Getting Started section. The GITHUB_TOKEN and GITHUB_USER host variables are forwarded into the container via containerEnv if present .
Further Reading#
- README — Local Development Setup
- VS Code Dev Containers overview (linked from README)
- Mac Dev Setup Guide / Linux / Windows wiki guides