Dev Containers make the project's development environment part of the repository.
Instead of asking every developer to install and configure the same tools by hand, the project describes a container that an editor such as VS Code can build and use as its workspace.
For Mars Rover, the Dev Container is more than a Python shell: it connects VS Code to the same Docker Compose service used by the project's container-based test workflow. That gives developers and CI a shared baseline for Python, dependencies, and commands.
Project links: GitHub repository · Event Storming and Then What? on Dev.to.
How this repository is configured
The setup is split across three files:
| File | Responsibility |
|---|---|
.devcontainer/devcontainer.json |
Tells VS Code which Compose file and service to use, where the workspace lives, and which editor settings and extensions to apply. |
docker-compose.yml |
Defines the mars-rover development service, its mounts, and its long-running command. |
container/Dockerfile |
Defines the Python image and installs the project's Python requirements. |
The Dev Container configuration selects the mars-rover service from docker-compose.yml and opens the workspace at /code. It adds the Dev Container Git feature and recommends the Python, Pylance, and Code Spell Checker extensions. The Python interpreter is set to /usr/local/bin/python, with basic type checking enabled. The accompanying lock file records the resolved Git feature version and digest.
The Dockerfile starts from python:3.10-slim-bookworm, sets /code as its working directory, installs packages from requirements.txt, and copies the application into the image. The requirements include pytest for tests and vulture for the dead-code check.
Compose then builds that Dockerfile and mounts the checkout into the container:
volumes:
- .:/code:cached
- ${PWD}/.ssh:/root/.ssh
command: sleep infinity
The workspace mount makes edits on the host immediately visible inside /code; developers do not need to rebuild the image after each source change. The container stays alive so the editor can attach and commands can be run interactively. The SSH mount makes host SSH configuration available inside the container, so only use it with a trusted development environment and keys appropriate for that work.
To start working, open the repository in VS Code and choose Dev Containers: Reopen in Container. Alternatively, start the Compose service with docker compose up -d mars-rover, then run development commands inside it.
In VS Code, use the Command Palette (Ctrl+Shift+P / Cmd+Shift+P) and search for Dev Containers to see available container commands:
Examples from the codebase
The container is useful because it supports the project's real workflows, not just a generic Python prompt.
For example, the end-to-end test in test/test_e2e.py creates a rover in a 4-by-4 world, sends the command string RMLMM, and checks that the rover finishes at 1:2:N. A second test places an obstacle at (2, 2), runs RMMLMMMMMMMMMMMRMMMM, and checks that the rover stops at O:2:1:N. These tests exercise the runner, command handling, domain behavior, repository, and projections together.
Run the test suite on a machine with the project's Python dependencies installed:
./devops/run.sh test
Or run it in the Compose container:
./devops/run.sh ci
The ci command starts the mars-rover service and runs the test command inside it. The GitHub Actions workflow in .github/workflows/main.yml uses this same entry point, so local container-based checks and CI follow the same route. To check for dead code in the container, use:
./devops/run.sh check
The script also provides ./devops/run.sh build to build the service image and ./devops/run.sh run to launch the sample program with python -m app.main.
Why this helps DevOps
When development and CI use the same container definition, there are fewer hidden differences to diagnose: a developer's locally installed Python version or an untracked system package is less likely to determine whether a test passes. The Dockerfile and Compose configuration provide a repeatable starting point, while the tests give concrete examples of expected behavior.
This makes issues easier to reproduce. A developer can check out the relevant revision, open it in the Dev Container, and run the same test command used by CI. For instance, if a rover reports the wrong coordinate after hitting an obstacle, the obstacle scenario in test/test_e2e.py is a ready-made reproduction that can be run in that environment. The container also provides a practical place to investigate dependency or Python-runtime differences without asking every team member to configure a separate local stack.
The same approach can reduce environment sprawl: Python and project tools are declared together, rather than being installed and maintained differently on every workstation. It also brings development closer to production when production uses a compatible Python version and the same dependency set.
Development parity is not production parity by itself
This repository defines a development and CI container, but it does not define a production deployment. In particular, Compose bind-mounts the working tree and the host SSH directory, and the service runs sleep infinity so an editor can attach. Those are development choices, not a production runtime. The sample application is launched separately with python -m app.main.
So the Dev Container helps reduce environment-related surprises, but it cannot guarantee that there will be no production issues. To claim stronger parity, production should use the same built application image (or a deliberately compatible one), and deployment-specific configuration should be managed separately. Pinning the base image by digest and locking dependency versions would also make image rebuilds more reproducible; the current Python image tag and minimum dependency requirements do not pin every installed artifact.
For background on the approach and the available Dev Container configurations, see the Dev Container Guides, including Using Images, Dockerfiles, and Docker Compose.

Top comments (0)