Created
April 16, 2024 14:48
-
-
Save jafar260698/8c8ba21883871a0942637b8defcfed68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- build | |
- deploy | |
build-dev: | |
stage: build | |
only: | |
- dev | |
tags: | |
- dev-app-backend | |
script: | |
- docker build --no-cache --rm -t app_backend:$CI_PIPELINE_IID . | |
- docker tag app_backend:$CI_PIPELINE_IID app_backend:latest | |
deploy-dev: | |
stage: deploy | |
only: | |
- dev | |
tags: | |
- dev-app-backend | |
script: | |
- docker service update --with-registry-auth --image app_backend:$CI_PIPELINE_IID app_backend | |
- sleep 10 # Wait for the service to stabilize | |
- CONTAINER_ID=$(docker ps | grep app_backend | head -n 1 | awk '{print $1}') | |
- if [ ! -z "$CONTAINER_ID" ]; then | |
docker exec -t -w /var/www/html $CONTAINER_ID composer install --ignore-platform-reqs; | |
docker exec -t -w /var/www/html $CONTAINER_ID php artisan migrate; | |
docker exec -t -w /var/www/html $CONTAINER_ID php artisan cache:clear; | |
docker exec -t -w /var/www/html $CONTAINER_ID php artisan config:clear; | |
docker exec -t -w /var/www/html $CONTAINER_ID php artisan route:clear; | |
if [ ! -z "$DB_SEED" ]; then | |
docker exec -t -w /var/www/html $CONTAINER_ID php artisan db:seed; | |
fi | |
else | |
echo "No running container found for the service"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment