Skip to content

Commit 1612897

Browse files
Streamlined and added CI steps for docker compose (#2207)
1 parent 3640cc5 commit 1612897

File tree

9 files changed

+61
-19
lines changed

9 files changed

+61
-19
lines changed

.dockerignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copied from .gitignore
2+
__pycache__
3+
data
4+
*.pyc
5+
*.db
6+
locale/*/LC_MESSAGES/django.mo
7+
*/locale/*/LC_MESSAGES/django.mo
8+
.sass-cache/
9+
.coverage
10+
.direnv
11+
.envrc
12+
djangoproject/cache
13+
djangoproject/static/css/*.map
14+
djangoproject/static/css/*.css
15+
# Additional ignores for Docker
16+
.git/

.github/workflows/docker-test-build.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,21 @@ jobs:
2525
- name: Checkout repository
2626
uses: actions/checkout@v4
2727

28-
- name: Test docker image build (local development)
28+
- if: matrix.req_file != 'tests.txt'
29+
name: Test docker image build (${{ matrix.req_file }})
2930
uses: docker/build-push-action@v6
3031
with:
3132
context: .
3233
push: false
3334
build-args: |
3435
REQ_FILE=requirements/${{ matrix.req_file }}
36+
37+
- if: matrix.req_file == 'tests.txt'
38+
name: Set up Docker Compose
39+
uses: docker/setup-compose-action@v1
40+
41+
- if: matrix.req_file == 'tests.txt'
42+
name: Run the tests via Docker
43+
run: |
44+
docker compose build
45+
docker compose run --rm web make ci

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,10 @@ test:
3333

3434
watch-scss:
3535
watchmedo shell-command --patterns=*.scss --recursive --command="make compile-scss-debug" $(SCSS)
36+
37+
reset-local-db:
38+
python -m manage flush --no-input
39+
python -m manage loaddata dev_sites
40+
python -m manage loaddata doc_releases
41+
python -m manage loaddata dashboard_production_metrics
42+
python -m manage update_metrics

README.rst

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,26 @@ Running Locally with Docker
343343

344344
docker compose up
345345

346-
3. View the site at http://localhost:8000/
347-
348-
4. Run the tests::
346+
3. Run the tests::
349347

350348
docker compose run --rm web python -m manage test
351349

350+
4. Load the sample / local dev data::
351+
352+
docker compose run --rm web make reset-local-db
353+
354+
If preferred, refer to the "Install and run locally from a virtual environment"
355+
for more granular management commands to load specific data sets.
356+
357+
5. View the site at http://www.djangoproject.localhost:8000/
358+
or http://dashboard.djangoproject.localhost:8000/.
359+
360+
6. For docs, download the documentation (takes awhile)::
361+
362+
docker compose exec -it web python -m manage update_docs
363+
364+
7. View the docs at http://docs.djangoproject.localhost:8000/.
365+
352366
Pre-commit checks
353367
-----------------
354368

djangoproject/settings/docker.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,3 @@
2424
SECRET_KEY = os.environ.get("SECRET_KEY")
2525

2626
ALLOWED_HOSTS = [".localhost", "127.0.0.1", "www.127.0.0.1"]
27-
28-
LOCALE_MIDDLEWARE_EXCLUDED_HOSTS = ["docs.djangoproject.localhost"]
29-
30-
# django-hosts settings
31-
PARENT_HOST = "djangoproject.localhost:8000"

docker-compose.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,9 @@ services:
4343
timeout: 10s
4444
retries: 10
4545
volumes:
46-
- ./initdb/tracdb.sql:/docker-entrypoint-initdb.d/tracdb.sql
46+
# Mount the Postgres initialization scripts
47+
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
48+
# This file contains the initial Trac database schema, but needs
49+
# to be loaded into the database manually (via 02_trac_schema.sh)
50+
# since it applies to the trac database, not the main Django database.
51+
- ./tracdb/trac.sql:/trac.sql
File renamed without changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
PGPASSWORD=secret psql --username=code.djangoproject --dbname=code.djangoproject < /trac.sql

docker-entrypoint.dev.sh

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
#!/bin/sh
22

3-
python -m manage flush --no-input
4-
PGPASSWORD=secret psql --host db --port 5432 --username=code.djangoproject --dbname=code.djangoproject < tracdb/trac.sql
53
python -m manage migrate
64
make compile-scss # must come before collectstatic
75
python -m manage collectstatic --no-input --clear
8-
python -m manage loaddata dev_sites
9-
python -m manage loaddata doc_releases
10-
# git config --global url."https://".insteadOf git://
11-
# python -m manage update_docs
12-
python -m manage loaddata dashboard_production_metrics
13-
# python -m manage loaddata dashboard_example_data
14-
python -m manage update_metrics
156

167
exec "$@"

0 commit comments

Comments
 (0)