Organize docker tests definition and document

pull/34/head
João Marques 3 years ago
parent dc0b60e63f
commit b46fc70a16

@ -67,6 +67,8 @@ jobs:
- run: poetry install
# Run tests
- run: poetry run pytest
env:
DOCKER_IMAGE_NAME: ${{ env.DOCKER_REPO }}:local
# Build and push
- name: Login to DockerHub
if:

@ -140,6 +140,35 @@ extremely critical but can expose some information that your service does not ne
- `TASKS`
- `VOLUMES`
## Development
All the dependencies you need to develop this project (apart from Docker itself) are
managed with [poetry](https://python-poetry.org/).
To set up your development environment, run:
```
poetry install
```
### Testing
To run the tests locally, you first need to build the image locally:
```
docker build -t docker-socket-proxy:local .
```
You can then run them with:
```
poetry run pytest
```
_Note:_ You can use the docker tag you want, but that is the one that is picked by
default in the tests. If you opt for a different one, set the environment variable
`DOCKER_IMAGE_NAME` to the value you prefer before running the tests.
## Logging
You can set the logging level or severity level of the messages to be logged with the

@ -6,8 +6,7 @@ from logging import info
from plumbum import local
from plumbum.cmd import docker
DOCKER_REPO = os.environ.get("DOCKER_REPO", "docker-socket-proxy")
IMAGE_NAME = f"{DOCKER_REPO}:local"
DOCKER_IMAGE_NAME = os.environ.get("DOCKER_IMAGE_NAME", "docker-socket-proxy:local")
@contextmanager
@ -19,7 +18,7 @@ def proxy(**env_vars):
"""
container_id = None
env_list = [f"--env={key}={value}" for key, value in env_vars.items()]
info(f"Starting {IMAGE_NAME} container with: {env_list}")
info(f"Starting {DOCKER_IMAGE_NAME} container with: {env_list}")
try:
container_id = docker(
"container",
@ -29,7 +28,7 @@ def proxy(**env_vars):
"--publish=2375",
"--volume=/var/run/docker.sock:/var/run/docker.sock",
*env_list,
IMAGE_NAME,
DOCKER_IMAGE_NAME,
).strip()
container_data = json.loads(
docker("container", "inspect", container_id.strip())

Loading…
Cancel
Save