Skip to content

Add feature to declare sidecar containers for tests and development #63

Open
@NiklasRosenstein

Description

@NiklasRosenstein

Sidecar containers are often required for testing, such as having a Postgres database available while running integration tests. These containers should be configurable in a Kraken build script, and it should be possible to start these containers directly and also have them start for tests.

In the build script, an example container definition may be:

from kraken.std.devenv import sidecar_container

sidecar_container(
  name="postgres",
  image="postgres:latest",
  ports=["5432:5432"],
  env={"POSTGRES_PASSWORD": "alpine"},
)

This should produce two targets, :postgres.start and :postgres.run. The :postgres.start task starts up the container in the background. The :postgres.run command is intended to be used on the CLI to wait for the container to complete or to cancel it when the task is interrupted.

For tests, the :postgres.start command would simply need to be a dependency on the task that runs the tests. It being a background task, the Postgers container will stay alive until the tests have completed.

Metadata

Metadata

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions