Skip to content

Commit 3d77e0f

Browse files
fabienheureuxkolok
andauthored
🚦 Mise en place de nginx en local (#1321)
* Add nginx and dual domain setup * fix merge conflict * fix precommit issue * Make nginx work * Test things * ??? * ??? * More dynamic playwright approach * wip * Add nginx * a single url... * Fix a test * deprecate legacy urls * wip * Run all test suite * wip * fix unit tests * Remove useless test * hum hum * oopsy * oopsy * oopsy * Disable test for now * Presque fini * Rename url in header html * rename context processsor --------- Co-authored-by: Nicolas Oudard <nicolas@oudard.org>
1 parent f87d4d1 commit 3d77e0f

34 files changed

+377
-292
lines changed

.env.template

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
AIRFLOW_CONN_QFDMO_DJANGO_DB=postgresql+psycopg2://qfdmo:qfdmo@localhost:6543/qfdmo
2-
AIRFLOW_WEBSERVER_REFRESHACTEUR_URL=http://localhost:8080
3-
ALLOWED_HOSTS=localhost,127.0.0.1
2+
AIRFLOW_WEBSERVER_REFRESHACTEUR_URL=https://lvao.ademe.local
43
AWS_ACCESS_KEY_ID=
54
AWS_S3_ENDPOINT_URL='https://s3.fr-par.scw.cloud'
65
AWS_S3_REGION_NAME='fr-par'
76
AWS_SECRET_ACCESS_KEY=
87
AWS_STORAGE_BUCKET_NAME='qfdmo-interface'
9-
BASE_URL=http://localhost:8000
10-
CMS_BASE_URL=https://longuevieauxobjets.ademe.fr
118
CARTE_MAX_SOLUTION_DISPLAYED=10
129
CONN_MAX_AGE=0
13-
CORS_ALLOWED_ORIGINS=http://localhost:8000,http://127.0.0.1:8000
1410
DATABASE_URL=postgis://qfdmo:qfdmo@localhost:6543/qfdmo
1511
DB_READONLY=postgis://qfdmo:qfdmo@localhost:6543/qfdmo
1612
DEBUG=True
@@ -26,8 +22,11 @@ STIMULUS_DEBUG=false
2622
POSTHOG_DEBUG=false
2723
ASSISTANT_MATOMO_ID=82
2824
ASSISTANT_POSTHOG_KEY=phc_fSfhoWDOUxZdKWty16Z3XfRiAoWd1qdJK0N0z9kQHJr # [DEV] project
29-
ASSISTANT_HOSTS=localhost:8000
30-
ASSISTANT_BASE_URL=http://localhost:8000
3125
NOTION_TOKEN=
3226
NOTION_CONTACT_FORM_DATABASE_ID=17c6523d57d78140b87f000cd3ecef4b # Correspond à https://www.notion.so/accelerateur-transition-ecologique-ademe/17c6523d57d7808b8cc5f5ccae264f7c?v=17c6523d57d78140b87f000cd3ecef4b&pvs=4
33-
DATA_UPLOAD_MAX_NUMBER_FIELDS=10000
27+
DATA_UPLOAD_MAX_NUMBER_FIELDS=10000
28+
29+
BASE_URL=https://quefairedemesdechets.ademe.local
30+
CMS_BASE_URL=https://longuevieauxobjets.ademe.fr
31+
ASSISTANT_HOSTS=quefairedemesdechets.ademe.local
32+
ALLOWED_HOSTS=lvao.ademe.local,quefairedemesdechets.ademe.local

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: "Intégration continue"
22

33
on:
44
pull_request:
5+
types: [labeled, opened, synchronize]
56
workflow_dispatch:
67

78
defaults:

.github/workflows/run_tests.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ jobs:
7777

7878
e2e:
7979
runs-on: ubuntu-latest
80+
if: contains(join(github.event.pull_request.labels.*.name, ','), 'frontend')
8081
strategy:
8182
matrix:
8283
shard: [1/5, 2/5, 3/5, 4/5, 5/5]
@@ -96,6 +97,14 @@ jobs:
9697
- 6543:5432
9798
steps:
9899
- uses: actions/checkout@v4
100+
101+
- name: Prepare environment
102+
run: |
103+
cp .env.template .env
104+
echo BASE_URL=http://localhost:8000 >> .env
105+
echo ALLOWED_HOSTS=localhost >> .env
106+
echo ASSISTANT_HOSTS=localhost >> .env
107+
99108
- uses: actions/setup-node@v4
100109
with:
101110
node-version-file: ".tool-versions"
@@ -125,9 +134,6 @@ jobs:
125134
- name: Install the project dependencies
126135
run: poetry sync --with dev --no-root
127136

128-
- name: Set env variables
129-
run: cp .env.template .env
130-
131137
- name: Migrate database
132138
run: |
133139
poetry run python manage.py createcachetable
@@ -146,10 +152,3 @@ jobs:
146152

147153
- name: Run Playwright tests
148154
run: npx playwright test --reporter=list --update-snapshots --shard=${{ matrix.shard }}
149-
150-
- uses: actions/upload-artifact@v4
151-
if: always()
152-
with:
153-
name: playwright-report
154-
path: playwright-report/
155-
retention-days: 30

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ media
3535

3636
_build
3737
.obsidian
38+
*.pem

.secrets.baseline

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
"filename": "core/settings.py",
139139
"hashed_secret": "1ee34e26aeaf89c64ecc2c85efe6a961b75a50e9",
140140
"is_verified": false,
141-
"line_number": 218
141+
"line_number": 275
142142
}
143143
],
144144
"dbt/package-lock.yml": [
@@ -156,7 +156,7 @@
156156
"filename": "docker-compose.yml",
157157
"hashed_secret": "3cf2012487b086bba2adb3386d69c2ab67a268b6",
158158
"is_verified": false,
159-
"line_number": 55
159+
"line_number": 60
160160
}
161161
],
162162
"iframe_without_js.html": [
@@ -187,5 +187,5 @@
187187
}
188188
]
189189
},
190-
"generated_at": "2025-04-16T15:04:57Z"
190+
"generated_at": "2025-04-22T10:11:19Z"
191191
}

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ PYTHON := poetry run python
99
DJANGO_ADMIN := $(PYTHON) manage.py
1010
PYTEST := poetry run pytest
1111
DB_URL := postgres://qfdmo:qfdmo@localhost:6543/qfdmo# pragma: allowlist secret
12+
ASSISTANT_URL := quefairedemesdechets.ademe.local
13+
LVAO_URL := lvao.ademe.local
1214

