Description
The recent addition of Dockerfile support to build and run container is mentioned as a possible fix for #114 and I wish to understand how this can be used in my use case.
There is an existing tox env that runs the test in the host OS
[testenv:pg{12,13,14,15}-docker-behave-{etcd}-{lin,mac}]
description = Run behaviour tests in patroni-dev docker container
setenv =
etcd: DCS=etcd
pg11: PG_MAJOR = 11
pg12: PG_MAJOR = 12
pg13: PG_MAJOR = 13
pg14: PG_MAJOR = 14
pg15: PG_MAJOR = 15
CONTAINER_NAME = tox-{env_name}-{env:PYTHONHASHSEED}
labels =
behave
depends =
pg{11,12,13,14,15}-docker-build
commands =
docker run \
-v {tox_root}:/src \
-e DCS={env:DCS} \
-e NAME={env:CONTAINER_NAME} \
--name {env:CONTAINER_NAME} \
--rm \
-t \
{env:PATRONI_DEV_IMAGE:patroni-dev:{env:PG_MAJOR}} \
run -x 'tox.env_list=py\{36,37,38,39,310,311\}-behave-{env:DCS}-lin' \
-- --format plain {posargs}
allowlist_externals =
docker
platform =
lin: linux
mac: darwin
I have Dockerfile(s) that contains software/environment setup required to run behaviour tests on different PG versions.
[testenv:pg{12,13,14,15}-docker-build]
description = Build docker containers needed for testing
labels =
behave
setenv =
pg11: PG_MAJOR = 11
pg12: PG_MAJOR = 12
pg13: PG_MAJOR = 13
pg14: PG_MAJOR = 14
pg15: PG_MAJOR = 15
DOCKER_BUILDKIT = 1
commands =
docker build . \
--tag patroni-dev:{env:PG_MAJOR} \
--build-arg PG_MAJOR \
--file features/Dockerfile
allowlist_externals = docker
As far as I can see from the new feature addition, I cannot pass arguments to CMD to the container when it runs. Mainly I would like to pass {posargs}
but also I would need to pass build args.
I am thinking I would put all of the command line requirements into the entrypoint of the Dockerfile and had something like this:
[docker:patroni-dev]
dockerfile: features/Dockerfile
volumes:
- bind:rw:{tox_root}:/src
[testenv:pg{12,13,14,15}-docker-behave-{etcd}]
description = Run behaviour tests in patroni-dev docker container
setenv =
etcd: DCS=etcd
pg11: PG_MAJOR = 11
pg12: PG_MAJOR = 12
pg13: PG_MAJOR = 13
pg14: PG_MAJOR = 14
pg15: PG_MAJOR = 15
labels =
behave
docker = patroni-dev
How do I pass the {posargs}
in? Where do I define build_args? As it stands now do I need a separate Dockerfile or dockerfile_target for different build options? Am I missing something? Perhaps there is another way to achieve this?
Thanks!