Skip to content

Commit

Permalink
Switch to dockerfile to avoid pg duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Havenstein committed Oct 30, 2024
1 parent 570b070 commit 0c79c4a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
13 changes: 3 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
---
services:
postgres:
image: "postgres:15"
build:
context: tools/dev_postgres
dockerfile: Dockerfile
container_name: dab_postgres
environment:
POSTGRES_DB: dab_db
POSTGRES_USER: dab
POSTGRES_PASSWORD: dabing
healthcheck:
test: ["CMD", "pg_isready", "-U", "dab", "-d", "dab_db"]
interval: 10s
timeout: 5s
retries: 5
ports:
- "55432:5432"

Expand Down
12 changes: 2 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ legacy_tox_ini = """
-r{toxinidir}/requirements/requirements_all.txt
-r{toxinidir}/requirements/requirements_dev.txt
allowlist_externals = sh
commands = pytest -n auto --cov=. --cov-report=xml:coverage.xml --cov-report=html --cov-report=json --cov-branch --junit-xml=django-ansible-base-test-results.xml {env:ANSIBLE_BASE_PYTEST_ARGS} test_app/tests/test_demo_data.py {posargs}
commands = pytest -n auto --cov=. --cov-report=xml:coverage.xml --cov-report=html --cov-report=json --cov-branch --junit-xml=django-ansible-base-test-results.xml {env:ANSIBLE_BASE_PYTEST_ARGS} {env:ANSIBLE_BASE_TEST_DIRS:test_app/tests} {posargs}
docker = db
[testenv:check]
Expand All @@ -125,15 +125,7 @@ legacy_tox_ini = """
DJANGO_SETTINGS_MODULE = test_app.sqlite3settings
[docker:db]
image = postgres:15
environment =
POSTGRES_PASSWORD=dabing
POSTGRES_USER=dab
POSTGRES_DB=dab_db
healthcheck_cmd = pg_isready -U dab -d dab_db
healthcheck_interval = 10
healthcheck_timeout = 5
healthcheck_retries = 5
dockerfile = {toxinidir}/tools/dev_postgres/Dockerfile
expose =
DB_PORT=5432/tcp
Expand Down
9 changes: 9 additions & 0 deletions tools/dev_postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM postgres:15

ENV POSTGRES_DB=dab_db
ENV POSTGRES_USER=dab
ENV POSTGRES_PASSWORD=dabing

EXPOSE 5432

HEALTHCHECK --interval=10s --timeout=5s --retries=5 CMD ["pg_isready", "-U", "dab", "-d", "dab_db"]

0 comments on commit 0c79c4a

Please sign in to comment.