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

gitlab-drupal-ci#48 Make L3D container names user specific

parent 2390e2f2
No related branches found
Tags test3
1 merge request!39Merging develop into main
#!/bin/bash #!/bin/bash
if [[ -n $1 ]]; then if [[ -n $1 ]]; then
docker inspect ${1}_l3d | jq -r .[0].Config.Env | grep L3DHOSTDIR | cut -d'=' -f 2 | cut -d'"' -f 1 docker inspect ${1}_${USERNAME}_l3d | jq -r .[0].Config.Env | grep L3DHOSTDIR | cut -d'=' -f 2 | cut -d'"' -f 1
fi fi
...@@ -51,9 +51,9 @@ function startContainer() { ...@@ -51,9 +51,9 @@ function startContainer() {
if [[ $COMPOSE_PROJECT_NAME == "." ]]; then if [[ $COMPOSE_PROJECT_NAME == "." ]]; then
mode=NONPRESISTENT mode=NONPRESISTENT
else else
ID=$(docker container ls --all -q -f name=^${COMPOSE_PROJECT_NAME}_l3d$) ID=$(docker container ls --all -q -f name=^${COMPOSE_PROJECT_NAME}_${USERNAME}_l3d$)
if [[ -n ${ID} ]]; then if [[ -n ${ID} ]]; then
docker start ${COMPOSE_PROJECT_NAME}_l3d docker start ${COMPOSE_PROJECT_NAME}_${USERNAME}_l3d
mode=REGULAR mode=REGULAR
fi fi
fi fi
...@@ -98,7 +98,7 @@ function startContainer() { ...@@ -98,7 +98,7 @@ function startContainer() {
start_params+=( start_params+=(
--hostname ${COMPOSE_PROJECT_NAME}-l3d --hostname ${COMPOSE_PROJECT_NAME}-l3d
) )
docker run --name ${COMPOSE_PROJECT_NAME}_l3d -dt \ docker run --name ${COMPOSE_PROJECT_NAME}_${USERNAME}_l3d -dt \
"${start_params[@]}" \ "${start_params[@]}" \
--restart unless-stopped \ --restart unless-stopped \
registry.lakedrops.com/docker/l3d/php-${PHP_VERSION}:${L3DVERSION} registry.lakedrops.com/docker/l3d/php-${PHP_VERSION}:${L3DVERSION}
...@@ -137,7 +137,7 @@ function startContainer() { ...@@ -137,7 +137,7 @@ function startContainer() {
fi fi
docker exec -it \ docker exec -it \
"${start_params[@]}" \ "${start_params[@]}" \
${COMPOSE_PROJECT_NAME}_l3d \ ${COMPOSE_PROJECT_NAME}_${USERNAME}_l3d \
/usr/local/bin/.start /usr/local/bin/.start
exitContainer exitContainer
fi fi
...@@ -147,7 +147,7 @@ if [[ -n $1 ]]; then ...@@ -147,7 +147,7 @@ if [[ -n $1 ]]; then
if [[ "$1" == "." ]]; then if [[ "$1" == "." ]]; then
COMPOSE_PROJECT_NAME=. COMPOSE_PROJECT_NAME=.
else else
ID=$(docker container ls --all -q -f name=^$1_l3d$) ID=$(docker container ls --all -q -f name=^$1_${USERNAME}_l3d$)
if [[ -n ${ID} ]]; then if [[ -n ${ID} ]]; then
PHP_VERSION=unknown PHP_VERSION=unknown
COMPOSE_PROJECT_NAME=$1 COMPOSE_PROJECT_NAME=$1
......
...@@ -81,7 +81,7 @@ fi ...@@ -81,7 +81,7 @@ fi
# Chenge directory to the existing project root, if available. # Chenge directory to the existing project root, if available.
if [[ -n $1 ]]; then if [[ -n $1 ]]; then
ID=$(docker container ls --all -q -f name=^$1_l3d$) ID=$(docker container ls --all -q -f name=^$1_${USERNAME}_l3d$)
if [[ -n ${ID} ]]; then if [[ -n ${ID} ]]; then
cd $(docker exec ${ID} php /usr/local/bin/volume.php --none) cd $(docker exec ${ID} php /usr/local/bin/volume.php --none)
fi fi
......
...@@ -250,7 +250,7 @@ if [[ "$INSTALLED_PHP_VERSION" != "$PHP_VERSION" ]]; then ...@@ -250,7 +250,7 @@ if [[ "$INSTALLED_PHP_VERSION" != "$PHP_VERSION" ]]; then
if [[ "${COMPOSE_PROJECT_NAME}" != "." ]]; then if [[ "${COMPOSE_PROJECT_NAME}" != "." ]]; then
echo -e "\\033[31m Killed the outdated container, please start again !!! \\033[0m" echo -e "\\033[31m Killed the outdated container, please start again !!! \\033[0m"
echo -e "\\033[31m ===================================================== \\033[0m" echo -e "\\033[31m ===================================================== \\033[0m"
docker rm -f ${COMPOSE_PROJECT_NAME}_l3d docker rm -f ${COMPOSE_PROJECT_NAME}_${USERNAME}_l3d
fi fi
fi fi
if [[ "$COMPOSER_DOWNGRADE" == "1" ]]; then if [[ "$COMPOSER_DOWNGRADE" == "1" ]]; then
...@@ -286,8 +286,8 @@ if [[ "${COMPOSE_PROJECT_NAME}" != "." ]]; then ...@@ -286,8 +286,8 @@ if [[ "${COMPOSE_PROJECT_NAME}" != "." ]]; then
echo "#!/bin/sh" > .git/hooks/post-checkout echo "#!/bin/sh" > .git/hooks/post-checkout
chmod +x .git/hooks/post-checkout chmod +x .git/hooks/post-checkout
fi fi
OLDCOMMAND='docker exec '${COMPOSE_PROJECT_NAME}'_l3d /usr/local/bin/update-env' OLDCOMMAND='docker exec '${COMPOSE_PROJECT_NAME}'_'${USERNAME}'_l3d /usr/local/bin/update-env'
NEWCOMMAND='RUNNING=$(docker container ls --all -q -f name='${COMPOSE_PROJECT_NAME}'_l3d);if [ "x$RUNNING" != "x" ];then docker exec '${COMPOSE_PROJECT_NAME}'_l3d /usr/local/bin/update-env;fi' NEWCOMMAND='RUNNING=$(docker container ls --all -q -f name='${COMPOSE_PROJECT_NAME}'_'${USERNAME}_'l3d);if [ "x$RUNNING" != "x" ];then docker exec '${COMPOSE_PROJECT_NAME}'_l3d /usr/local/bin/update-env;fi'
OLD_HOOK_DEFINED=$(grep "$OLDCOMMAND" .git/hooks/post-checkout) OLD_HOOK_DEFINED=$(grep "$OLDCOMMAND" .git/hooks/post-checkout)
NEW_HOOK_DEFINED=$(grep "$NEWCOMMAND" .git/hooks/post-checkout) NEW_HOOK_DEFINED=$(grep "$NEWCOMMAND" .git/hooks/post-checkout)
if [[ "x$OLD_HOOK_DEFINED" = "x" ]]; then if [[ "x$OLD_HOOK_DEFINED" = "x" ]]; then
......
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