Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
docker-php-starterkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
docker-php-starterkit
Commits
2d39e714
Commit
2d39e714
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
update docker init script
parent
8ae69c68
No related branches found
No related tags found
1 merge request
!9
Update docker init script
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docker/init.sh
+80
-29
80 additions, 29 deletions
docker/init.sh
with
80 additions
and
29 deletions
docker/init.sh
+
80
−
29
View file @
2d39e714
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
# 2023-08-17 v1.6 <www.axel-hahn.de> menu selection with single key (without return)
# 2023-08-17 v1.6 <www.axel-hahn.de> menu selection with single key (without return)
# 2023-11-10 v1.7 <axel.hahn@unibe.ch> replace docker-compose with "docker compose"
# 2023-11-10 v1.7 <axel.hahn@unibe.ch> replace docker-compose with "docker compose"
# 2023-11-13 v1.8 <axel.hahn@unibe.ch> UNDO "docker compose"; update infos
# 2023-11-13 v1.8 <axel.hahn@unibe.ch> UNDO "docker compose"; update infos
# 2023-11-15 v1.9 <axel.hahn@unibe.ch> add help; execute multiple actions by params; new menu item: open app
# ======================================================================
# ======================================================================
cd
$(
dirname
$0
)
cd
$(
dirname
$0
)
...
@@ -21,7 +22,7 @@ cd $( dirname $0 )
...
@@ -21,7 +22,7 @@ cd $( dirname $0 )
# git@git-repo.iml.unibe.ch:iml-open-source/docker-php-starterkit.git
# git@git-repo.iml.unibe.ch:iml-open-source/docker-php-starterkit.git
selfgitrepo
=
"docker-php-starterkit.git"
selfgitrepo
=
"docker-php-starterkit.git"
_version
=
"1.
8
"
_version
=
"1.
9
"
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# FUNCTIONS
# FUNCTIONS
...
@@ -39,6 +40,61 @@ function h3(){
...
@@ -39,6 +40,61 @@ function h3(){
echo
-e
"
\e
[34m-----
$*
\e
[0m"
echo
-e
"
\e
[34m-----
$*
\e
[0m"
}
}
# show help for param -h
function
showMenu
(){
echo
"
$(
_key g
)
- remove git data of starterkit"
echo
echo
"
$(
_key i
)
- init application: set permissions"
echo
"
$(
_key t
)
- generate files from templates"
echo
"
$(
_key T
)
- remove generated files"
echo
echo
"
$(
_key u
)
- startup containers docker-compose ... up -d"
echo
"
$(
_key U
)
- startup containers docker-compose ... up -d --build"
echo
"
$(
_key s
)
- shutdown containers docker-compose stop"
echo
"
$(
_key r
)
- remove containers docker-compose rm -f"
echo
echo
"
$(
_key m
)
- more infos"
echo
"
$(
_key o
)
- open app [
${
APP_NAME
}
]
$frontendurl
"
echo
"
$(
_key c
)
- console (bash)"
echo
echo
"
$(
_key q
)
- quit"
}
function
showHelp
(){
local
_self
=
$(
basename
"
$0
"
)
cat
<<
EOH
INITIALIZER FOR DOCKER APP v
$_version
A helper script written in Bash to bring up a PHP+Mysql application in docker.
Source : https://git-repo.iml.unibe.ch/iml-open-source/docker-php-starterkit
Docs : https://os-docs.iml.unibe.ch/docker-php-starterkit/
License: GNU GPL 3.0
(c) Institute for Medical Education; University of Bern
SYNTAX:
$_self
[-h|-v]
$_self
[menu key]
OPTIONS:
-h show this help and exit
-v show version exit
MENU KEYS:
In the interactive menu are some keys to init an action.
The same keys can be put as parameter to start this action.
You can add multiples keys to apply multiple actions.
$(
showMenu
)
EXAMPLES:
$_self
starts interactive mode
$_self
u bring up docker container(s) and stay in interactive mode
$_self
i q set write permissions and quit
EOH
}
# function _gitinstall(){
# function _gitinstall(){
# h2 "install/ update app from git repo ${gitrepo} in ${gittarget} ..."
# h2 "install/ update app from git repo ${gitrepo} in ${gittarget} ..."
# test -d ${gittarget} && ( cd ${gittarget} && git pull )
# test -d ${gittarget} && ( cd ${gittarget} && git pull )
...
@@ -191,6 +247,7 @@ function _removeGeneratedFiles(){
...
@@ -191,6 +247,7 @@ function _removeGeneratedFiles(){
done
done
}
}
# show running containers
function
_showContainers
(){
function
_showContainers
(){
local
bLong
=
$1
local
bLong
=
$1
h2 CONTAINERS
h2 CONTAINERS
...
@@ -202,6 +259,7 @@ function _showContainers(){
...
@@ -202,6 +259,7 @@ function _showContainers(){
}
}
# show urls for app container
function
_showBrowserurl
(){
function
_showBrowserurl
(){
echo
"In a web browser open:"
echo
"In a web browser open:"
echo
"
$frontendurl
"
echo
"
$frontendurl
"
...
@@ -210,7 +268,7 @@ function _showBrowserurl(){
...
@@ -210,7 +268,7 @@ function _showBrowserurl(){
fi
fi
}
}
#
a bit stupid ... i think I need to delete it.
#
detect + show ports and urls for app container and db container
function
_showInfos
(){
function
_showInfos
(){
_showContainers long
_showContainers long
h2 INFO
h2 INFO
...
@@ -246,39 +304,26 @@ function _key(){
...
@@ -246,39 +304,26 @@ function _key(){
# helper: wait for a return key
# helper: wait for a return key
function
_wait
(){
function
_wait
(){
echo
-n
"... press RETURN > "
;
read
-r
echo
-n
"... press RETURN > "
;
read
-r
-t
15
}
}
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# MAIN
# MAIN
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
action
=
$1
action
=
$1
;
shift
1
while
true
;
do
while
true
;
do
echo
echo
-e
"
\e
[32m===== INITIALIZER FOR DOCKER APP [
$APP_NAME
] v
$_version
=====
\e
[0m
\n\r
"
if
[
-z
"
$action
"
]
;
then
if
[
-z
"
$action
"
]
;
then
echo
echo
-e
"
\e
[32m===== INITIALIZER FOR DOCKER APP [
$APP_NAME
] v
$_version
=====
\e
[0m
\n\r
"
_showContainers
_showContainers
h2 MENU
h2 MENU
echo
"
$(
_key g
)
- remove git data of starterkit"
showMenu
echo
echo
"
$(
_key i
)
- init application: set permissions"
echo
"
$(
_key t
)
- generate files from templates"
echo
"
$(
_key T
)
- remove generated files"
echo
echo
"
$(
_key u
)
- startup containers docker-compose ... up -d"
echo
"
$(
_key U
)
- startup containers docker-compose ... up -d --build"
echo
"
$(
_key s
)
- shutdown containers docker-compose stop"
echo
"
$(
_key r
)
- remove containers docker-compose rm -f"
echo
echo
"
$(
_key m
)
- more infos"
echo
"
$(
_key c
)
- console (bash)"
echo
echo
"
$(
_key q
)
- quit"
echo
echo
echo
-n
" select >"
echo
-n
" select >"
read
-rn
1 action
read
-rn
1 action
...
@@ -286,6 +331,8 @@ while true; do
...
@@ -286,6 +331,8 @@ while true; do
fi
fi
case
"
$action
"
in
case
"
$action
"
in
"-h"
)
showHelp
;
exit
0
;;
"-v"
)
echo
$(
basename
$0
)
$_version
;
exit
0
;;
g
)
g
)
_removeGitdata
_removeGitdata
;;
;;
...
@@ -300,21 +347,17 @@ while true; do
...
@@ -300,21 +347,17 @@ while true; do
_removeGeneratedFiles
_removeGeneratedFiles
rm
-rf
containers
rm
-rf
containers
;;
;;
# not in the menu
# f)
# _removeGeneratedFiles
# _generateFiles
# _wait
# ;;
m
)
m
)
_showInfos
_showInfos
_wait
_wait
;;
;;
u|U
)
u|U
)
h2
"Bring up..."
dockerUp
=
"docker-compose -p "
$APP_NAME
" --verbose up -d --remove-orphans"
dockerUp
=
"docker-compose -p "
$APP_NAME
" --verbose up -d --remove-orphans"
if
[
"
$action
"
=
"U"
]
;
then
if
[
"
$action
"
=
"U"
]
;
then
dockerUp+
=
" --build"
dockerUp+
=
" --build"
fi
fi
echo
"
$dockerUp
"
if
$dockerUp
;
then
if
$dockerUp
;
then
_showBrowserurl
_showBrowserurl
else
else
...
@@ -326,24 +369,32 @@ while true; do
...
@@ -326,24 +369,32 @@ while true; do
_wait
_wait
;;
;;
s
)
s
)
h2
"Stopping..."
docker-compose
-p
"
$APP_NAME
"
stop
docker-compose
-p
"
$APP_NAME
"
stop
;;
;;
r
)
r
)
h2
"Removing..."
docker-compose
-p
"
$APP_NAME
"
rm
-f
docker-compose
-p
"
$APP_NAME
"
rm
-f
;;
;;
c
)
c
)
h2
"Console"
docker ps
docker ps
echo
-n
"id or name >"
echo
-n
"id or name >"
read
dockerid
read
dockerid
test
-z
"
$dockerid
"
||
docker
exec
-it
$dockerid
/bin/bash
test
-z
"
$dockerid
"
||
docker
exec
-it
$dockerid
/bin/bash
;;
;;
o
)
h2
"Console"
xdg-open
"
$frontendurl
"
;;
q
)
q
)
h2
"Bye!"
exit
0
;
exit
0
;
;;
;;
*
)
*
)
test
-n
"
$action
"
&&
(
echo
" ACTION FOR [
$action
] NOT IMPLEMENTED."
;
sleep
1
)
test
-n
"
$action
"
&&
(
echo
" ACTION FOR [
$action
] NOT IMPLEMENTED."
;
sleep
1
)
esac
esac
action
=
action
=
$1
;
shift
1
done
done
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment