From 49a1effd87c6159cb9e019ca56e5f57756d52e0b Mon Sep 17 00:00:00 2001 From: chaima <122599773+ChaimaBenOmrane@users.noreply.github.com> Date: Tue, 9 Sep 2025 10:53:28 +0100 Subject: [PATCH 1/6] Create python-app.yml --- .github/workflows/python-app.yml | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/python-app.yml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 0000000..1168bd9 --- /dev/null +++ b/.github/workflows/python-app.yml @@ -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 From e1d5cda74891a9f0727507e7fdd07f891f25b628 Mon Sep 17 00:00:00 2001 From: ChaimaBenOmrane Date: Tue, 9 Sep 2025 11:13:26 +0100 Subject: [PATCH 2/6] v1 --- test_tester.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 test_tester.py diff --git a/test_tester.py b/test_tester.py new file mode 100644 index 0000000..fd96042 --- /dev/null +++ b/test_tester.py @@ -0,0 +1,2 @@ +def tester(): + assert True \ No newline at end of file From 45e327b47a927d0f9025e7bf331a04aa762d53eb Mon Sep 17 00:00:00 2001 From: ChaimaBenOmrane Date: Tue, 9 Sep 2025 11:17:13 +0100 Subject: [PATCH 3/6] test --- test_1.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 test_1.py diff --git a/test_1.py b/test_1.py new file mode 100644 index 0000000..fd96042 --- /dev/null +++ b/test_1.py @@ -0,0 +1,2 @@ +def tester(): + assert True \ No newline at end of file From 41ddfb36ec7070344762a6ff30cbcc063404b70e Mon Sep 17 00:00:00 2001 From: chaima <122599773+ChaimaBenOmrane@users.noreply.github.com> Date: Tue, 9 Sep 2025 11:21:42 +0100 Subject: [PATCH 4/6] Create docker-image.yml --- .github/workflows/docker-image.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..3f53646 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,18 @@ +name: Docker Image CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Build the Docker image + run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) From 2b721f13d3f590186cc0257f03d646a4264bb144 Mon Sep 17 00:00:00 2001 From: chaima <122599773+ChaimaBenOmrane@users.noreply.github.com> Date: Tue, 9 Sep 2025 11:25:59 +0100 Subject: [PATCH 5/6] Update docker-image.yml --- .github/workflows/docker-image.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 3f53646..4837663 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -16,3 +16,9 @@ jobs: - uses: actions/checkout@v4 - name: Build the Docker image run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ chaimabenomrane2001 }} + password: ${{ 14772552 }} From c0d203ca46182aa7cd9d49f308f852365ba56a50 Mon Sep 17 00:00:00 2001 From: ChaimaBenOmrane Date: Tue, 9 Sep 2025 13:04:28 +0100 Subject: [PATCH 6/6] docker --- .github/workflows/docker-image.yml | 32 ++++++++++++++++++++---------- Dockerfile | 25 +++++++++++++++++++++++ 2 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 4837663..6f38465 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,4 +1,4 @@ -name: Docker Image CI +name: Docker Build and Push on: push: @@ -6,19 +6,29 @@ on: pull_request: branches: [ "main" ] -jobs: +permissions: + contents: read +jobs: build: - runs-on: ubuntu-latest - + steps: - - uses: actions/checkout@v4 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) + - name: Checkout code + uses: actions/checkout@v4 - name: Log in to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ chaimabenomrane2001 }} - password: ${{ 14772552 }} + 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 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e5912be --- /dev/null +++ b/Dockerfile @@ -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" \ No newline at end of file