feat: Update CI/CD pipeline to include database update and Docker build/deploy steps #5
This commit is contained in:
@@ -43,14 +43,38 @@ semantic-release:
|
||||
only:
|
||||
- main
|
||||
|
||||
deploy-job: # This job runs in the deploy stage.
|
||||
stage: release # It only runs when *both* jobs in the test stage complete successfully.
|
||||
update_db:
|
||||
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
|
||||
tags:
|
||||
- deployment
|
||||
script:
|
||||
- cp -ir Web/dist/Web/browser/* /var/www/html
|
||||
- systemctl stop api.service
|
||||
- cp -ir Api/build/* /var/api
|
||||
- systemctl start api.service
|
||||
- echo "Application successfully deployed."
|
||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||
- docker tag centrum-api:latest $CI_REGISTRY_IMAGE:latest
|
||||
- docker push $CI_REGISTRY_IMAGE:latest
|
||||
- echo "Docker image deployed to registry: $CI_REGISTRY_IMAGE:latest"
|
||||
|
||||
Reference in New Issue
Block a user