Cordium documentation · Latest
Running Containers
Workspaces can run their own containers via rootless Podman, which turns a Workspace into a complete environment for applications that depend on databases, caches, message brokers and other services (read more here). Since the containers run inside the Workspace's own sandbox, they do not have any access to the host or to the Cluster, and they are stopped with the Workspace.
Development Dependencies
The following Template installs Podman and starts PostgreSQL and Redis containers on every start of the Workspace. The containers use the Workspace's network (i.e. --net host), which means that the application reaches them at localhost:
Here are a few notes about this Template:
The container images are only downloaded on the first start of a persistent Workspace, since the Podman storage is part of the Workspace's storage.
The PostgreSQL data lives in the
payments-pgdataPodman volume, which also persists across restarts of a persistent Workspace. ThePRE_STOPtask stops the database gracefully before the Workspace stops.The containers count towards the Workspace's CPU, memory and storage limits.
Compose Files
If your repository already has a Compose file for its dependencies, you can run it via podman-compose. Here is the relevant part of a Template for a repository that has a compose.dev.yaml file at its root:
Ports published by the Compose services (e.g. 5432:5432) are reachable at localhost inside the Workspace.
Integration Tests in CI
The same approach works for ephemeral CI Workspaces that run integration tests against real dependencies instead of mocks. With autoStop, the Workspace stops as soon as the tests complete, and the run fails if they fail:
Added to a Workspace of the Template above, the integration-tests task runs after the postgres, redis and migrate tasks, since the Workspace's tasks run after the Template's (read more here):
To build and push container images from Workspaces, read this example.