2023-10-15 22:44:19 -05:00
|
|
|
name: Build & Push to ACR Pipeline
|
2023-10-15 22:40:48 -05:00
|
|
|
|
2023-10-16 18:30:50 -05:00
|
|
|
trigger:
|
|
|
|
- '*'
|
|
|
|
|
2023-10-13 17:28:15 -05:00
|
|
|
pr:
|
2023-10-16 18:30:50 -05:00
|
|
|
- '*'
|
2023-10-13 17:28:15 -05:00
|
|
|
|
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
|
|
|
|
jobs:
|
2023-10-16 18:30:50 -05:00
|
|
|
- job: BuildAndPushImages
|
2023-10-13 17:28:15 -05:00
|
|
|
steps:
|
2023-10-15 22:31:15 -05:00
|
|
|
- checkout: self
|
|
|
|
|
2023-10-16 18:30:50 -05:00
|
|
|
- bash: |
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Specify the path to your docker-compose.yml
|
|
|
|
composeFile="$(find $(Build.SourcesDirectory) -name docker-compose.yml | head -1)"
|
|
|
|
|
|
|
|
# Check if a docker-compose.yml file was found
|
|
|
|
if [ -z "$composeFile" ]; then
|
|
|
|
echo "No docker-compose.yml file found in the workspace."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Log the path to the docker-compose.yml file
|
|
|
|
echo "Using docker-compose file at: $composeFile"
|
|
|
|
|
|
|
|
# Log in to ACR (replace ACR_USERNAME and ACR_PASSWORD)
|
|
|
|
docker login dadeschoolscontainerregistry.azurecr.io -u ACR_USERNAME -p ACR_PASSWORD
|
|
|
|
|
|
|
|
# List of services to build, tag, and push
|
|
|
|
services=(
|
|
|
|
"damageassesmentapianswers"
|
|
|
|
"damageassesmentapiattachments"
|
|
|
|
"damageassesmentapiemployees"
|
|
|
|
"damageassesmentapilocations"
|
|
|
|
"damageassesmentapiquestions"
|
|
|
|
"damageassesmentapisurveys"
|
|
|
|
"damageassesmentapidoculinks"
|
|
|
|
"damageassesmentapiresponses"
|
|
|
|
)
|
|
|
|
|
|
|
|
# Loop through the services and build, tag, and push
|
|
|
|
for service in "${services[@]}"; do
|
|
|
|
# Build the service
|
|
|
|
docker-compose -f "$composeFile" build "$service"
|
|
|
|
|
|
|
|
# Tag the image for ACR
|
|
|
|
docker tag "$service" "dadeschoolscontainerregistry.azurecr.io/$service"
|
|
|
|
|
|
|
|
# Push the image to ACR
|
|
|
|
docker push "dadeschoolscontainerregistry.azurecr.io/$service"
|
|
|
|
done
|
|
|
|
displayName: 'Build and Push Docker Images'
|
|
|
|
env:
|
|
|
|
ACR_USERNAME: $(acrUsername) # Set your ACR username secret here
|
|
|
|
ACR_PASSWORD: $(acrPassword) # Set your ACR password secret here
|