Skip to content
Snippets Groups Projects
Commit aaaa2fc5 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

update docker init

parent 9e02e95e
Branches
No related tags found
1 merge request!455997 no autocomplete
......@@ -4,8 +4,12 @@
# DOCKER PHP DEV ENVIRONMENT :: INIT
#
# ----------------------------------------------------------------------
# 2021-11-nn <axel.hahn@iml.unibe.ch>
# 2022-07-19 <axel.hahn@iml.unibe.ch> support multiple dirs for setfacl
# 2021-11-nn v1.0 <axel.hahn@iml.unibe.ch>
# 2022-07-19 v1.1 <axel.hahn@iml.unibe.ch> support multiple dirs for setfacl
# 2022-11-16 v1.2 <www.axel-hahn.de> use docker-compose -p "$APP_NAME"
# 2022-12-18 v1.3 <www.axel-hahn.de> add -p "$APP_NAME" in other docker commands
# 2022-12-20 v1.4 <axel.hahn@unibe.ch> replace fgrep with grep -F
# 2023-03-06 v1.5 <www.axel-hahn.de> up with and without --build
# ======================================================================
cd $( dirname $0 )
......@@ -14,6 +18,8 @@ cd $( dirname $0 )
# git@git-repo.iml.unibe.ch:iml-open-source/docker-php-starterkit.git
selfgitrepo="docker-php-starterkit.git"
_version="1.5"
# ----------------------------------------------------------------------
# FUNCTIONS
# ----------------------------------------------------------------------
......@@ -86,7 +92,7 @@ function _removeGitdata(){
function _fix_no-db(){
local _file=$1
if [ $DB_ADD = false ]; then
typeset -i local iStart=$( cat ${_file} | fgrep -n "$CUTTER_NO_DATABASE" | cut -f 1 -d ':' )-1
typeset -i local iStart=$( cat ${_file} | grep -Fn "$CUTTER_NO_DATABASE" | cut -f 1 -d ':' )-1
if [ $iStart -gt 0 ]; then
sed -ni "1,${iStart}p" ${_file}
fi
......@@ -186,7 +192,7 @@ function _showContainers(){
local bLong=$1
h2 CONTAINERS
if [ -z "$bLong" ]; then
docker-compose ps
docker-compose -p "$APP_NAME" ps
else
docker ps | grep $APP_NAME
fi
......@@ -233,7 +239,7 @@ action=$1
while true; do
echo
echo -e "\e[32m===== INITIALIZER FOR APP [$APP_NAME] ===== \e[0m"
echo -e "\e[32m===== INITIALIZER FOR DOCKER APP [$APP_NAME] v$_version ===== \e[0m\n\r"
if [ -z "$action" ]; then
......@@ -246,7 +252,8 @@ while true; do
echo " t - generate files from templates"
echo " T - remove generated files"
echo
echo " u - startup containers docker-compose up -d"
echo " u - startup containers docker-compose ... up -d"
echo " U - startup containers docker-compose ... up -d --build"
echo " s - shutdown containers docker-compose stop"
echo " r - remove containers docker-compose rm -f"
echo
......@@ -281,24 +288,27 @@ while true; do
_showInfos
_wait
;;
u)
if docker-compose --verbose up -d --remove-orphans --build; then
# test ! -z "${APP_ONSTARTUP}" && sleep 2 && docker exec -it appmonitor-server /bin/bash -c "${APP_ONSTARTUP}"
u|U)
dockerUp="docker-compose -p "$APP_NAME" --verbose up -d --remove-orphans"
if [ "$action" = "U" ]; then
dockerUp+=" --build"
fi
if $dockerUp; then
echo "In a web browser:"
echo " $frontendurl"
else
echo "ERROR: docker-compose up failed :-/"
docker-compose logs | tail
docker-compose -p "$APP_NAME" logs | tail
fi
echo
_wait
;;
s)
docker-compose stop
docker-compose -p "$APP_NAME" stop
;;
r)
docker-compose rm -f
docker-compose -p "$APP_NAME" rm -f
;;
c)
docker ps
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment