Skip to content

Commit c41f48e

Browse files
committed
Add Docker containers to help development against local DBs
1 parent 7c005da commit c41f48e

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,15 @@ just test
2424
```
2525

2626
If you don't have `just` installed, you can look in the `justfile` for the commands that are run.
27+
28+
To help with testing on Docker, there's a `docker-compose.yml` file to run PostgreSQL and MySQL in Docker, as well as some additional `just` commands for testing:
29+
30+
```sh
31+
just start-dbs
32+
just test-postgres
33+
just test-mysql
34+
just test-sqlite
35+
36+
# To run all of the above:
37+
just test-dbs
38+
```

docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
services:
2+
postgresql:
3+
image: postgres:16-alpine
4+
environment:
5+
POSTGRES_USER: postgres
6+
POSTGRES_PASSWORD: postgres
7+
ports:
8+
- 15432:5432
9+
10+
mysql:
11+
image: mysql:8.4
12+
environment:
13+
MYSQL_ROOT_PASSWORD: django
14+
MYSQL_DATABASE: django
15+
ports:
16+
- 13306:3306

justfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,18 @@ lint:
1717
python -m ruff check django_tasks tests
1818
python -m ruff format django_tasks tests --check
1919
python -m mypy django_tasks tests
20+
21+
start-dbs:
22+
docker-compose pull
23+
docker-compose up -d
24+
25+
test-sqlite *ARGS:
26+
python -m manage test --shuffle --noinput {{ ARGS }}
27+
28+
test-postgres *ARGS:
29+
DATABASE_URL=postgres://postgres:postgres@localhost:15432/postgres python -m manage test --shuffle --noinput {{ ARGS }}
30+
31+
test-mysql *ARGS:
32+
DATABASE_URL=mysql://root:django@127.0.0.1:13306/django python -m manage test --shuffle --noinput {{ ARGS }}
33+
34+
test-dbs *ARGS: start-dbs test-postgres test-mysql test-sqlite

0 commit comments

Comments
 (0)