Ajoute les workflows Gitea Actions et l'image du front
- .gitea/workflows/test-build.yaml : construction des images et jobs de tests (back-end : ruff, migrations, pytest ; front : lint, types, tests, build) sur les pull requests - .gitea/workflows/build-and-release.yaml : publication des images sur Harbor à chaque tag - frontend/Dockerfile, nginx.conf, .dockerignore : image du front (nginx sans privilèges sur le port 8080, relais de /api, /admin et /static vers le back-end du pod) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0617fa8dc4
commit
ec729d604f
5 files changed
+197
No files matched your search
@@ -0,0 +1,36 @@
|
|||||||
|
name: Build and release
|
||||||
|
run-name: Build and release ${{ github.ref_name }} (by ${{ gitea.actor }})
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: https://gitea.com/actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
|
- name: Log in to Docker Registry
|
||||||
|
uses: https://gitea.com/docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4
|
||||||
|
with:
|
||||||
|
registry: h3m6q87t.gra7.container-registry.ovh.net
|
||||||
|
username: ${{ vars.OVH_REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.OVH_REGISTRY_PASSWORD }}
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: https://gitea.com/docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4
|
||||||
|
- name: Build and push backend
|
||||||
|
uses: https://gitea.com/docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7
|
||||||
|
with:
|
||||||
|
context: backend
|
||||||
|
pull: true
|
||||||
|
push: true
|
||||||
|
tags: h3m6q87t.gra7.container-registry.ovh.net/prism/backend:${{ github.ref_name }}
|
||||||
|
|
||||||
|
- name: Build and push frontend
|
||||||
|
uses: https://gitea.com/docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7
|
||||||
|
with:
|
||||||
|
context: frontend
|
||||||
|
pull: true
|
||||||
|
push: true
|
||||||
|
tags: h3m6q87t.gra7.container-registry.ovh.net/prism/frontend:${{ github.ref_name }}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
name: Test build
|
||||||
|
run-name: Build ${{ github.ref_name }} (by ${{ gitea.actor }})
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- auto_merge_enabled
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: https://gitea.com/actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
|
- name: Log in to Docker Registry
|
||||||
|
uses: https://gitea.com/docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4
|
||||||
|
with:
|
||||||
|
registry: h3m6q87t.gra7.container-registry.ovh.net
|
||||||
|
username: ${{ vars.OVH_REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.OVH_REGISTRY_PASSWORD }}
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: https://gitea.com/docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4
|
||||||
|
- name: Build backend
|
||||||
|
uses: https://gitea.com/docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7
|
||||||
|
with:
|
||||||
|
context: backend
|
||||||
|
pull: true
|
||||||
|
push: false
|
||||||
|
|
||||||
|
- name: Build frontend
|
||||||
|
uses: https://gitea.com/docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7
|
||||||
|
with:
|
||||||
|
context: frontend
|
||||||
|
pull: true
|
||||||
|
push: false
|
||||||
|
|
||||||
|
backend-tests:
|
||||||
|
name: Back-end (qualité et tests)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
# Base des tests, joignable sous le nom « db ».
|
||||||
|
db:
|
||||||
|
image: postgres:17
|
||||||
|
env:
|
||||||
|
POSTGRES_DB: prism
|
||||||
|
POSTGRES_USER: prism
|
||||||
|
POSTGRES_PASSWORD: prism
|
||||||
|
options: >-
|
||||||
|
--health-cmd "pg_isready -U prism -d prism"
|
||||||
|
--health-interval 5s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 10
|
||||||
|
env:
|
||||||
|
SECRET_KEY: ci-uniquement-pas-un-secret
|
||||||
|
DEBUG: "true"
|
||||||
|
ALLOWED_HOSTS: localhost
|
||||||
|
CSRF_TRUSTED_ORIGINS: http://localhost
|
||||||
|
DATABASE_URL: postgres://prism:prism@db:5432/prism
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: backend
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: https://gitea.com/actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
|
- name: Set up Python
|
||||||
|
uses: https://gitea.com/actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
||||||
|
with:
|
||||||
|
python-version: "3.12"
|
||||||
|
- name: Install uv
|
||||||
|
run: python -m pip install "uv~=0.9"
|
||||||
|
- name: Install dependencies
|
||||||
|
run: uv sync --locked
|
||||||
|
- name: Wait for PostgreSQL
|
||||||
|
run: >-
|
||||||
|
uv run python -c "import socket,time,sys;
|
||||||
|
[(sys.exit(0) if socket.socket().connect_ex(('db',5432))==0 else time.sleep(1)) for _ in range(30)]"
|
||||||
|
- name: Ruff (lint)
|
||||||
|
run: uv run ruff check .
|
||||||
|
- name: Ruff (format)
|
||||||
|
run: uv run ruff format --check .
|
||||||
|
- name: Check migrations are up to date
|
||||||
|
run: uv run python manage.py makemigrations --check --dry-run
|
||||||
|
- name: Tests
|
||||||
|
run: uv run pytest
|
||||||
|
|
||||||
|
frontend-tests:
|
||||||
|
name: Front-end (qualité, tests et build)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: frontend
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: https://gitea.com/actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
|
- name: Set up Node
|
||||||
|
uses: https://gitea.com/actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
- name: Lint
|
||||||
|
run: |
|
||||||
|
npx oxlint .
|
||||||
|
npx eslint .
|
||||||
|
- name: Type check
|
||||||
|
run: npm run type-check
|
||||||
|
- name: Tests
|
||||||
|
run: npm run test:unit -- --run
|
||||||
|
- name: Build
|
||||||
|
run: npm run build-only
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
.eslintcache
|
||||||
|
Dockerfile
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
FROM node:24-alpine AS build
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build-only
|
||||||
|
|
||||||
|
# Sert le front et relaie /api, /admin et /static vers le back-end du même pod (port 8000).
|
||||||
|
FROM nginxinc/nginx-unprivileged:1.27-alpine
|
||||||
|
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
COPY --from=build /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
server {
|
||||||
|
listen 8080;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
# Le back-end tourne dans le même pod que ce conteneur.
|
||||||
|
location ~ ^/(api|admin|static)/ {
|
||||||
|
proxy_pass http://127.0.0.1:8000;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
||||||
|
proxy_read_timeout 60s;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Fichiers versionnés par Vite : cache long.
|
||||||
|
location /assets/ {
|
||||||
|
try_files $uri =404;
|
||||||
|
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Application monopage : toute autre route retombe sur index.html.
|
||||||
|
location / {
|
||||||
|
try_files $uri /index.html;
|
||||||
|
add_header Cache-Control "no-cache";
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user