ci: add CD pipeline with Docker Hub push on pre-prod

This commit is contained in:
2026-05-02 17:58:09 +02:00
parent ece977f268
commit a9d8fb5297
3 changed files with 83 additions and 33 deletions
+40 -9
View File
@@ -2,13 +2,13 @@ name: Backend - Build & Lint
on:
push:
branches: [main]
branches: [pre-prod]
paths:
- "backend/**/**"
- "backend/**"
pull_request:
branches: [main]
branches: [pre-prod]
paths:
- "backend/**/**"
- "backend/**"
jobs:
lint:
@@ -54,9 +54,40 @@ jobs:
working-directory: backend/gestion
run: go build -v ./...
- name: Upload binary
uses: actions/upload-artifact@v4
docker:
name: Docker Build & Push
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/pre-prod'
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
name: backend-binary
path: backend/gestion/gestion
retention-days: 7
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build & push backend (runtime)
uses: docker/build-push-action@v6
with:
context: .
file: docker/backend/Dockerfile
target: runtime
push: true
tags: |
xor1234/backend-mln:latest
- name: Build & push WAF
uses: docker/build-push-action@v6
with:
context: .
file: docker/backend/Dockerfile
target: waf
push: true
tags: |
xor1234/backend-mln:waf
+31 -7
View File
@@ -2,13 +2,15 @@ name: Frontend Web - Build & Lint
on:
push:
branches: [main]
branches: [pre-prod]
paths:
- "frontend-prep/**"
- "docker/frontend/**"
pull_request:
branches: [main]
branches: [pre-prod]
paths:
- "frontend-prep/**"
- "docker/frontend/**"
jobs:
lint-typecheck:
@@ -62,9 +64,31 @@ jobs:
VITE_TOMTOM_API_KEY: ${{ secrets.VITE_TOMTOM_API_KEY }}
run: npm run build
- name: Upload dist artifact
uses: actions/upload-artifact@v4
docker:
name: Docker Build & Push
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/pre-prod'
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
name: frontend-web-dist
path: frontend-prep/dist
retention-days: 7
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build & push frontend
uses: docker/build-push-action@v6
with:
context: .
file: docker/frontend/Dockerfile
push: true
tags: |
xor1234/frontend-mln:latest
build-args: |
VITE_TOMTOM_API_KEY=${{ secrets.VITE_TOMTOM_API_KEY }}
+12 -17
View File
@@ -1,13 +1,9 @@
services:
# =========================================================
# Backend Go
# =========================================================
backend:
build:
context: ..
dockerfile: docker/backend/Dockerfile
target: runtime
image: xor1234/backend-mln:latest
container_name: gestion-backend
restart: unless-stopped
environment:
@@ -44,9 +40,7 @@ services:
# Frontend Web (React/Vite — servi en HTTP interne)
# =========================================================
frontend:
build:
context: ..
dockerfile: docker/frontend/Dockerfile
image: xor1234/frontend-mln:latest
container_name: gestion-frontend
restart: unless-stopped
networks:
@@ -54,16 +48,8 @@ services:
depends_on:
- backend
# =========================================================
# WAF (Nginx + ModSecurity) — point d'entrée public
# Les certificats fullchain.pem + privkey.pem doivent être
# placés dans ./certs/ à côté de ce fichier avant le deploy.
# =========================================================
waf:
build:
context: ..
dockerfile: docker/backend/Dockerfile
target: waf
image: xor1234/backend-mln:waf
container_name: gestion-waf
restart: unless-stopped
environment:
@@ -143,6 +129,15 @@ services:
retries: 5
start_period: 10s
dozzle-agent:
image: amir20/dozzle:latest
command: agent
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
ports:
- "7007:7007"
restart: unless-stopped
networks:
gestion-network:
driver: bridge