rriviere commited on
Commit
d4b25ae
·
unverified ·
2 Parent(s): 826861f82af15e

Merge pull request #4 from RaphaelRIVIERE/feature/cicd

Browse files

Add CI/CD pipeline with GitHub Actions and Hugging Face deployment

Files changed (5) hide show
  1. .dockerignore +13 -0
  2. .github/workflows/ci_cd.yml +40 -0
  3. Dockerfile +13 -0
  4. app/main.py +1 -1
  5. docker-compose.yaml +5 -2
.dockerignore ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ venv/
2
+ .env
3
+ __pycache__/
4
+ *.pyc
5
+ *.pyo
6
+ .pytest_cache/
7
+ htmlcov/
8
+ .coverage
9
+ data/
10
+ *.md
11
+ .git/
12
+ .gitignore
13
+ postgres_data/
.github/workflows/ci_cd.yml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: CI/CD
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Checkout du code
13
+ uses: actions/checkout@v4
14
+
15
+ - name: Configuration Python 3.12
16
+ uses: actions/setup-python@v5
17
+ with:
18
+ python-version: "3.12"
19
+
20
+ - name: Installation des dépendances
21
+ run: pip install -r requirements.txt
22
+
23
+ - name: Exécution des tests
24
+ run: pytest tests/ -v
25
+
26
+ deploy:
27
+ needs: test
28
+ runs-on: ubuntu-latest
29
+ steps:
30
+ - name: Checkout du code
31
+ uses: actions/checkout@v4
32
+
33
+ - name: Déploiement sur Hugging Face
34
+ env:
35
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
36
+ run: |
37
+ git config user.email "action@github.com"
38
+ git config user.name "GitHub Actions"
39
+ git remote add hf https://rriviere:$HF_TOKEN@huggingface.co/spaces/rriviere/attrition-api
40
+ git push hf main --force
Dockerfile ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.12-slim
2
+
3
+ WORKDIR /app
4
+
5
+ COPY requirements.txt .
6
+ RUN pip install --no-cache-dir -r requirements.txt
7
+
8
+ COPY app/ ./app/
9
+ COPY ml_model/ ./ml_model/
10
+
11
+ EXPOSE 7860
12
+
13
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
app/main.py CHANGED
@@ -34,7 +34,7 @@ async def lifespan(app: FastAPI):
34
  app = FastAPI(
35
  title="Futurisys HR Churn API",
36
  description="API de prédiction du risque de départ des employés",
37
- version="0.4.0",
38
  lifespan=lifespan,
39
  )
40
 
 
34
  app = FastAPI(
35
  title="Futurisys HR Churn API",
36
  description="API de prédiction du risque de départ des employés",
37
+ version="0.5.0",
38
  lifespan=lifespan,
39
  )
40
 
docker-compose.yaml CHANGED
@@ -6,7 +6,7 @@ services:
6
  - POSTGRES_USER=postgres
7
  - POSTGRES_PASSWORD=postgres
8
  volumes:
9
- - "./postgres_data:/var/lib/postgresql/data:rw"
10
  ports:
11
  - "5432:5432"
12
  pgadmin:
@@ -15,4 +15,7 @@ services:
15
  - PGADMIN_DEFAULT_EMAIL=admin@admin.com
16
  - PGADMIN_DEFAULT_PASSWORD=root
17
  ports:
18
- - "8080:80"
 
 
 
 
6
  - POSTGRES_USER=postgres
7
  - POSTGRES_PASSWORD=postgres
8
  volumes:
9
+ - postgres_data:/var/lib/postgresql/data:rw
10
  ports:
11
  - "5432:5432"
12
  pgadmin:
 
15
  - PGADMIN_DEFAULT_EMAIL=admin@admin.com
16
  - PGADMIN_DEFAULT_PASSWORD=root
17
  ports:
18
+ - "8080:80"
19
+
20
+ volumes:
21
+ postgres_data: