
This uses the `docker compose run --rm` approach suggested by Dudo [here](https://github.com/orgs/gitops-ci-cd/discussions/1). I'm...still learning my around it. It has some learning curve - especially regarding running integration tests (the current setup _keeps_ the app running even after tests have terminated, which is probably not as-desired), but I suspect it'll become second-nature pretty quickly and will have outsized benefits when working in a team with heterogeneous workstation setups.
47 lines
1.1 KiB
YAML
47 lines
1.1 KiB
YAML
services:
|
|
base: &base
|
|
tty: true
|
|
stdin_open: true
|
|
# Necessary because compose does not permit a service to lack a build
|
|
build:
|
|
context: .
|
|
target: deps
|
|
entrypoint: python
|
|
volumes:
|
|
- .:/usr/src/app:delegated
|
|
|
|
app:
|
|
build:
|
|
context: .
|
|
target: app
|
|
environment:
|
|
- DOWNLOAD_DIR=/download
|
|
ports:
|
|
- "8000:8000"
|
|
volumes:
|
|
- ./download_dir:/download
|
|
|
|
test-base: &test-base
|
|
<<: *base
|
|
build:
|
|
context: .
|
|
target: test
|
|
|
|
test:
|
|
<<: *test-base
|
|
command: ["-m", "pytest", "--ignore=integ-tests", "."]
|
|
|
|
test-with-output:
|
|
<<: *test-base
|
|
command: ["-m", "pytest", "-rP", "--ignore=integ-tests", "."]
|
|
|
|
test-integ:
|
|
<<: *test-base
|
|
depends_on:
|
|
# TODO - should really have a healthcheck here to avoid race-conditions. "Up" doesn't actually mean "Up and accepting requests"
|
|
- app
|
|
command: ["-m", "pytest", "integ-tests" ]
|
|
volumes:
|
|
- ./download_dir:/download
|
|
- .:/usr/src/app:delegated # Have to re-specify this because the specification above overrides, rather than appending
|