diff options
| author | 2019-03-30 17:27:17 -0700 | |
|---|---|---|
| committer | 2019-03-30 17:27:17 -0700 | |
| commit | 0f90525a0e7bde5207269cff65cc5f049c115832 (patch) | |
| tree | d3666923d1f23346c2cc4ec37478e8e2c2e71eee | |
| parent | Re-lock and update test job to Python 3.7 (diff) | |
Azure: Add build and push steps for base and venv images
The base image is only built when base.Dockerfile changes. The virtual
environment image is only built when the base image is built,
venv.Dockerfile changes, or either Pipfile changes. Images are pushed
only after all images have been successfully built.
| -rw-r--r-- | azure-pipelines.yml | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/azure-pipelines.yml b/azure-pipelines.yml index bf756b8..ad9a7c8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -43,8 +43,34 @@ jobs: dockerRegistryEndpoint: 'DockerHub' command: 'login' + - script: | + if [[ -n "$(git diff HEAD~ -- docker/base.Dockerfile)" ]]; then + echo "##vso[task.setvariable variable=BASE_CHANGED]1" + fi + + if [[ -n "$(git diff HEAD~ -- Pipfile* docker/venv.Dockerfile)" ]]; then + echo "##vso[task.setvariable variable=VENV_CHANGED]1" + fi + displayName: 'Check Changed Files' + + - script: docker build -t pythondiscord/snekbox-base:latest -f docker/base.Dockerfile . + displayName: 'Build Base Image' + condition: and(succeeded(), variables.BASE_CHANGED) + + - script: docker build -t pythondiscord/snekbox-venv:latest -f docker/venv.Dockerfile . + displayName: 'Build Virtual Environment Image' + condition: and(succeeded(), or(variables.BASE_CHANGED, variables.VENV_CHANGED)) + - script: docker build -t pythondiscord/snekbox:latest -f docker/Dockerfile . displayName: 'Build Final Image' + - script: docker push pythondiscord/snekbox-base:latest + displayName: 'Push Base Image to Dockerhub' + condition: and(succeeded(), variables.BASE_CHANGED) + + - script: docker push pythondiscord/snekbox-venv:latest + displayName: 'Push Virtual Environment Image to Dockerhub' + condition: and(succeeded(), or(variables.BASE_CHANGED, variables.VENV_CHANGED)) + - script: docker push pythondiscord/snekbox:latest - displayName: 'Push Image to Dockerhub' + displayName: 'Push Final Image to Dockerhub' |