Created
January 9, 2022 08:35
-
-
Save mahenzon/45f36b9dcd3a04f27e06d605e3dfff53 to your computer and use it in GitHub Desktop.
GitLab CI multistage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.build-and-push-multistage: | |
stage: build-and-push | |
image: docker:20.10.7-dind | |
variables: | |
# space separated | |
services: app-build app-prod | |
# pull / push in this number of parallel jobs | |
parallelism: 2 | |
before_script: | |
- apk add --no-cache docker-compose | |
- echo "$REGISTRY_PASSWORD" | docker login $REGISTRY --username $REGISTRY_USERNAME --password-stdin | |
script: | |
- > | |
for service in $services; do | |
echo "build and push $service"; | |
done | |
- > | |
for service in $services; | |
do | |
docker-compose pull "$service" || true; | |
done | |
- docker image ls -a | |
- > | |
for service in $services; | |
do | |
docker-compose build "$service"; | |
done | |
- > | |
for service in $services; | |
do | |
docker-compose push "$service"; | |
done | |
interruptible: true | |
app-dev:build-and-push: | |
extends: .build-and-push-multistage | |
only: | |
- develop | |
variables: | |
IMAGE_TAG: dev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment