Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Flask_App
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LAMRINI Houda
Flask_App
Commits
b1263dce
Commit
b1263dce
authored
4 months ago
by
LAMRINI Houda
Browse files
Options
Downloads
Patches
Plain Diff
gitlab-ci
parent
5f2e817a
No related branches found
No related tags found
No related merge requests found
Pipeline
#47242
failed
4 months ago
Stage: cleanup
Stage: build
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
.gitlab-ci.yml
+39
-23
39 additions, 23 deletions
.gitlab-ci.yml
with
39 additions
and
23 deletions
.gitlab-ci.yml
+
39
−
23
View file @
b1263dce
image
:
docker:20.10.16
# Version
plus
récente
recommandée
image
:
docker:20.10.16
# Version récente
pour éviter les bugs
services
:
services
:
-
name
:
docker:20.10.16-dind
-
name
:
docker:20.10.16-dind
alias
:
docker
alias
:
docker
command
:
[
"
--tls=false"
]
# Désactiver TLS pour éviter les erreurs
de connexion
command
:
[
"
--tls=false"
]
# Désactiver TLS pour éviter les erreurs
variables
:
variables
:
DOCKER_DRIVER
:
overlay2
DOCKER_DRIVER
:
overlay2
DOCKER_TLS_CERTDIR
:
"
"
# Désactiver
TLS
DOCKER_TLS_CERTDIR
:
"
"
# Désactiver
le TLS (source d'erreur)
DOCKER_HOST
:
"
tcp://
l
oc
alhost
:2375"
DOCKER_HOST
:
"
tcp://
d
oc
ker
:2375"
stages
:
stages
:
-
build_push
-
cleanup
-
build
-
test
-
deploy
Cleanup Unused Docker Images
:
stage
:
cleanup
tags
:
-
docker
script
:
-
docker image prune -f ||
true
# Supprime les anciennes images inutilisées
Build Docker
:
stage
:
build
tags
:
-
docker
before_script
:
before_script
:
-
echo $CI_JOB_TOKEN | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
-
echo $CI_JOB_TOKEN | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
script
:
-
docker build . --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
-
docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
build-push-image
:
Run Tests
:
stage
:
build_push
stage
:
test
tags
:
tags
:
-
docker
-
docker
script
:
script
:
-
docker build . --tag $CI_REGISTRY/my-image:latest
# Lancer les tests ici (exemple : pytest, Jest, etc.)
-
docker push $CI_REGISTRY/my-image:latest
-
echo "Running tests..."
services
:
-
docker run --rm $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME pytest
-
name
:
docker:20.10.16-dind
alias
:
docker
Deploy to Prod
:
command
:
[
"
--tls=false"
]
stage
:
deploy
variables
:
only
:
DOCKER_HOST
:
"
tcp://localhost:2375"
-
main
# Déploiement uniquement sur la branche `main`
DOCKER_TLS_CERTDIR
:
"
"
tags
:
rules
:
-
docker
-
if
:
'
$CI_COMMIT_BRANCH
==
"main"'
before_script
:
before_script
:
-
echo $CI_JOB_TOKEN | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
-
echo $CI_JOB_TOKEN | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
script
:
script
:
-
docker
build . --tag $CI_REGISTRY/my-image:latest
-
docker
pull $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
-
docker
push $CI_REGISTRY/my-image:latest
-
docker
run -d --name my-app -p 8080:80 $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
retry
:
2
# Réessaie deux fois en cas d'échec
-
docker image prune -f ||
true
# Nettoyer les images inutiles
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment