Skip to content
Snippets Groups Projects
Commit 7daa4492 authored by jurgenhaas's avatar jurgenhaas
Browse files

#12 Proper versions for script and images at the same time

parent 7f1e8b3f
No related branches found
No related tags found
No related merge requests found
variables:
VERSION: ${CI_COMMIT_TAG}
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
l3d-script:
stage: build
script: sed -i -e "s/'{{ version }}'/${VERSION}/g" l3d
artifacts:
name: l3d
paths:
- l3d
only:
- tags
php-7.0:
stage: build
script:
- docker build --pull --build-arg PHP_VERSION=7.0 -t $CI_REGISTRY_IMAGE:php-7.0 .
- docker push $CI_REGISTRY_IMAGE:php-7.0
- docker build --pull --build-arg PHP_VERSION=7.0 --build-arg VERSION=${VERSION} -t ${CI_REGISTRY_IMAGE}/php-7.0:${VERSION} .
- docker push ${CI_REGISTRY_IMAGE}/php-7.0:${VERSION}
only:
- master
- tags
php-7.1:
stage: build
script:
- docker build --pull --build-arg PHP_VERSION=7.1 -t $CI_REGISTRY_IMAGE:php-7.1 .
- docker push $CI_REGISTRY_IMAGE:php-7.1
- docker build --pull --build-arg PHP_VERSION=7.1 --build-arg VERSION=${VERSION} -t ${CI_REGISTRY_IMAGE}/php-7.1:${VERSION} .
- docker push ${CI_REGISTRY_IMAGE}/php-7.1:${VERSION}
only:
- master
- tags
php-7.2:
stage: build
script:
- docker build --pull --build-arg PHP_VERSION=7.2 -t $CI_REGISTRY_IMAGE:php-7.2 .
- docker push $CI_REGISTRY_IMAGE:php-7.2
- docker build --pull --build-arg PHP_VERSION=7.2 --build-arg VERSION=${VERSION} -t ${CI_REGISTRY_IMAGE}/php-7.2:${VERSION} .
- docker push ${CI_REGISTRY_IMAGE}/php-7.2:${VERSION}
only:
- master
- tags
ARG PHP_VERSION
ARG VERSION
FROM registry.lakedrops.com/docker/gitlab-drupal-ci:php-${PHP_VERSION}
LABEL com.example.vendor="LakeDrops" \
maintainer="juergen.haas@lakedrops.com" \
version="1.2.2" \
version="${VERSION}" \
description="Drupal development environment from LakeDrops."
ENV LAKEDROPS_DEV_ENV 1
......
#!/usr/bin/env bash
function help {
VERSION='{{ version }}'
function showHelp {
echo "L3D - LakeDropsDrupalDev"
echo "========================="
echo ""
echo "Version: 1.4.1"
echo "Version: ${VERSION}"
echo "Info and support: https://gitlab.lakedrops.com/docker/l3d"
echo ""
echo "Usage:"
echo " l3d [ help | selfupdate | update | PROJECTNAME]"
echo " l3d [ help | version | selfupdate | update | PROJECTNAME ]"
echo ""
echo ""
}
function selfupdate {
function showVersion {
echo "${VERSION}"
}
function selfUpdate {
NEWVERSION=$(curl -s https://gitlab.lakedrops.com/api/v4/projects/282/repository/tags | grep -o '[0-9]*\.[0-9]*\.[0-9]*' | head -1)
if [[ "$NEWVERSION" == "$VERSION" ]]; then
echo "No new version available"
return
fi
NEWSCRIPT="https://gitlab.lakedrops.com/docker/l3d/-/jobs/artifacts/${NEWVERSION}/raw/l3d?job=l3d-script"
DEST=$(which l3d)
WGET=$(which wget)
CURL=$(which curl)
if [[ -n "$WGET" ]]; then
sudo wget -O $DEST https://gitlab.lakedrops.com/docker/l3d/raw/master/l3d > /dev/null 2>&1
sudo wget -O ${DEST} ${NEWSCRIPT} > /dev/null 2>&1
elif [[ -n "$CURL" ]]; then
sudo curl -o $DEST https://gitlab.lakedrops.com/docker/l3d/raw/master/l3d > /dev/null 2>&1
sudo curl -o ${DEST} ${NEWSCRIPT} > /dev/null 2>&1
else
echo "Could't find wget or curl to perform the update!"
exit 1
fi
sudo chmod +x $DEST
sudo chmod +x ${DEST}
echo "Self update succeeded!"
}
function update {
getenv
IMAGEID=$(docker image ls -q registry.lakedrops.com/docker/l3d:php-${PHP_VERSION})
function updateImage {
getConfig
IMAGEID=$(docker image ls -q registry.lakedrops.com/docker/l3d/php-${PHP_VERSION}:${VERSION})
echo "Updating the image ..."
STATUS=$(docker pull registry.lakedrops.com/docker/l3d:php-${PHP_VERSION})
STATUS=$(docker pull registry.lakedrops.com/docker/l3d/php-${PHP_VERSION}:${VERSION})
if [[ "$STATUS" == *"Status: Image is up to date"* ]]; then
echo "Already up to date"
else
......@@ -53,7 +65,7 @@ function update {
fi
}
function getenv {
function getConfig {
if [[ -f ".env" ]]; then
export $(cat .env | xargs) > /dev/null 2>&1
fi
......@@ -76,7 +88,7 @@ function getenv {
fi
}
function start {
function startContainer {
if [[ -n "${COMPOSE_PROJECT_NAME}" ]]; then
ID=$(docker container ls -q -f name=${COMPOSE_PROJECT_NAME}_l3d)
......@@ -95,7 +107,7 @@ function start {
--volume ${HOME}/.gitconfig:/root/.gitconfig \
--workdir /drupal \
--restart unless-stopped \
registry.lakedrops.com/docker/l3d:php-${PHP_VERSION}
registry.lakedrops.com/docker/l3d/php-${PHP_VERSION}:${VERSION}
fi
EXISTING=$(ls -1)
......@@ -108,19 +120,26 @@ function start {
}
COMPOSE_PROJECT_NAME=
if [[ "$VERSION" == "{{ version }}" ]]; then
selfUpdate
fi
case $1 in
help )
help
showHelp
;;
version )
showVersion
;;
selfupdate )
selfupdate
selfUpdate
;;
update )
update
start
updateImage
startContainer
;;
* )
......@@ -130,8 +149,9 @@ case $1 in
COMPOSE_PROJECT_NAME=$1
fi
else
getenv
getConfig
fi
start
startContainer
;;
esac
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment