Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Docker Build and Push

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ chaimabenomrane2001 }}
password: ${{ dckr_pat_KzQgqOgvAhVlW2nkBFS2-uSUPAw }}

- name: Build Docker image
run: |
docker build -t ChaimaBenOmrane/Python-To-Do-List:${{ github.sha }} .
docker tag ChaimaBenOmrane/Python-To-Do-List:${{ github.sha }} ChaimaBenOmrane/Python-To-Do-List:latest

- name: Push Docker image
run: |
docker push ChaimaBenOmrane/Python-To-Do-List:${{ github.sha }}
docker push ChaimaBenOmrane/Python-To-Do-List:latest
39 changes: 39 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Utiliser une image Python officielle comme base
FROM python:3.11-slim

# Définir le répertoire de travail dans le conteneur
WORKDIR /app

# Copier le fichier Python dans le conteneur
COPY todo.py .

# Créer un utilisateur non-root pour la sécurité
RUN groupadd -r todouser && useradd -r -g todouser todouser

# Changer la propriété du répertoire de travail
RUN chown -R todouser:todouser /app

# Passer à l'utilisateur non-root
USER todouser

# Définir la commande par défaut pour exécuter l'application
CMD ["python", "todo.py"]

# Optionnel: Ajouter des métadonnées
LABEL maintainer="votre-email@example.com"
LABEL version="1.0"
LABEL description="Simple Todo List Application"
2 changes: 2 additions & 0 deletions test_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def tester():
assert True
2 changes: 2 additions & 0 deletions test_tester.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def tester():
assert True