build.sh 830 Bytes
Newer Older
David Danier's avatar
mysql  
David Danier committed
1 2 3 4
#!/bin/bash

# Configuration

David Danier's avatar
mysql  
David Danier committed
5 6
VERSIONS="5.6 5.7 8"
LATEST_VERSION="8"
David Danier's avatar
mysql  
David Danier committed
7 8 9

# Let's do it

10 11 12
set -o errexit
set -o pipefail

David Danier's avatar
mysql  
David Danier committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
if [ -z "$CI_REGISTRY" ]
then  # outside gitlab ci runner
    docker login docker.team23.de
    BUILD_PROJECT_NAME=$( basename $( pwd ) )
    BUILD_IMAGE_BASE="docker.team23.de/docker/$BUILD_PROJECT_NAME"
else  # inside gitlab ci runner
    docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY"
    BUILD_IMAGE_BASE="$CI_REGISTRY/$CI_PROJECT_PATH"
fi

for VERSION in $VERSIONS
do
    # Copy shared files
    cp -rp shared/* "$VERSION/"
    # Build Image
    docker build --pull -t "$BUILD_IMAGE_BASE:$VERSION" "$VERSION"
    docker push "$BUILD_IMAGE_BASE:$VERSION"
done

# Build latest image
docker build --pull -t "$BUILD_IMAGE_BASE:latest" "$LATEST_VERSION"
docker push "$BUILD_IMAGE_BASE:latest"