build.sh 794 Bytes
Newer Older
David Danier's avatar
mysql  
David Danier committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#!/bin/bash

# Configuration

VERSIONS="5 10"
LATEST_VERSION="10"

# 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
    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"