After trying out GitHub Codespaces for work, it’s clear that—while impressive—it is not a suitable replacement to developing locally. It’s slow to set up. It’s also very expensive.
When using Codespaces with a monorepo that uses docker-compose
to run services (e.g. a database, frontend app, and API server) you want to have everything running so you can develop as soon as it boots. However, every Codespaces container builds the entire docker-compose
each time which takes time for any non-trivial setup.
If you try to set your .devcontainer
to your project’s docker-compose.yml
, Codespaces doesn’t expose the running docker services in an accessible way and you are attached to a single container with no way to switch. You can’t see logs (e.g. docker compose logs {service}
) or execute code in another container (e.g. docker compose exec {service} {command}
). You can’t change which container the Codespace is attached to so running setup or maintenance scripts is difficult.
You could use the default
.devcontainer
and calldocker
from within the Codespace terminal, but then you push the build latency to after the Codespace boots and the user has to remember to call it for the set of services they need.GitHub is also working on a feature to pre-build devcontainer images, but who knows how much that will cost in storage.
Adding up the costs of using Codespaces full time shows that it’s more expensive than buying MacBook Air M1s. At the default 4 core VM at $0.36 you’re looking at roughly $1,000 per engineer per year. Not to mention and you still need to buy and maintain a work laptop.
There is an argument to be made that you save money on time spent dealing with local configuration issues. This makes sense at larger organizations, but for a small startup, probably not.
See also:
Links to this note
-
Running Docker Compose in Codespaces
Using the built-in
docker-compose
configuration in GitHub Codespaces is limited. It’s better to rundocker-compose
inside the Codespace but this requires a docker-in-docker setup which is finicky. -
Codespaces Doesn’t Allow Requests Across Ports from a Preview
At time of writing, a CORS error will occur if the web application served in a GitHub preview URL attempts to make a fetch request to a different port. Specifically, it the preflight
OPTION
request receive a302
HTTP status code and fail withRedirect is not allowed for a preflight request
.