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

Merge branch 'master' into develop

# Conflicts:
#	l3d
parents d509c308 322be173
No related branches found
No related tags found
No related merge requests found
......@@ -4,13 +4,23 @@ variables:
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
l3d-script:
setup:
stage: build
script: sed -i -e "s/'{{ version }}'/${VERSION}/g" l3d
artifacts:
name: l3d
paths:
- l3d
script:
- docker build --pull --build-arg VERSION=${VERSION} -t ${CI_REGISTRY_IMAGE}/setup:${VERSION} ./setup
- docker build --pull --build-arg VERSION=${VERSION} -t ${CI_REGISTRY_IMAGE}/setup:latest ./setup
- docker push ${CI_REGISTRY_IMAGE}/setup:${VERSION}
- docker push ${CI_REGISTRY_IMAGE}/setup:latest
only:
- tags
run:
stage: build
script:
- docker build --pull --build-arg VERSION=${VERSION} -t ${CI_REGISTRY_IMAGE}/run:${VERSION} ./run
- docker build --pull --build-arg VERSION=${VERSION} -t ${CI_REGISTRY_IMAGE}/run:latest ./run
- docker push ${CI_REGISTRY_IMAGE}/run:${VERSION}
- docker push ${CI_REGISTRY_IMAGE}/run:latest
only:
- tags
......
#!/usr/bin/env bash
EXISTING=$(ls -1)
if [[ -n "$EXISTING" ]]; then
exit
fi
echo "Lets start a new project here ..."
echo ""
echo "Options to start:"
echo " 1 LakeDrops Drupal 8 project template"
echo " 2 Drupal's community project template"
echo " 3 Existing git repository"
echo ""
echo ""
#!/bin/bash
function truncateCurrentDirectory {
if [[ -f ".env" ]]; then
......@@ -22,8 +8,15 @@ function truncateCurrentDirectory {
}
function restoreEnvFile {
echo "PHP_VERSION=${PHP_VERSION}" >>.env
echo "COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}" >>.env
if [[ -n ${PHP_VERSION} ]]; then
echo "PHP_VERSION=${PHP_VERSION}" >>.env
fi
if [[ -n ${COMPOSE_PROJECT_NAME} ]]; then
echo "COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}" >>.env
fi
if [[ -f ".env" ]]; then
env -i $(cat .env | xargs) >.env
fi
}
function create {
......@@ -32,6 +25,21 @@ function create {
restoreEnvFile
}
EXISTING=$(ls -1)
if [[ -n "$EXISTING" ]]; then
restoreEnvFile
exit
fi
echo "Lets start a new project here ..."
echo ""
echo "Options to start:"
echo " 1 LakeDrops Drupal 8 project template"
echo " 2 Drupal's community project template"
echo " 3 Existing git repository"
echo ""
echo ""
while true; do
read -p "Choose an option: " OPTION
case ${OPTION} in
......@@ -65,4 +73,5 @@ while true; do
esac
done
restoreEnvFile
/usr/bin/fish
......@@ -12,7 +12,7 @@ ENV LAKEDROPS_DEV_ENV 1
ENV LAKEDROPS_DEV_DC_OPTIONS " "
ADD config.fish /etc/fish/
ADD start-new-project /usr/local/bin/
ADD .start /usr/local/bin/
RUN echo "Install dorgflow" && \
cd /var/opt && \
......
......@@ -4,23 +4,22 @@ Provides fully configured Docker images for local Drupal development where your
## Prerequisites
Nothing else than docker and this [script](https://gitlab.lakedrops.com/docker/l3d/raw/master/l3d) being installed on your host. You don't need any other tool - none!
Nothing else than docker being installed on your host. You don't need any other tool - none!
Ideally you download that script and copy that to a directory in your search path (e.g. `/usr/local/bin`), then it will be available for all your Drupal projects.
## Quick start
You can execute the following commands:
You can install the tool with the following command:
```bash
sudo wget -O /usr/local/bin/l3d https://gitlab.lakedrops.com/docker/l3d/raw/master/l3d
sudo chmod +x /usr/local/bin/l3d
docker run -v /usr/local/bin:/setup --rm registry.lakedrops.com/docker/l3d/setup:latest
```
## Quick start
Go to the project root for which you want to use **L3D** and execute the downloaded script (simply type `l3d` at the command prompt). It will ask you for the PHP version to be used (input `7.0`, `7.1` or `7.2`) and it will download the matching L3D image and start a container for you.
This will install the script `l3d` into the given directory `/usr/local/bin` from where it is executable everywhere on your host (assuming this path being in your search path). If you want that script to be installed elsewhere then provide that alternative path in the install command above. Also, instead of `latest` you can also start with any othe specific version number of this tool. You can find all available version string in the [tag list](https://gitlab.lakedrops.com/docker/l3d/tags) of this project.
## Usage
Go to the project root for which you want to use **L3D** and execute the installed script (simply type `l3d` at the command prompt). It will ask you for the PHP version to be used (input `7.0`, `7.1` or `7.2`) and it will download the matching **L3D** image and start a container for you.
Inside the container you'll find the directory `/drupal` which contains everything from your project's root. You can work from there by using these available tools:
| Tool | Command | Shortcut |
......@@ -34,7 +33,7 @@ Inside the container you'll find the directory `/drupal` which contains everythi
## Update the image
When starting **L3D** with the script this will simply re-use the latest available image in your local docker environment. To force your docker to download the latest version of an image you can use `l3d update` which will also start the working container for you but check for an updated version of the image first.
When starting **L3D** with the script this will simply re-use the latest available image in your local docker environment. To force your docker to download the latest version of an image you can use `l3d update` which will check for an updated version of the image and pull that to your host for subsequent commands.
## Update the start script
......
#!/usr/bin/env bash
VERSION='{{ version }}'
function showHelp {
echo "L3D - LakeDropsDrupalDev"
echo "========================="
echo ""
echo "Version: ${VERSION}"
echo "Info and support: https://gitlab.lakedrops.com/docker/l3d"
echo ""
echo "Usage:"
echo " l3d [ help | version | selfupdate | update | PROJECTNAME ]"
echo ""
echo ""
}
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} ${NEWSCRIPT} > /dev/null 2>&1
elif [[ -n "$CURL" ]]; then
sudo curl -L -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}
echo "Self update succeeded!"
}
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}:${VERSION})
if [[ "$STATUS" == *"Status: Image is up to date"* ]]; then
echo "Already up to date"
else
echo "Image updated"
if [[ -n "$ID" ]]; then
while true; do
ID=$(docker container ls -q -f ancestor=${IMAGEID})
if [[ -n "$ID" ]]; then
echo "Removing outdated container ..."
docker stop ${ID}
docker rm ${ID}
else
break
fi
done
fi
fi
}
function getConfig {
if [[ -f ".env" ]]; then
export $(cat .env | xargs) > /dev/null 2>&1
fi
if [[ "${PHP_VERSION}" == "" ]]; then
while true; do
read -p "Which PHP version is your project using? " PHP_VERSION
case ${PHP_VERSION} in
7.0) break;;
7.1) break;;
7.2) break;;
*) echo "Version not supported.";;
esac
done
echo "PHP_VERSION=${PHP_VERSION}" >>.env
fi
if [[ "${COMPOSE_PROJECT_NAME}" == "" ]]; then
read -p "Name your project (used as subdomain): " COMPOSE_PROJECT_NAME
echo "COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}" >>.env
fi
}
function startContainer {
if [[ -n "${COMPOSE_PROJECT_NAME}" ]]; then
ID=$(docker container ls -q -f name=${COMPOSE_PROJECT_NAME}_l3d)
if [[ -n "$ID" ]]; then
docker start ${COMPOSE_PROJECT_NAME}_l3d
else
docker run --name ${COMPOSE_PROJECT_NAME}_l3d -dt \
--hostname ${COMPOSE_PROJECT_NAME}-l3d \
--env COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} \
--env SSH_AUTH_SOCK=/ssh-agent \
--env-file ${PWD}/.env \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume ${PWD}:/drupal \
--volume ${SSH_AUTH_SOCK}:/ssh-agent \
--volume ${HOME}/.traefik:/root/.traefik \
--volume ${HOME}/.gitconfig:/root/.gitconfig \
--workdir /drupal \
--restart unless-stopped \
registry.lakedrops.com/docker/l3d/php-${PHP_VERSION}:${VERSION}
fi
EXISTING=$(ls -1)
if [[ -n "$EXISTING" ]]; then
docker exec -it ${COMPOSE_PROJECT_NAME}_l3d /usr/bin/fish
else
docker exec -it ${COMPOSE_PROJECT_NAME}_l3d /usr/local/bin/start-new-project
fi
fi
}
COMPOSE_PROJECT_NAME=
if [[ "$VERSION" == "{{ version }}" ]]; then
selfUpdate
fi
case $1 in
help)
showHelp
;;
version)
showVersion
;;
selfupdate)
selfUpdate
;;
update)
updateImage
startContainer
;;
*)
if [[ -n "$1" ]]; then
ID=$(docker container ls -q -f name=$1_l3d)
if [[ -n "${ID}" ]]; then
COMPOSE_PROJECT_NAME=$1
fi
else
getConfig
fi
startContainer
;;
esac
FROM docker:dind
ARG VERSION
LABEL com.example.vendor="LakeDrops" \
maintainer="juergen.haas@lakedrops.com" \
version="${VERSION}" \
description="Setup for the Drupal development environment from LakeDrops."
USER root
ADD scripts/* /usr/local/bin/
RUN apk add bash curl jq && \
sed -i -e "s/'{{ version }}'/${VERSION}/g" /usr/local/bin/run
ENTRYPOINT /bin/sh
#!/bin/bash
echo "L3D - LakeDropsDrupalDev"
echo "========================="
echo ""
echo "Version: ${VERSION}"
echo "Support: https://gitlab.lakedrops.com/docker/l3d"
echo ""
echo "Usage: l3d [ help | version | selfupdate | update | PROJECTNAME ]"
echo ""
#!/bin/bash
export VERSION='{{ version }}'
COMMAND=start
if [[ -n "$1" ]]; then
if [[ -f "/usr/local/bin/$1" ]]; then
COMMAND=$1
shift
fi
fi
/usr/local/bin/${COMMAND} $@
#!/bin/sh
if [[ -n $1 ]]; then
NEWVERSION=$1
else
NEWVERSION=$(curl -s https://gitlab.lakedrops.com/api/v4/projects/282/repository/tags | jq -r .[0].name)
fi
if [[ "$NEWVERSION" == "$VERSION" ]]; then
echo "No new version available"
return
fi
UPDATE=$(docker run -v ${SCRIPTPATH}:/setup --rm registry.lakedrops.com/docker/l3d/setup:${NEWVERSION})
if [[ "$UPDATE" == *"setup:${NEWVERSION} not found"* ]]; then
echo "Version not found."
return
fi
echo "Self update succeeded!"
echo "Cleaning old container"
docker stop l3dsetup
#!/bin/bash
function getConfig {
if [[ ! -n ${PHP_VERSION} ]]; then
while true; do
read -p "Which PHP version is your project using? " PHP_VERSION
case ${PHP_VERSION} in
7.0 ) break;;
7.1 ) break;;
7.2 ) break;;
* ) echo "Version not supported.";;
esac
done
fi
if [[ ! -n ${COMPOSE_PROJECT_NAME} ]]; then
read -p "Name your project (used as subdomain): " COMPOSE_PROJECT_NAME
fi
}
function startContainer {
if [[ -n ${COMPOSE_PROJECT_NAME} ]]; then
ID=$(docker container ls -q -f name=${COMPOSE_PROJECT_NAME}_l3d)
if [[ -n ${ID} ]]; then
docker start ${COMPOSE_PROJECT_NAME}_l3d
else
docker run --name ${COMPOSE_PROJECT_NAME}_l3d -dt \
--hostname ${COMPOSE_PROJECT_NAME}-l3d \
--env COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} \
--env PHP_VERSION=${PHP_VERSION} \
--env SSH_AUTH_SOCK=/ssh-agent \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume ${WORKDIR}:/drupal \
--volume ${SSHAUTH}:/ssh-agent \
--volume ${HOMEDIR}/.traefik:/root/.traefik \
--volume ${HOMEDIR}/.gitconfig:/root/.gitconfig \
--workdir /drupal \
--restart unless-stopped \
registry.lakedrops.com/docker/l3d/php-${PHP_VERSION}:${VERSION}
fi
docker exec -it \
${COMPOSE_PROJECT_NAME}_l3d \
/usr/local/bin/.start
fi
}
if [[ -n $1 ]]; then
ID=$(docker container ls -q -f name=$1_l3d)
if [[ -n ${ID} ]]; then
PHP_VERSION=unknown
COMPOSE_PROJECT_NAME=$1
fi
fi
getConfig
startContainer
#!/bin/bash
if [[ -n ${PHP_VERSION} ]]; then
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}:${VERSION})
if [[ "$STATUS" == *"Status: Image is up to date"* ]]; then
echo "Already up to date"
else
echo "Image updated"
while true; do
ID=$(docker container ls -q -f ancestor=${IMAGEID})
if [[ -n ${ID} ]]; then
echo "Removing outdated container ..."
docker stop ${ID}
docker rm ${ID}
else
break
fi
done
fi
fi
#!/bin/bash
echo "${VERSION}"
FROM busybox
ARG VERSION
LABEL com.example.vendor="LakeDrops" \
maintainer="juergen.haas@lakedrops.com" \
version="${VERSION}" \
description="Setup for the Drupal development environment from LakeDrops."
USER root
ADD scripts/* /usr/local/bin/
RUN sed -i -e "s/'{{ version }}'/${VERSION}/g" /usr/local/bin/l3d
CMD /usr/local/bin/setup
#!/bin/bash
ID=$(docker container ls -q -f name=l3drun)
if [[ ! -n ${ID} ]]; then
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
docker run --name=l3drun -dt --rm \
--env SCRIPTPATH=${SCRIPTPATH} \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume ${SCRIPTPATH}:/setup \
registry.lakedrops.com/docker/l3d/run:'{{ version }}'
fi
if [[ -f ".env" ]]; then
export $(cat .env | xargs) > /dev/null 2>&1
fi
docker exec -it \
--env HOMEDIR=${HOME} \
--env WORKDIR=${PWD} \
--env SSHAUTH=${SSH_AUTH_SOCK} \
--env PHP_VERSION=${PHP_VERSION} \
--env COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} \
l3drun \
/usr/local/bin/run $@
#!/bin/sh
cp /usr/local/bin/l3d /setup/l3d
echo "L3D installed successfully!"
echo ""
echo "Call ===> l3d help <=== for further instructions."
echo ""
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