Update azure-pipelines.yml for Azure Pipelines
This commit is contained in:
parent
0c37b87d43
commit
7365fb08d3
@ -1,35 +1,74 @@
|
||||
trigger:
|
||||
- docker-branch
|
||||
- docker-branch # Trigger the pipeline on pushes to the main branch. Adjust the branch name as needed.
|
||||
|
||||
pr:
|
||||
- '*' # Include pull requests.
|
||||
|
||||
pool:
|
||||
vmImage: 'ubuntu-latest'
|
||||
vmImage: 'ubuntu-latest' # Use the latest Ubuntu image.
|
||||
|
||||
stages:
|
||||
- stage: Checkout
|
||||
jobs:
|
||||
- job: CheckoutJob
|
||||
variables:
|
||||
DOCKER_IMAGE_ANSWERS: 'santhoshsnair/answers-api'
|
||||
DOCKER_IMAGE_ATTACHMENTS: 'anthoshsnair/attachments-api'
|
||||
DOCKER_IMAGE_EMPLOYEES: 'anthoshsnair/employee-api'
|
||||
DOCKER_IMAGE_LOCATIONS: 'anthoshsnair/locations-api'
|
||||
DOCKER_IMAGE_QUESTIONS: 'anthoshsnair/questions-api'
|
||||
DOCKER_IMAGE_SURVEYS: 'anthoshsnair/surveys-api'
|
||||
DOCKER_IMAGE_SURVEYRESPONSE: 'anthoshsnair/surveyresponse-api'
|
||||
jobs:
|
||||
- job: BuildAndDeploy
|
||||
steps:
|
||||
- checkout: self
|
||||
|
||||
- stage: BuildAndTest
|
||||
jobs:
|
||||
- job: BuildAndTestJob
|
||||
steps:
|
||||
- script: dotnet restore
|
||||
displayName: 'Restore .NET dependencies'
|
||||
- task: UsePythonVersion@0
|
||||
inputs:
|
||||
versionSpec: '3.x'
|
||||
addToPath: true
|
||||
|
||||
- script: dotnet build --configuration Release
|
||||
displayName: 'Build .NET project'
|
||||
- script: |
|
||||
# Build and push the answers-api Docker image
|
||||
docker build -t $(DOCKER_IMAGE_ANSWERS) ./DamageAssesment.Api.Answers
|
||||
docker push $(DOCKER_IMAGE_ANSWERS)
|
||||
|
||||
- script: dotnet test DamageAssesmentApi/DamageAssesment.sln --configuration Release
|
||||
displayName: 'Run .NET tests'
|
||||
# Build and push the attachments-api Docker image
|
||||
docker build -t $(DOCKER_IMAGE_ATTACHMENTS) ./DamageAssesment.Api.Attachments
|
||||
docker push $(DOCKER_IMAGE_ATTACHMENTS)
|
||||
|
||||
- stage: Deploy
|
||||
jobs:
|
||||
- job: DeployJob
|
||||
steps:
|
||||
- script: docker-compose -f docker-compose.yml -f docker-compose.prod.yml build
|
||||
displayName: 'Build Docker Images'
|
||||
# Build and push the attachments-api Docker image
|
||||
docker build -t $(DOCKER_IMAGE_EMPLOYEES) ./DamageAssesment.Api.Employees
|
||||
docker push $(DOCKER_IMAGE_EMPLOYEES)
|
||||
|
||||
- script: docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
|
||||
displayName: 'Deploy using Docker Compose'
|
||||
# Build and push the attachments-api Docker image
|
||||
docker build -t $(DOCKER_IMAGE_LOCATIONS) ./DamageAssesment.Api.Locations
|
||||
docker push $(DOCKER_IMAGE_LOCATIONS)
|
||||
|
||||
# Build and push the attachments-api Docker image
|
||||
docker build -t $(DOCKER_IMAGE_QUESTIONS) ./DamageAssesment.Api.Questions
|
||||
docker push $(DOCKER_IMAGE_QUESTIONS)
|
||||
|
||||
#Build and push the attachments-api Docker image
|
||||
docker build -t $(DOCKER_IMAGE_SURVEYS) ./DamageAssesment.Api.Surveys
|
||||
docker push $(DOCKER_IMAGE_SURVEYS)
|
||||
|
||||
#Build and push the attachments-api Docker image
|
||||
docker build -t $(DOCKER_IMAGE_SURVEYRESPONSE) ./DamageAssesment.Api.SurveyResponses
|
||||
docker push $(DOCKER_IMAGE_SURVEYRESPONSE)
|
||||
|
||||
displayName: 'Build and Push Docker Images'
|
||||
env:
|
||||
DOCKER_IMAGE_ANSWERS: $(DOCKER_IMAGE_ANSWERS)
|
||||
DOCKER_IMAGE_ATTACHMENTS: $(DOCKER_IMAGE_ATTACHMENTS)
|
||||
DOCKER_IMAGE_EMPLOYEES: $(DOCKER_IMAGE_EMPLOYEES)
|
||||
DOCKER_IMAGE_LOCATIONS: $(DOCKER_IMAGE_LOCATIONS)
|
||||
DOCKER_IMAGE_QUESTIONS: $(DOCKER_IMAGE_QUESTIONS)
|
||||
DOCKER_IMAGE_SURVEYS: $(DOCKER_IMAGE_SURVEYS)
|
||||
DOCKER_IMAGE_SURVEYRESPONSE: $(DOCKER_IMAGE_SURVEYRESPONSE)
|
||||
- script: |
|
||||
# Deploy your services using Docker Compose
|
||||
docker-compose -f docker-compose.yml up -d --build
|
||||
displayName: 'Deploy with Docker Compose'
|
||||
|
||||
- script: |
|
||||
# Cleanup: Stop and remove Docker containers
|
||||
docker-compose -f docker-compose.yml down
|
||||
displayName: 'Cleanup Docker Containers'
|
||||
|
Loading…
Reference in New Issue
Block a user