1315
# Makefile config
1416
.PHONY: check
@@ -17,6 +19,10 @@ check:
1719
@npm --version
1820
@node --version
1921

22+
.PHONY: init-certs
23+
init-certs:
24+
docker run -ti -v ./nginx-local-only/certs:/app/certs -w /app/certs --rm alpine/mkcert $(LVAO_URL) $(ASSISTANT_URL)
25+
2026

2127
.PHONY: init-dev
2228
init-dev:
@@ -26,6 +32,7 @@ init-dev:
2632
# python
2733
curl -sSL https://install.python-poetry.org | python3 -
2834
poetry install --with dev,airflow
35+
make init-certs
2936
# javascript
3037
npm install
3138
npx playwright install --with-deps
@@ -50,7 +57,6 @@ run-airflow:
5057

5158
.PHONY: run-django
5259
run-django:
53-
docker compose --profile lvao up -d
5460
rm -rf .parcel-cache
5561
honcho start -f Procfile.dev
5662

@@ -100,7 +106,7 @@ unit-test:
100106

101107
.PHONY: e2e-test
102108
e2e-test:
103-
npx playwright test
109+
npx playwright test --ui
104110
$(PYTEST) ./integration_tests
105111

106112
.PHONY: a11y

core/context_processors.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,24 @@ def content(request):
2424
return vars(constants)
2525

2626

27-
def assistant(request) -> dict:
28-
if request.META.get("HTTP_HOST") not in settings.ASSISTANT["HOSTS"]:
29-
return {}
30-
31-
return {
27+
def global_context(request) -> dict:
28+
base = {
3229
"assistant": {
3330
"is_home": request.path == reverse("home"),
3431
"is_iframe": request.COOKIES.get("iframe") == "1"
3532
or "iframe" in request.GET,
3633
"POSTHOG_KEY": settings.ASSISTANT["POSTHOG_KEY"],
3734
"MATOMO_ID": settings.ASSISTANT["MATOMO_ID"],
35+
"BASE_URL": settings.ASSISTANT["BASE_URL"],
3836
},
37+
"lvao": {"BASE_URL": settings.ASSISTANT["BASE_URL"]},
38+
}
39+
40+
if request.META.get("HTTP_HOST") not in settings.ASSISTANT["HOSTS"]:
41+
return base
42+
43+
return {
44+
**base,
3945
"footer_pages": CMSPage.objects.all(),
4046
"search_form": SearchForm(),
4147
"search_view_template_name": SEARCH_VIEW_TEMPLATE_NAME,

0 commit comments

Comments
 (0)