-
Notifications
You must be signed in to change notification settings - Fork 598
♻️ (deploy) harmonize prod deployment layout under deploy/ #2425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| web: bin/buildpack_start.sh | ||
| web: deploy/paas/buildpack_start.sh | ||
| postdeploy: python manage.py migrate |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Docs — Docker Compose deployment | ||
|
|
||
| Prod-oriented Docker Compose layout for [Docs](https://github.com/suitenumerique/docs). | ||
|
|
||
| > The root `compose.yml` of the repository is the **development** stack. Use the files in this folder to deploy Docs in production. | ||
|
|
||
| ## Layout | ||
|
|
||
| ``` | ||
| deploy/docker/ | ||
| ├── compose.yml # Main production compose file | ||
| ├── env.d/ # (you provide) postgres / backend / yprovider / common env files | ||
| └── examples/ | ||
| ├── keycloak/ # Sample OIDC provider | ||
| ├── minio/ # Sample S3-compatible object storage | ||
| └── nginx-proxy/ # Sample reverse proxy with Let's Encrypt | ||
| ``` | ||
|
|
||
| ## Getting started | ||
|
|
||
| See the [installation walkthrough](../../docs/installation/compose.md) — it covers env files, OIDC, S3, Postgres, Redis, mail and reverse-proxy setup end to end. | ||
|
|
||
| Quick setup: | ||
|
|
||
| ```bash | ||
| mkdir -p docs/env.d && cd docs | ||
|
|
||
| # Fetch the compose file and example env files | ||
| curl -o compose.yml https://raw.githubusercontent.com/suitenumerique/docs/refs/heads/main/deploy/docker/compose.yml | ||
| curl -o env.d/common https://raw.githubusercontent.com/suitenumerique/docs/refs/heads/main/env.d/production.dist/common | ||
| curl -o env.d/backend https://raw.githubusercontent.com/suitenumerique/docs/refs/heads/main/env.d/production.dist/backend | ||
| curl -o env.d/yprovider https://raw.githubusercontent.com/suitenumerique/docs/refs/heads/main/env.d/production.dist/yprovider | ||
| curl -o env.d/postgresql https://raw.githubusercontent.com/suitenumerique/docs/refs/heads/main/env.d/production.dist/postgresql | ||
|
|
||
| # Pin to a tagged release before going to production | ||
| docker compose up -d | ||
| docker compose run --rm backend python manage.py migrate | ||
| ``` | ||
|
|
||
| ## Other deployments | ||
|
|
||
| * Kubernetes/Helm: see [`deploy/kubernetes/`](../kubernetes/). | ||
| * PaaS (Scalingo, Clever Cloud, …): see [`deploy/paas/`](../paas/). | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,7 +9,7 @@ | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||
| mkdir keycloak | ||||||||||||||||||||||
| curl -o keycloak/compose.yaml https://raw.githubusercontent.com/suitenumerique/docs/refs/heads/main/docs/examples/compose/keycloak/compose.yaml | ||||||||||||||||||||||
| curl -o keycloak/compose.yaml https://raw.githubusercontent.com/suitenumerique/docs/refs/heads/main/deploy/docker/examples/keycloak/compose.yaml | ||||||||||||||||||||||
| curl -o keycloak/env.d/kc_postgresql https://raw.githubusercontent.com/suitenumerique/docs/refs/heads/main/env.d/production.dist/kc_postgresql | ||||||||||||||||||||||
| curl -o keycloak/env.d/keycloak https://raw.githubusercontent.com/suitenumerique/docs/refs/heads/main/env.d/production.dist/keycloak | ||||||||||||||||||||||
|
Comment on lines
10
to
14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create Step 1 only creates Suggested change-mkdir keycloak
+mkdir -p keycloak/env.d
curl -o keycloak/compose.yaml https://raw.githubusercontent.com/suitenumerique/docs/refs/heads/main/deploy/docker/examples/keycloak/compose.yaml
curl -o keycloak/env.d/kc_postgresql https://raw.githubusercontent.com/suitenumerique/docs/refs/heads/main/env.d/production.dist/kc_postgresql
curl -o keycloak/env.d/keycloak https://raw.githubusercontent.com/suitenumerique/docs/refs/heads/main/env.d/production.dist/keycloak📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| ``` | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Docs — PaaS deployment | ||
|
|
||
| Buildpack scripts and nginx template for deploying [Docs](https://github.com/suitenumerique/docs) on a PaaS (Scalingo, Clever Cloud, …). | ||
|
|
||
| ## Layout | ||
|
|
||
| ``` | ||
| deploy/paas/ | ||
| ├── buildpack_postcompile.sh # Build-time: cleanup unused files to reduce slug size | ||
| ├── buildpack_postfrontend.sh # Build-time: assemble frontend/backend/nginx into slug | ||
| ├── buildpack_start.sh # Runtime: starts uvicorn + y-provider + nginx | ||
| └── servers.conf.erb # Nginx routing template (ERB → consumed by buildpack) | ||
| ``` | ||
|
Comment on lines
+7
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a language tag to the layout fence. The bare fenced block trips markdownlint (MD040). Suggested fix-```
+```text
deploy/paas/
├── buildpack_postcompile.sh # Build-time: cleanup unused files to reduce slug size
├── buildpack_postfrontend.sh # Build-time: assemble frontend/backend/nginx into slug
├── buildpack_start.sh # Runtime: starts uvicorn + y-provider + nginx
└── servers.conf.erb # Nginx routing template (ERB → consumed by buildpack)
-```
+```🧰 Tools🪛 markdownlint-cli2 (0.22.1)[warning] 7-7: Fenced code blocks should have a language specified (MD040, fenced-code-language) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
|
|
||
| The root `Procfile` references `deploy/paas/buildpack_start.sh` for the `web` process. | ||
|
|
||
| ## Getting started | ||
|
|
||
| See the [Scalingo walkthrough](../../docs/installation/scalingo.md) — it covers the full env-var setup (buildpack URL, OIDC, S3, theme customization, etc.). | ||
|
|
||
| The two build-time hooks are wired via the [La Suite buildpack](https://github.com/suitenumerique/buildpack) env vars: | ||
|
|
||
| ```bash | ||
| scalingo env-set LASUITE_SCRIPT_POSTCOMPILE="deploy/paas/buildpack_postcompile.sh" | ||
| scalingo env-set LASUITE_SCRIPT_POSTFRONTEND="deploy/paas/buildpack_postfrontend.sh" | ||
| ``` | ||
|
|
||
| ## Other deployments | ||
|
|
||
| * Docker Compose: see [`deploy/docker/`](../docker/). | ||
| * Kubernetes/Helm: see [`deploy/kubernetes/`](../kubernetes/). | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3102,6 +3102,25 @@ def get(self, request): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return drf.response.Response(dict_settings) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _load_theme_customization(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if settings.THEME_CUSTOMIZATION_JSON: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cache_key = "theme_customization_env" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| theme_customization = cache.get(cache_key, {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if theme_customization: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return theme_customization | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| theme_customization = json.loads(settings.THEME_CUSTOMIZATION_JSON) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| except json.JSONDecodeError: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logger.error("THEME_CUSTOMIZATION_JSON is not a valid JSON") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cache.set( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cache_key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| theme_customization, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| settings.THEME_CUSTOMIZATION_CACHE_TIMEOUT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+3106
to
+3121
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cache key does not vary with env value, causing stale theme after config changes. Line 3106 uses a fixed key ( 💡 Suggested fix+import hashlib
...
- cache_key = "theme_customization_env"
+ theme_json = settings.THEME_CUSTOMIZATION_JSON
+ cache_key = f"theme_customization_env_{hashlib.sha256(theme_json.encode()).hexdigest()}"
theme_customization = cache.get(cache_key, {})🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return theme_customization | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+3111
to
+3123
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validate that At Line 3112, 💡 Suggested fix try:
theme_customization = json.loads(settings.THEME_CUSTOMIZATION_JSON)
except json.JSONDecodeError:
logger.error("THEME_CUSTOMIZATION_JSON is not a valid JSON")
return {}
+ if not isinstance(theme_customization, dict):
+ logger.error("THEME_CUSTOMIZATION_JSON must decode to a JSON object")
+ return {}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if not settings.THEME_CUSTOMIZATION_FILE_PATH: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: suitenumerique/docs
Length of output: 839
Fix broken compose download URLs (404s).
In
deploy/docker/README.md(lines 25-33), theraw.githubusercontent.com/.../refs/heads/main/...URL format works forenv.d/production.dist/*(200), but the compose files return 404, so the bootstrap will fail:deploy/docker/compose.yml-> 404deploy/docker/examples/keycloak/compose.yaml-> 404deploy/docker/examples/minio/compose.yaml-> 404Update the paths/filenames (or branch) for those compose artifacts.
🤖 Prompt for AI Agents