ci: add CD pipeline with Docker Hub push on pre-prod
This commit is contained in:
@@ -2,13 +2,13 @@ name: Backend - Build & Lint
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [pre-prod]
|
||||||
paths:
|
paths:
|
||||||
- "backend/**/**"
|
- "backend/**"
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [pre-prod]
|
||||||
paths:
|
paths:
|
||||||
- "backend/**/**"
|
- "backend/**"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
@@ -54,9 +54,40 @@ jobs:
|
|||||||
working-directory: backend/gestion
|
working-directory: backend/gestion
|
||||||
run: go build -v ./...
|
run: go build -v ./...
|
||||||
|
|
||||||
- name: Upload binary
|
docker:
|
||||||
uses: actions/upload-artifact@v4
|
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:
|
with:
|
||||||
name: backend-binary
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
path: backend/gestion/gestion
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
retention-days: 7
|
|
||||||
|
- 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
|
||||||
|
|||||||
@@ -2,13 +2,15 @@ name: Frontend Web - Build & Lint
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [pre-prod]
|
||||||
paths:
|
paths:
|
||||||
- "frontend-prep/**"
|
- "frontend-prep/**"
|
||||||
|
- "docker/frontend/**"
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [pre-prod]
|
||||||
paths:
|
paths:
|
||||||
- "frontend-prep/**"
|
- "frontend-prep/**"
|
||||||
|
- "docker/frontend/**"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint-typecheck:
|
lint-typecheck:
|
||||||
@@ -62,9 +64,31 @@ jobs:
|
|||||||
VITE_TOMTOM_API_KEY: ${{ secrets.VITE_TOMTOM_API_KEY }}
|
VITE_TOMTOM_API_KEY: ${{ secrets.VITE_TOMTOM_API_KEY }}
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
- name: Upload dist artifact
|
docker:
|
||||||
uses: actions/upload-artifact@v4
|
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:
|
with:
|
||||||
name: frontend-web-dist
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
path: frontend-prep/dist
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
retention-days: 7
|
|
||||||
|
- 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 }}
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
services:
|
services:
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Backend Go
|
# Backend Go
|
||||||
# =========================================================
|
# =========================================================
|
||||||
backend:
|
backend:
|
||||||
build:
|
image: xor1234/backend-mln:latest
|
||||||
context: ..
|
|
||||||
dockerfile: docker/backend/Dockerfile
|
|
||||||
target: runtime
|
|
||||||
container_name: gestion-backend
|
container_name: gestion-backend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
@@ -44,9 +40,7 @@ services:
|
|||||||
# Frontend Web (React/Vite — servi en HTTP interne)
|
# Frontend Web (React/Vite — servi en HTTP interne)
|
||||||
# =========================================================
|
# =========================================================
|
||||||
frontend:
|
frontend:
|
||||||
build:
|
image: xor1234/frontend-mln:latest
|
||||||
context: ..
|
|
||||||
dockerfile: docker/frontend/Dockerfile
|
|
||||||
container_name: gestion-frontend
|
container_name: gestion-frontend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
@@ -54,16 +48,8 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- 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:
|
waf:
|
||||||
build:
|
image: xor1234/backend-mln:waf
|
||||||
context: ..
|
|
||||||
dockerfile: docker/backend/Dockerfile
|
|
||||||
target: waf
|
|
||||||
container_name: gestion-waf
|
container_name: gestion-waf
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
@@ -143,6 +129,15 @@ services:
|
|||||||
retries: 5
|
retries: 5
|
||||||
start_period: 10s
|
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:
|
networks:
|
||||||
gestion-network:
|
gestion-network:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|||||||
Reference in New Issue
Block a user