feat: Update CI/CD pipeline to include database update and Docker build/deploy steps #5

This commit is contained in:
Marek Lesko
2025-07-27 16:52:46 +00:00
parent af3b0aefe4
commit e84149bc11

View File

@@ -43,14 +43,38 @@ semantic-release:
only: only:
- main - main
deploy-job: # This job runs in the deploy stage. update_db:
stage: release # It only runs when *both* jobs in the test stage complete successfully. image: mcr.microsoft.com/dotnet/sdk:8.0
script:
- dotnet restore
- dotnet build
- dotnet ef database update --project Api/Api.csproj --startup-project Api/Api.csproj
variables:
ConnectionStrings__DefaultConnection: "Server=db;Database=CentrumDb;User=sa;Password=Your_password123;TrustServerCertificate=True;"
only:
- main
docker-build:
stage: release
image: docker:latest
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay2
script:
- docker build -t centrum-api:latest -f Api/Dockerfile .
- echo "Docker image built: centrum-api:latest"
docker-deploy:
stage: release
image: docker:latest
services:
- docker:dind
environment: production environment: production
tags: tags:
- deployment - deployment
script: script:
- cp -ir Web/dist/Web/browser/* /var/www/html - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- systemctl stop api.service - docker tag centrum-api:latest $CI_REGISTRY_IMAGE:latest
- cp -ir Api/build/* /var/api - docker push $CI_REGISTRY_IMAGE:latest
- systemctl start api.service - echo "Docker image deployed to registry: $CI_REGISTRY_IMAGE:latest"
- echo "Application successfully deployed."