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

#2 Name and re-use ne container per project

parent dd758f7e
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,13 @@ Nothing else than docker and this [script](https://gitlab.lakedrops.com/docker/l
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.
You can execute the following commands:
```bash
sudo wget -O /usr/local/bin/l3d https://gitlab.lakedrops.com/docker/l3d/raw/master/l3d
sudo chmod +x /usr/local/bin/l3d
```
## 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.
......@@ -27,7 +34,15 @@ 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 -u` 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 also start the working container for you but check for an updated version of the image first.
## Update the start script
Just call `l3d selfupdate` and the start script will be updated from the original repository.
## Getting help
Calling `l3d help` displays information about **L3D** and provides a link to further details.
## Examples
......
#!/usr/bin/env bash
if [[ "$1" == "help" ]]; then
echo "L3D - LakeDropsDrupalDev"
echo "========================="
echo ""
echo "Version: 1.1.0"
echo "Info and support: https://gitlab.lakedrops.com/docker/l3d"
exit 0
fi
if [[ "$1" == "selfupdate" ]]; then
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
elif [[ -n "$CURL" ]]; then
sudo curl -o $DEST https://gitlab.lakedrops.com/docker/l3d/raw/master/l3d
else
echo "Could't find wget or curl to perform the update!"
exit 1
fi
sudo chmod +x $DEST
echo "Self update succeeded!"
exit 0
fi
export $(cat .env | xargs)
if [[ "${PHP_VERSION}" == "" ]]; then
while true; do
......@@ -19,8 +45,25 @@ if [[ "${COMPOSE_PROJECT_NAME}" == "" ]]; then
echo "COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}" >>.env
fi
if [[ "$1" == "-u" ]]; then
if [[ "$1" == "update" ]]; then
docker pull registry.lakedrops.com/docker/l3d:php-${PHP_VERSION}
fi
docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock -v ${PWD}:/drupal -v ${SSH_AUTH_SOCK}:/ssh-agent -v ${HOME}/.traefik:/root/.traefik -e SSH_AUTH_SOCK=/ssh-agent -e COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} -w /drupal registry.lakedrops.com/docker/l3d:php-${PHP_VERSION} /usr/bin/fish
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 \
--workdir /drupal \
--restart unless-stopped \
registry.lakedrops.com/docker/l3d:php-${PHP_VERSION}
fi
docker exec -it ${COMPOSE_PROJECT_NAME}_l3d /usr/bin/fish
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