Skip to content

Instantly share code, notes, and snippets.

@jafar260698
Created April 16, 2024 14:48
Show Gist options
  • Save jafar260698/8c8ba21883871a0942637b8defcfed68 to your computer and use it in GitHub Desktop.
Save jafar260698/8c8ba21883871a0942637b8defcfed68 to your computer and use it in GitHub Desktop.
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