From dc7f2bef8488fa0dd7309d54424116fc14d4f405 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Tue, 13 May 2025 13:18:03 +0200 Subject: [PATCH 1/3] handle addition variables config file for non sharable values --- docker/init.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/docker/init.sh b/docker/init.sh index 04fc725..3362aeb 100755 --- a/docker/init.sh +++ b/docker/init.sh @@ -31,11 +31,12 @@ # 2024-11-20 v1.24 <axel.hahn@unibe.ch> fix menu with started database less app; apply template permissions on target file; add $WEBURL; remove $frontendurl # 2024-11-20 v1.25 <axel.hahn@unibe.ch> fix menu startup containers # 2024-11-21 v1.26 <axel.hahn@unibe.ch> Reset colors in _checkConfig +# 2025-05-13 v1.27 <axel.hahn@unibe.ch> handle addition variables config file for non sharable values # ====================================================================== cd "$( dirname "$0" )" || exit 1 -_version="1.26" +_version="1.27" # init used vars gittarget= @@ -45,7 +46,7 @@ _self=$( basename "$0" ) # shellcheck source=/dev/null . "${_self}.cfg" || exit 1 - +. "${_self}_not_shared.cfg" 2>/dev/null # git@git-repo.iml.unibe.ch:iml-open-source/docker-php-starterkit.git selfgitrepo="docker-php-starterkit.git" @@ -406,15 +407,18 @@ function _fix_no-db(){ # used in _generateFiles function _getreplaces(){ # loop over vars to make the replacement - grep "^[a-zA-Z]" "$_self.cfg" | while read -r line + for myfile in "${_self}.cfg" "${_self}_not_shared.cfg" do - # echo replacement: $line - mykey=$( echo "$line" | cut -f 1 -d '=' ) - myvalue="$( eval echo \"\$"$mykey"\" )" + grep "^[a-zA-Z]" "${myfile}" | while read -r line + do + # echo replacement: $line + mykey=$( echo "$line" | cut -f 1 -d '=' ) + myvalue="$( eval echo \"\$"$mykey"\" )" - # TODO: multiline values fail here in replacement with sed - echo -e "s#{{$mykey}}#${myvalue}#g" + # TODO: multiline values fail here in replacement with sed + echo -e "s#{{$mykey}}#${myvalue}#g" + done done } -- GitLab From 7f0e01ed8cef36fe3487bf9309af34cb5c63f515 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Tue, 13 May 2025 13:18:21 +0200 Subject: [PATCH 2/3] add dist file for your secrets --- docker/init.sh_not_shared.cfg.dist | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 docker/init.sh_not_shared.cfg.dist diff --git a/docker/init.sh_not_shared.cfg.dist b/docker/init.sh_not_shared.cfg.dist new file mode 100644 index 0000000..ccbbf36 --- /dev/null +++ b/docker/init.sh_not_shared.cfg.dist @@ -0,0 +1,11 @@ +# ====================================================================== +# +# senstive configuration not to check in into your git repository +# +# ====================================================================== + +OIDCCryptoPassphrase=0123456789 +OIDCClientSecret='YOUR-SECRET-HERE' +OIDCProviderMetadataURL='https://keycloak.example.com/realms/YOUR-REALM/.well-known/openid-configuration' + +# ---------------------------------------------------------------------- -- GitLab From d7fe074f9327fde3ecebf253faadf5d3f23c4909 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Tue, 13 May 2025 13:37:49 +0200 Subject: [PATCH 3/3] update docs --- "docs/30_\360\237\252\204_Init_a_new_project.md" | 1 + .../20_Templates.md" | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git "a/docs/30_\360\237\252\204_Init_a_new_project.md" "b/docs/30_\360\237\252\204_Init_a_new_project.md" index 71f4d3e..b6fbd11 100644 --- "a/docs/30_\360\237\252\204_Init_a_new_project.md" +++ "b/docs/30_\360\237\252\204_Init_a_new_project.md" @@ -28,6 +28,7 @@ The initial file structure looks like this: ├── docker # Docker data │ ├── init.sh << shellscript for initialization │ ├── init.sh.cfg << config file +│ ├── init.sh_not_shared.cfg.dist << config file template │ └── templates << folder with templates │ ├── docker-compose.yml │ ├── dot_env diff --git "a/docs/40_\342\232\231\357\270\217_Configuration/20_Templates.md" "b/docs/40_\342\232\231\357\270\217_Configuration/20_Templates.md" index df515a0..5b94306 100644 --- "a/docs/40_\342\232\231\357\270\217_Configuration/20_Templates.md" +++ "b/docs/40_\342\232\231\357\270\217_Configuration/20_Templates.md" @@ -4,7 +4,7 @@ * All files in the `docker/templates/` directory will be processed. This also means: you can add as many custom files here as you want - and the will processed too. * in the first line must be a line `# TARGET: [name of target file]` to define the target file. If this line does not exist, then the file will be skipped. * Placeholdrs have the syntax variable in double brackets, i.e. `{{VARNAME}}` -* variables to be replaced are those in docker/init.sh.cfg and `{{genrator}}` +* variables to be replaced are those in docker/init.sh.cfg and `{{generator}}` # Templates @@ -147,7 +147,10 @@ and php modules. To override default module settings see template with "extra-p FROM php:{{APP_PHP_VERSION}}-apache # install packages -RUN apt-get update && apt-get install -y {{APP_APT_PACKAGES}} +RUN rm -rf /var/lib/apt/lists/* +RUN mkdir -p /var/cache/apt/archives/partial +RUN apt-get update +RUN apt-get install -y {{APP_APT_PACKAGES}} # enable apache modules RUN a2enmod {{APP_APACHE_MODULES}} @@ -204,7 +207,7 @@ For the security headers in the buttom part the apache module "headers" ist need Custom PHP config file for you additional settings. Showing all warnings and errors is enabled as default. -✴️ You **SHOULD** change this to setup Mysql database service for your needs. +✴️ You **SHOULD** change this to correct timezone or define other settings ```ini # TARGET: docker/containers/web-server/php/extra-php-config.ini @@ -216,6 +219,13 @@ Showing all warnings and errors is enabled as default. error_reporting=E_ALL display_errors=1 +; If you want to catch emails locally in your dev environment +; eg. https://os-docs.iml.unibe.ch/php-emailcatcher/ +; sendmail_path = "php {{WEBROOT}}/vendor/emailcatcher/php-sendmail.php" + +[Date] +date.timezone = Europe/Zurich + ; ---------------------------------------------------------------------- ; XDEBUG STUFF BELOW ; ---------------------------------------------------------------------- -- GitLab