Skip to content
Snippets Groups Projects
Commit 83aa7434 authored by LAMRINI Houda's avatar LAMRINI Houda
Browse files

gitlab-ci update

parent f072eb8a
No related branches found
No related tags found
No related merge requests found
Pipeline #47248 failed
...@@ -14,7 +14,6 @@ variables: ...@@ -14,7 +14,6 @@ variables:
stages: stages:
- build - build
- test
- deploy - deploy
before_script: before_script:
...@@ -22,23 +21,15 @@ before_script: ...@@ -22,23 +21,15 @@ before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY" - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- echo "Checking Docker availability..." - echo "Checking Docker availability..."
- docker info - docker info
- echo "Setting DNS server to 8.8.8.8"
- echo "nameserver 8.8.8.8" > /etc/resolv.conf
build-push-image: build-push-image:
stage: build stage: build
script: script:
- echo "Building the Docker image..." - echo "Building the Docker image..."
- docker build -t "$CI_REGISTRY_IMAGE:latest" . - docker build -t "$CI_REGISTRY_IMAGE:latest" .
- echo "Pushing the Docker image..." - echo "Pushing the Docker image to the registry..."
- docker push "$CI_REGISTRY_IMAGE:latest" - docker push "$CI_REGISTRY_IMAGE:latest"
test-container:
stage: test
script:
- echo "Running tests..."
- docker run --rm "$CI_REGISTRY_IMAGE:latest" python -m unittest discover tests/
deploy: deploy:
stage: deploy stage: deploy
only: only:
...@@ -46,5 +37,6 @@ deploy: ...@@ -46,5 +37,6 @@ deploy:
script: script:
- echo "Deploying the application..." - echo "Deploying the application..."
- docker pull "$CI_REGISTRY_IMAGE:latest" - docker pull "$CI_REGISTRY_IMAGE:latest"
- docker run -d -p 5000:5000 --name flask_app "$CI_REGISTRY_IMAGE:latest" - docker stop flask_app || true # Arrêter le conteneur existant (si présent)
- docker rm flask_app || true # Supprimer le conteneur existant (si présent)
- docker run -d -p 5000:8000 --name flask_app "$CI_REGISTRY_IMAGE:latest"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment