Skip to content

Commit

Permalink
Add Docker containers to help development against local DBs
Browse files Browse the repository at this point in the history
  • Loading branch information
RealOrangeOne committed Jul 10, 2024
1 parent 7c005da commit c41f48e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,15 @@ just test
```

If you don't have `just` installed, you can look in the `justfile` for the commands that are run.

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:

```sh
just start-dbs
just test-postgres
just test-mysql
just test-sqlite

# To run all of the above:
just test-dbs
```
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
services:
postgresql:
image: postgres:16-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 15432:5432

mysql:
image: mysql:8.4
environment:
MYSQL_ROOT_PASSWORD: django
MYSQL_DATABASE: django
ports:
- 13306:3306
15 changes: 15 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,18 @@ lint:
python -m ruff check django_tasks tests
python -m ruff format django_tasks tests --check
python -m mypy django_tasks tests

start-dbs:
docker-compose pull
docker-compose up -d

test-sqlite *ARGS:
python -m manage test --shuffle --noinput {{ ARGS }}

test-postgres *ARGS:
DATABASE_URL=postgres://postgres:postgres@localhost:15432/postgres python -m manage test --shuffle --noinput {{ ARGS }}

test-mysql *ARGS:
DATABASE_URL=mysql://root:django@127.0.0.1:13306/django python -m manage test --shuffle --noinput {{ ARGS }}

test-dbs *ARGS: start-dbs test-postgres test-mysql test-sqlite

0 comments on commit c41f48e

Please sign in to comment.