From c4aeedd032c7f854bc0d24e6ede21518f3339e44 Mon Sep 17 00:00:00 2001 From: Mouigni Date: Wed, 12 Aug 2026 00:09:18 +0200 Subject: [PATCH] Restauration : Docker + CI/CD + entrypoint --- .gitea/workflows/build.yml | 33 +++++++++++++++++++++++++++++++++ Dockerfile | 12 ++++++++++++ docker-compose.yml | 18 ++++++++++++++++++ entrypoint.sh | 4 ++++ 4 files changed, 67 insertions(+) create mode 100644 .gitea/workflows/build.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 entrypoint.sh diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..c3b34c8 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,33 @@ +name: Build & Deploy + +on: + push: + branches: [main] + workflow_dispatch: {} + +env: + IMAGE: git.nfteam.ovh/mouigni/regwatch-backend + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Build & push image + run: | + set -e + echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login git.nfteam.ovh -u "${{ secrets.REGISTRY_USER }}" --password-stdin + SHA="${GITHUB_SHA::12}" + docker build -t "${IMAGE}:latest" -t "${IMAGE}:${SHA}" -f Dockerfile . + docker push --all-tags "${IMAGE}" + - name: Notify ntfy + if: always() + run: | + if [ "${{ job.status }}" = "success" ]; then EMOJI="white_check_mark"; PRIO="default"; else EMOJI="rotating_light"; PRIO="high"; fi + curl -s -H "Authorization: Bearer ${{ secrets.NTFY_TOKEN }}" \ + -H "Title: ${GITHUB_REPOSITORY} — ${{ job.status }}" \ + -H "Priority: ${PRIO}" -H "Tags: ${EMOJI}" \ + -H "Click: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions" \ + -d "${GITHUB_WORKFLOW} (${GITHUB_REF_NAME} #${GITHUB_RUN_NUMBER}) : ${{ job.status }}" \ + "${{ secrets.NTFY_URL }}/${{ secrets.NTFY_TOPIC }}" || true \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e3024c2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM python:3.12-slim + +WORKDIR /app + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . +RUN chmod +x entrypoint.sh + +EXPOSE 8000 +CMD ["./entrypoint.sh"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c16daf9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +services: + regwatch-backend: + image: git.nfteam.ovh/mouigni/regwatch-backend:latest + container_name: regwatch-backend + restart: unless-stopped + pull_policy: always + env_file: .env + environment: + - OLLAMA_HOST=http://192.168.1.136:11434 + ports: + - "8114:8000" + labels: + - "com.centurylinklabs.watchtower.enable=true" + - "homepage.group=RegWatch" + - "homepage.name=RegWatch API" + - "homepage.icon=fastapi.png" + - "homepage.href=https://regwatch-api.nfteam.ovh" + - "homepage.description=API veille réglementaire (FastAPI, scrapers CIR/SCCS)" \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..c2406d7 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -e +python -c "from database.models import Base; from database.database import engine; Base.metadata.create_all(bind=engine); print('regwatch: schema OK')" +exec uvicorn api.main:app --host 0.0.0.0 --port 8000