build.sh 946 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 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

# Let's do it

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
David Danier's avatar
David Danier committed
25
    docker pull "$BUILD_IMAGE_BASE:$VERSION" || echo "No version exists yet"
David Danier's avatar
mysql  
David Danier committed
26 27 28 29 30
    docker build --pull -t "$BUILD_IMAGE_BASE:$VERSION" "$VERSION"
    docker push "$BUILD_IMAGE_BASE:$VERSION"
done

# Build latest image
David Danier's avatar
David Danier committed
31
docker pull "$BUILD_IMAGE_BASE:latest" || echo "No version exists yet"
David Danier's avatar
mysql  
David Danier committed
32 33
docker build --pull -t "$BUILD_IMAGE_BASE:latest" "$LATEST_VERSION"
docker push "$BUILD_IMAGE_BASE:latest"