From 861ac2b821ae6ca7d605e5374c31c42ca661f034 Mon Sep 17 00:00:00 2001 From: Apolo Pena <3060702+apolopena@users.noreply.github.com> Date: Thu, 27 Jan 2022 21:06:00 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20RELEASE:=20Version=201.4.0=20(#1?= =?UTF-8?q?89)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update starter.ini * Update init-gitpod.sh * Update .gitpod.Dockerfile Update xdebug configuration to own config file for ioncube support Add global composer bin folder to $PATH Add update-ca-certificates * Update .gitpod.Dockerfile Add composer bin to $PATH * Update .gitpod.Dockerfile * Update ioncube setup * Update README.md Fix #153 * Update utils.sh Fix #152 * Update before-tasks.sh Fix #151 * Update starter.ini Fix #149 * Update update-pma-pws-help.txt Fix #147 * Update README.md Fix #147 * Update start-server.sh Fix #145 * BaseImage PHP8 * Update to PHP 8.0 * Update .gitpod.Dockerfile * Update to PHP 8.0 Fix #155 * Fix PHP8 Path * Fix PHP 8 Path * Clear APT lists * Add Workspace/Project composer bin folder to $PATH * Add Workspace/Project composer bin folder to $PATH * Update update-pma-pws-help.txt * Update .gitpod.yml * optional php7.4 install * optional php7.4 install * πŸ› FIX: optional php7.4 install: add sudo * πŸ› FIX: optional php7.4 install: in progress * πŸ› FIX: optional php7.4 install: in progress * πŸ› FIX: optional php7.4 install: in progress * ♻️ REFACTOR: comments and /~https://github.com/apolopena/gitpod-laravel-starter/issues/156 * ♻️ REFACTOR: /~https://github.com/apolopena/gitpod-laravel-starter/issues/157 in progress * ♻️ REFACTOR: Consolidate docker layers: in progress * πŸ› FIX: 157: consolidate docker layers: bad file names in first RUN instruction * πŸ› FIX: 157: consolidate docker layers: debug missing tmp file * πŸ€– TEST: 157: consolidate docker layers: use /var/tmp rather than /tmp * πŸ› FIX: 157: consolidate docker layers: swap gitpod apt-get install function for standard one that doesnt rm /tmp * πŸ› FIX: 157: consolidate docker layers: swap gitpod apt-get install function for standard one that doesnt rm /tmp * πŸ› FIX: 157: consolidate docker layers: swap gitpod apt-get install function for standard one that doesnt rm /tmp * πŸ› FIX: 157: consolidate docker layers: swap gitpod apt-get install function for standard one that doesnt rm /tmp * πŸ‘Œ IMPROVE: 156 Install core, additional and optional PHP version packages * βž• ADD: get php major and minor version * πŸ€– TEST: force docker image build * πŸ› FIX: log for unsupported php version in starter.ini * πŸ› FIX: use array for package args rather than a string * πŸ€– TEST: force docker image build * πŸ‘Œ IMPROVE: log messages when swapping php versions * πŸ€– TEST: force docker image build * πŸ‘Œ IMPROVE: log messages when swapping php versions * πŸ’‘ UPDATE COMMENTS: everytime should be two words * πŸ› FIX: capitalize you * πŸ’‘ UPDATE COMMENTS: capitalize the word you in first bullet point of securing phpMyAdmin * πŸ“– DOC: make Technology lowercase in Welcome section * πŸ’‘ UPDATE COMMENTS: must be run as a sudo user * πŸ› FIX: move composer bin to /home/apena/.nvm/versions/node/v12.4.0/bin:/home/apena/go/bin:/home/apena/.local/bin:/home/apena/bin:/usr/local/bin:/home/apena/.vscode-server/bin/fe719cd3e5825bf14e14182fddeb88ee8daf044f/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/PROGRAM FILES/DELL/DW WLAN CARD:/mnt/c/PROGRAM FILES/INTEL/ICLS CLIENT/:/mnt/c/WINDOWS/SYSTEM32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/SYSTEM32/WBEM:/mnt/c/WINDOWS/SYSTEM32/WINDOWSPOWERSHELL/V1.0/:/mnt/c/WINDOWS/SYSTEM32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/SYSTEM32/WBEM:/mnt/c/WINDOWS/SYSTEM32/WINDOWSPOWERSHELL/V1.0/:/mnt/c/WINDOWS/SYSTEM32/OPENSSH/:/mnt/c/PROGRAMDATA/CHOCOLATEY/BIN:/mnt/c/HASHICORP/VAGRANT/BIN:/mnt/c/PROGRAM FILES (X86)/MELD/:/mnt/c/PROGRAM FILES (X86)/INTEL/INTEL(R) MANAGEMENT ENGINE COMPONENTS/DAL:/mnt/c/PROGRAM FILES/INTEL/INTEL(R) MANAGEMENT ENGINE COMPONENTS/DAL:/mnt/c/WINDOWS/SYSTEM32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/SYSTEM32/WBEM:/mnt/c/WINDOWS/SYSTEM32/WINDOWSPOWERSHELL/V1.0/:/mnt/c/WINDOWS/SYSTEM32/OPENSSH/:/mnt/c/USERS/PENAV/APPDATA/ROAMING/NVM:/mnt/c/PROGRAM FILES/NODEJS:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/ProgramData/DockerDesktop/version-bin:/mnt/c/Python27/:/mnt/c/Python27/Scripts:/mnt/c/Users/penav/AppData/Local/Programs/Python/Python38/:/mnt/c/Users/penav/AppData/Local/Programs/Python/Python38/Scripts/:/mnt/c/Users/penav/.poetry/bin:/mnt/c/Users/penav/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files/MongoDB/Server/4.2/bin:/mnt/c/Program Files/heroku/bin:/mnt/c/Users/penav/AppData/Local/Google/Cloud SDK/google-cloud-sdk/bin:/mnt/c/Users/penav/AppData/Roaming/nvm:/mnt/c/Program Files/nodejs:/mnt/c/Users/penav/AppData/Local/Programs/Microsoft VS Code/bin:/usr/local/go/bin:/home/apena/.config/yarn/global/node_modules/.bin block above setting of initialized flag * move composer bin to PATH block above setting of initialized flag * βž• ADD: dynamic xdebug install * πŸ› FIX: typos/syntax errors * πŸ€– TEST: force docker image build * πŸ› FIX: generate xdebug conf * πŸ€– TEST: force docker image build * πŸ› FIX: xdebug conf not generating * πŸ€– TEST: force docker image build * πŸ› FIX: xdebug.ini name * πŸ€– TEST: hardcoded php version * πŸ€– TEST: force docker image build * πŸ€– TEST: reverting code * πŸ› FIX: bad log syntax and set phpize specifically * πŸ€– TEST: install-xdebug.sh * πŸ› FIX: missing phpize * πŸ€– TEST: force docker image build * πŸ€– TEST: hardcoded php version to 7.4 for now * πŸ€– TEST: hardcode phpize path for php7.4 for now * βž• ADD: libapache2-mod-php7.4 and --set php-config * πŸ€– TEST: force docker image build * ♻️ REFACTOR: /~https://github.com/apolopena/gitpod-laravel-starter/issues/156 * ⚰️ REMOVE: extraneous file * ♻️ REFACTOR: /~https://github.com/apolopena/gitpod-laravel-starter/issues/156 * πŸ€– TEST: force docker image build * πŸ€– TEST: Gitpod us cluster is unstable, forcing docker image build * πŸ€– TEST: force docker image build * πŸ€– TEST: force docker * ♻️ REFACTOR: /~https://github.com/apolopena/gitpod-laravel-starter/issues/156 * Add GnuPG Support * Update .gitpod.Dockerfile * Add Log Notice and Description Fix #170 * πŸ› FIX: rebuild package list * πŸ€– TEST: build docker image * πŸ› FIX: try conditionally disabling php module for apache before installing php * πŸ€– TEST: docker image build * πŸ€– TEST: trying to properly purge gp installed php * πŸ€– TEST: docker * πŸ€– TEST: trying to properly purge gp installed php * πŸ€– TEST: docker * πŸ› FIX: php-fpm conf path * πŸ€– TEST: docker * πŸ› FIX: apache conf getting overwritten by potential php install * πŸ› FIX: php-fpm.conf path * πŸ€– TEST: docker * ♻️ REFACTOR: autogeneration of php-fpm * πŸ€– TEST: docker * πŸ› FIX: set apache conf * πŸ› FIX: bad tabs in php-fpm.conf generation * πŸ€– TEST: docker * ♻️ REFACTOR: apache configuration * πŸ› FIX: /~https://github.com/apolopena/gitpod-laravel-starter/issues/172 * πŸ€– TEST: docker * πŸ› FIX: typo * πŸ€– TEST: /~https://github.com/apolopena/gitpod-laravel-starter/issues/173 * πŸ€– TEST: debugging #171 * πŸ€– TEST: docker * πŸ› FIX: /~https://github.com/apolopena/gitpod-laravel-starter/issues/174 * πŸ› FIX: trim any potential leading or tailing whitepsace from the parsed ppa value * πŸ€– TEST: docker * πŸ€– TEST: /~https://github.com/apolopena/gitpod-laravel-starter/issues/174 again * πŸ€– TEST: docker * πŸ› FIX: /~https://github.com/apolopena/gitpod-laravel-starter/issues/148 * πŸ› FIX: log messages for /~https://github.com/apolopena/gitpod-laravel-starter/pull/171/ * ♻️ REFACTOR: /~https://github.com/apolopena/gitpod-laravel-starter/issues/165 and /~https://github.com/apolopena/gitpod-laravel-starter/issues/170 * πŸ› FIX: /~https://github.com/apolopena/gitpod-laravel-starter/issues/158 * πŸ› FIX: bump hardcoded gls version in preparation for v1.4 release * πŸ› FIX: /~https://github.com/apolopena/gitpod-laravel-starter/issues/168 * πŸ› FIX: /~https://github.com/apolopena/gitpod-laravel-starter/issues/161 and log messages for /~https://github.com/apolopena/gitpod-laravel-starter/issues/168 and autogeneration of php-fpm.conf * πŸ› FIX: /~https://github.com/apolopena/gitpod-laravel-starter/issues/161 * πŸ› FIX: /~https://github.com/apolopena/gitpod-laravel-starter/issues/168 * πŸ€– TEST: /~https://github.com/apolopena/gitpod-laravel-starter/issues/168 * πŸ› FIX: comment * πŸ€– TEST: /~https://github.com/apolopena/gitpod-laravel-starter/issues/168 * πŸ€– TEST: /~https://github.com/apolopena/gitpod-laravel-starter/issues/168 * πŸ› FIX: move autogeneration of files as per starter.ini to after rsync * πŸ› FIX: shorten log message gor phpinfo.php autogenaration * πŸ› FIX: parse .vscode/settings.json first * Show only stderr for gpg * πŸ’‘ UPDATE COMMENTS: improve log msg * πŸ› FIX: /~https://github.com/apolopena/gitpod-laravel-starter/issues/164 * Update feature-request-.md Fix hidden comment issue * πŸ› FIX: /~https://github.com/apolopena/gitpod-laravel-starter/commit/36149918059bc56bdf65337b210eacb688ac9fee * πŸ“– DOC: /~https://github.com/apolopena/gitpod-laravel-starter/issues/160 * πŸ› FIX: /~https://github.com/apolopena/gitpod-laravel-starter/issues/156 * πŸ€– TEST: docker * πŸ“– DOC: /~https://github.com/apolopena/gitpod-laravel-starter/issues/173 * πŸ€– TEST: docker * πŸ› FIX: /~https://github.com/apolopena/gitpod-laravel-starter/issues/156 for ioncube * πŸ€– TEST: docker * πŸ€– TEST: ioncube install, TODO: swap this back to the default of 0 after testing * πŸ€– TEST: do not install ioncube if php version is > 7.4 * ♻️ REFACTOR: remove generation of php-fpm conf * ♻️ REFACTOR: generation of php-fpm.conf for /~https://github.com/apolopena/gitpod-laravel-starter/issues/156 * πŸ€– TEST: force docker * ⚰️ REMOVE: autogeneration of php-fpm.conf * πŸ€– TEST: force docker * πŸ› FIX: proper exit * πŸ€– TEST: force docker * πŸ› FIX: get current php version * ♻️ REFACTOR: move autogen of php-fpm.conf * ♻️ REFACTOR: ioncube install for php 7.4 * πŸ’‘ UPDATE COMMENTS: PHP ppa comment * πŸ€– TEST: force docker * πŸ› FIX: bump npm install to 8.3.2 * πŸ› FIX: add phpfpm install for php versions > 7.4 * πŸ€– TEST: force docker * ♻️ REFACTOR: move invalidate cache back to the bottom of the file * πŸ› FIX: path to utils.sh * πŸ€– TEST: force docker * πŸ› FIX: log to workspace-image.log when using existing gitpodlatest version of php * πŸ› FIX: php version comparison for installing phpfpm * πŸ€– TEST: install php 7.4 * πŸ€– TEST: invalid value for php version * πŸ€– TEST: force docker * πŸ› FIX: fallback routine for /~https://github.com/apolopena/gitpod-laravel-starter/issues/156 * πŸ€– TEST: force docker * πŸ€– TEST: /~https://github.com/apolopena/gitpod-laravel-starter/issues/156 install php 7.4 explicity * πŸ€– TEST: force docker * πŸ› FIX: restore default value for ioncube install to 0 * πŸ€– TEST: force docker * πŸ“– DOC: /~https://github.com/apolopena/gitpod-laravel-starter/issues/180 * πŸ“– DOC: /~https://github.com/apolopena/gitpod-laravel-starter/issues/181 * ♻️ REFACTOR: /~https://github.com/apolopena/gitpod-laravel-starter/issues/170 * πŸ› FIX: log gpg_key_id * πŸ€– TEST: gitpod with git signed commit * πŸ› FIX: unset GPG_KEY once successful * πŸ€– TEST: test gpg trusted key * πŸ€– TEST: gpg signed commit * πŸ› FIX: /~https://github.com/apolopena/gitpod-laravel-starter/issues/170 swap git email to env GPG_MATCH_GIT_TO_EMAIL if present * πŸ› FIX: typo * πŸ€– TEST: email match for gpg * πŸ› FIX: make gpg key logs silent except for errors * πŸ› FIX: /~https://github.com/apolopena/gitpod-laravel-starter/issues/170 Support GPG_AUTO_ULTIMATE_TRUST to automagically give ultimate trust to a GPG_KEY * ⚰️ REMOVE: extraneous space in GPG_AUTO_ULTIMATE_TRUST conditional * πŸ› FIX: /~https://github.com/apolopena/gitpod-laravel-starter/issues/170 make success a slient log for GPG_AUTO_ULTIMATE_TRUST * πŸ› FIX: reduce verbosity of all log messages * πŸ› FIX: /~https://github.com/apolopena/gitpod-laravel-starter/issues/170 log improper use of GPG env vars * ⚰️ REMOVE: redundant file * πŸ€– TEST: remove hotfix #140 * πŸ€– TEST: /~https://github.com/apolopena/gitpod-laravel-starter/issues/185 * πŸ€– TEST: /~https://github.com/apolopena/gitpod-laravel-starter/issues/185 * πŸ› FIX: /~https://github.com/apolopena/gitpod-laravel-starter/issues/188 * πŸ› FIX: /~https://github.com/apolopena/gitpod-laravel-starter/issues/185 * πŸ“– DOC: /~https://github.com/apolopena/gitpod-laravel-starter/issues/183 * ⚰️ REMOVE: test file * πŸ“– DOC: dev-qa fix for /~https://github.com/apolopena/gitpod-laravel-starter/issues/183 * πŸ‘Œ IMPROVE: Documentation formatting, broken links and /~https://github.com/apolopena/gitpod-laravel-starter/issues/176 Co-authored-by: BjΓΆrn Strausmann --- .gitattributes | 1 + .github/ISSUE_TEMPLATE/feature-request-.md | 2 +- .gitpod.Dockerfile | 83 ++++---- .gitpod.yml | 2 +- .gp/bash/before-tasks.sh | 69 ++++++- .gp/bash/examples/change-passwords.sh | 110 ----------- .gp/bash/examples/init-react-example.sh | 6 +- .../examples/init-react-typescript-example.sh | 8 +- .gp/bash/helpers.sh | 25 ++- .gp/bash/init-complete.sh | 3 + .gp/bash/init-gitpod.sh | 79 +++++++- .gp/bash/init-optional-scaffolding.sh | 2 - .gp/bash/install-core-packages.sh | 37 ++++ .gp/bash/install-project-packages.sh | 35 ++++ .gp/bash/install-xdebug.sh | 54 ++++++ .gp/bash/php.sh | 177 ++++++++++++++++++ .gp/bash/start-server.sh | 4 +- .gp/bash/utils.sh | 30 ++- .gp/bash/workspace-init-logger.sh | 8 +- .gp/conf/php-fpm/php-fpm.conf | 18 +- .gp/conf/vscode/disable_preview_tab.txt | 2 + .gp/conf/xdebug/xdebug.ini | 6 - .gp/snippets/messages/update-pma-pws-help.txt | 8 +- .gp/snippets/server-functions.sh | 6 +- README.md | 157 +++++++++++----- starter.ini | 48 ++++- 26 files changed, 724 insertions(+), 256 deletions(-) create mode 100644 .gitattributes delete mode 100644 .gp/bash/examples/change-passwords.sh create mode 100644 .gp/bash/install-core-packages.sh create mode 100644 .gp/bash/install-project-packages.sh create mode 100644 .gp/bash/install-xdebug.sh create mode 100644 .gp/bash/php.sh create mode 100644 .gp/conf/vscode/disable_preview_tab.txt delete mode 100644 .gp/conf/xdebug/xdebug.ini diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..21256661 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature-request-.md b/.github/ISSUE_TEMPLATE/feature-request-.md index ee9cbe38..9783f86b 100644 --- a/.github/ISSUE_TEMPLATE/feature-request-.md +++ b/.github/ISSUE_TEMPLATE/feature-request-.md @@ -17,7 +17,7 @@ assignees: '' ## Constraints and Assumptions - + ## Alternatives or Workarounds diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index afe36316..18eb217b 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -2,52 +2,55 @@ FROM gitpod/workspace-mysql USER gitpod +# Copy required files to /tmp +COPY --chown=gitpod:gitpod .gp/bash/update-composer.sh \ + starter.ini \ + .gp/conf/apache/apache2.conf \ + .gp/conf/nginx/nginx.conf \ + .gp/bash/.bash_aliases \ + .gp/bash/php.sh \ + .gp/bash/install-core-packages.sh \ + .gp/bash/install-project-packages.sh \ + .gp/bash/install-xdebug.sh \ + .gp/bash/update-composer.sh \ + .gp/bash/utils.sh \ + .gp/bash/scaffold-project.sh \ + .gp/snippets/server-functions.sh \ + .gp/snippets/browser-functions.sh \ + .gp/bash/bin/hot-reload.sh \ + /tmp/ + +# Create log files and move required files to their proper locations RUN sudo touch /var/log/workspace-image.log \ && sudo chmod 666 /var/log/workspace-image.log \ && sudo touch /var/log/workspace-init.log \ && sudo chmod 666 /var/log/workspace-init.log \ && sudo touch /var/log/xdebug.log \ - && sudo chmod 666 /var/log/xdebug.log - -RUN echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections \ - && sudo apt-get update -q \ - && sudo apt-get -y install php7.4-fpm rsync grc shellcheck \ - && sudo apt-get clean - -COPY --chown=gitpod:gitpod .gp/conf/xdebug/xdebug.ini /tmp -RUN wget http://xdebug.org/files/xdebug-3.0.4.tgz \ - && tar -xvzf xdebug-3.0.4.tgz \ - && cd xdebug-3.0.4 \ - && phpize \ - && ./configure --enable-xdebug \ - && make \ - && sudo cp modules/xdebug.so /usr/lib/php/20190902/xdebug.so \ - && sudo bash -c "echo -e '\nzend_extension = /usr/lib/php/20190902/xdebug.so\n[XDebug]\nxdebug.client_host = 127.0.0.1\nxdebug.client_port = 9009\nxdebug.log = /var/log/xdebug.log\nxdebug.mode = debug\nxdebug.start_with_request = trigger\n' >> /etc/php/7.4/cli/php.ini" \ - && sudo bash -c "echo -e '\nzend_extension = /usr/lib/php/20190902/xdebug.so\n[XDebug]\nxdebug.client_host = 127.0.0.1\nxdebug.client_port = 9009\nxdebug.log = /var/log/xdebug.log\nxdebug.mode = debug\nxdebug.start_with_request = trigger\n' >> /etc/php/7.4/apache2/php.ini" \ - && sudo cp /tmp/xdebug.ini /etc/php/7.4/mods-available/xdebug.ini \ - && sudo ln -s /etc/php/7.4/mods-available/xdebug.ini /etc/php/7.4/fpm/conf.d - -COPY --chown=gitpod:gitpod .gp/bash/update-composer.sh /tmp -RUN sudo bash -c ". /tmp/update-composer.sh" && rm /tmp/update-composer.sh + && sudo chmod 666 /var/log/xdebug.log \ + && sudo cp /tmp/apache2.conf /etc/apache2/apache2.conf \ + && sudo mv /tmp/nginx.conf /etc/nginx/nginx.conf \ + && sudo mv /tmp/.bash_aliases /home/gitpod/.bash_aliases \ + && sudo mv /tmp/server-functions.sh /home/gitpod/.bashrc.d/server-functions \ + && sudo mv /tmp/browser-functions.sh /home/gitpod/.bashrc.d/browser-functions \ + && sudo mv /tmp/hot-reload.sh /usr/local/bin/hot-reload -# gitpod trick to bypass the docker caching mechanism for all lines below this one -# just increment the value each time you want to bypass the cache system -ENV INVALIDATE_CACHE=184 +# Install and configure php and php-fpm as specified in starter.ini +RUN sudo bash -c ". /tmp/php.sh" && rm /tmp/php.sh -COPY --chown=gitpod:gitpod .gp/conf/apache/apache2.conf /etc/apache2/apache2.conf -COPY --chown=gitpod:gitpod .gp/conf/nginx/nginx.conf /etc/nginx/nginx.conf -COPY --chown=gitpod:gitpod .gp/bash/.bash_aliases /home/gitpod -COPY --chown=gitpod:gitpod .gp/bash/utils.sh /tmp -COPY --chown=gitpod:gitpod starter.ini /tmp -COPY --chown=gitpod:gitpod .gp/bash/scaffold-project.sh /tmp -RUN sudo bash -c ". /tmp/scaffold-project.sh" && rm /tmp/scaffold-project.sh +# Install core packages for gitpod-laravel-starter +RUN sudo bash -c ". /tmp/install-core-packages.sh" && rm /tmp/install-core-packages.sh + +# Install any user specified packages for the project +RUN sudo bash -c ". /tmp/install-project-packages.sh" && rm /tmp/install-project-packages.sh + +# Download, compile, install and configure xdebug from source +RUN sudo bash -c ". /tmp/install-xdebug.sh" && rm /tmp/install-xdebug.sh -# Aliases -COPY --chown=gitpod:gitpod .gp/snippets/server-functions.sh /tmp -COPY --chown=gitpod:gitpod .gp/snippets/browser-functions.sh /tmp -RUN cp /tmp/server-functions.sh ~/.bashrc.d/server-functions \ - && cp /tmp/browser-functions.sh ~/.bashrc.d/browser-functions +# Update composer. TODO: /~https://github.com/apolopena/gitpod-laravel-starter/issues/159 +RUN sudo bash -c ". /tmp/update-composer.sh" && rm /tmp/update-composer.sh + +# Scaffold the Laravel project +RUN sudo bash -c ". /tmp/scaffold-project.sh" && rm /tmp/scaffold-project.sh -# Customs cli's and user scripts for /usr/local/bin -COPY --chown=gitpod:gitpod .gp/bash/bin/hot-reload.sh /usr/local/bin -RUN sudo mv /usr/local/bin/hot-reload.sh /usr/local/bin/hot-reload \ No newline at end of file +# Force the docker image to build by incrementing this value +ENV INVALIDATE_CACHE=226 \ No newline at end of file diff --git a/.gitpod.yml b/.gitpod.yml index 6b3fb346..4979b795 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -38,4 +38,4 @@ tasks: vscode: extensions: - - felixfbecker.php-debug@1.14.12:e02f0fde2ddd444c182ba531e8b09afd + - felixfbecker.php-debug diff --git a/.gp/bash/before-tasks.sh b/.gp/bash/before-tasks.sh index 52c8692e..fcab8ab2 100644 --- a/.gp/bash/before-tasks.sh +++ b/.gp/bash/before-tasks.sh @@ -5,7 +5,7 @@ # # before-tasks.sh # Description: -# Tasks that should be run everytime the worspace is created or started. +# Tasks that should be run every time the workspace is created or started. # # Notes: # Gitpod currently does not persist files in the home directory so we must write them @@ -18,14 +18,13 @@ # Some rake tasks are dynamic and depend on the configuration in starter.ini if [[ $(bash .gp/bash/utils.sh parse_ini_value starter.ini github-changelog-generator install) ]]; then msg="Writing rake tasks" - log_silent "$msg" && if bash .gp/bash/init-rake-tasks.sh; then log_silent "SUCCESS: $msg" else log -e "ERROR: $msg" fi fi - +git status # Aliases for git msg="git aliases have been written" bash .gp/bash/utils.sh add_file_to_file_after "\\[alias\\]" .gp/snippets/git/emoji-log ~/.gitconfig && @@ -33,6 +32,68 @@ bash .gp/bash/utils.sh add_file_to_file_after "\\[alias\\]" .gp/snippets/git/ali log_silent "$msg" && log_silent "try: git a or: git aliases to see what is available." +# BEGIN: Enable GPG key to sign Git commits. +# Error handling for improper use of GPG environment variables +err_msg_prefix1="A GPG_KEY was found but it's corresponding GPG_KEY_ID was not." +err_msg_prefix2="A GPG_KEY_ID was found but it's corresponding GPG_KEY was not." +err_msg_suffix="Git commits will not be signed." +[[ -n $GPG_KEY && -z $GPG_KEY_ID ]] && +log -e "ERROR: $err_msg_prefix1 $err_msg_suffix" +[[ -n $GPG_KEY_ID && -z $GPG_KEY ]] && +log -e "ERROR: $err_msg_prefix2 $err_msg_suffix" +# Main GPG key logic +if [[ -n $GPG_KEY && -n $GPG_KEY_ID ]]; then + gpg_conf_path=~/.gnupg/gpg.conf + msg="Enabling Git commit signing for GPG key id: $GPG_KEY_ID" + gpg -q --batch --import <(echo "$GPG_KEY" | base64 -d) && + echo 'pinentry-mode loopback' >> "$gpg_conf_path" && + git config --global user.signingkey "$GPG_KEY_ID" && + git config commit.gpgsign true + ec=$? + if [[ $ec -eq 0 ]]; then + log_silent "SUCCESS: $msg" + # Change the git email if the user needs it (ensures the commit is marked as 'Verified') + if [[ -n $GPG_MATCH_GIT_TO_EMAIL ]]; then + msg="Setting user.email in ~/.gitconfig to $GPG_MATCH_GIT_TO_EMAIL" + if git config --global user.email "$GPG_MATCH_GIT_TO_EMAIL"; then + log_silent "SUCCESS: $msg" + else + log -e "ERROR: $msg" + fi + fi + # Ultimately trust the key, bump to lowercase and check the value of the directive + if [[ $(echo "$GPG_AUTO_ULTIMATE_TRUST" | tr '[:upper:]' '[:lower:]') == yes ]]; then + msg="Automagically giving ultimate trust to GPG_KEY_ID: $GPG_KEY_ID" + # Prepend the key id as a trusted hex and update the local database with a silent arbitrary gpg call + echo -e ""trusted-key 0x"$GPG_KEY_ID""\n$(cat $gpg_conf_path)" > "$gpg_conf_path" && + gpg --list-keys &> /dev/null + ec=$? + if [[ $ec -eq 0 ]]; then + log_silent "SUCCESS: $msg" + else + log -e "ERROR: $msg" + fi + fi + else + log -e "ERROR: $msg" + fi +fi +# END: Enable GPG key to sign Git commits. + +# Auto activate intelephense if license key is available +if [[ -n $INTELEPHENSE_LICENSEKEY ]]; then + msg="creating $HOME/intelephense/licence.txt" + log_silent "INTELEPHENSE_LICENSEKEY environment variable found, $msg" + mkdir -p "$HOME/intelephense" && + echo "$INTELEPHENSE_LICENSEKEY" > "$HOME/intelephense/licence.txt" && + ec=$? + if [[ $ec -eq 0 ]]; then + log "SUCCESS: $msg" + else + log -e "ERROR: $msg" + fi +fi + # Restore files marked as persistant such as workspace-init.log # See persist_file in bash/helpers.sh for how the system works # Keep this block at the bottom of the file so that any logging from this @@ -40,4 +101,4 @@ log_silent "try: git a or: git aliases to see what is available." # will get written to from this script upon every workspace restart. if [[ $(bash .gp/bash/helpers.sh is_inited) == 1 ]]; then bash .gp/bash/helpers.sh restore_persistent_files "$GITPOD_REPO_ROOT" -fi \ No newline at end of file +fi diff --git a/.gp/bash/examples/change-passwords.sh b/.gp/bash/examples/change-passwords.sh deleted file mode 100644 index 1d69215a..00000000 --- a/.gp/bash/examples/change-passwords.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash -# -# SPDX-License-Identifier: MIT -# Copyright Β© 2021 Apolo Pena -# -# change-passwords.sh -# Description: -# Changes passwords for phpmyadmin from the defaults in version control to the values set in .starter.env -# -# Notes: -# This script should be always run at least once by the user as an mandatory additional layer of security -# This script requires the file .starter.env to exist along will all the key value pairs set. -# -# See: -# example.starter.ini - -# Load spinner -. .gp/bash/spinner.sh - -phpmyadmin() { - [ ! -d public/phpmyadmin ] && echo "No installation of phpmyadmin was found. Process aborted. " && exit 1 - # Keep keys in sequence. Add new keys to the end of the array - local keys=(PHPMYADMIN_SUPERUSER_PW PHPMYADMIN_CONTROLUSER_PW) - - local name="change-passwords.sh phpmyadmin" - local err="$name ERROR:" - local config_file="public/phpmyadmin/config.inc.php" - local all_zeros='^[0]+$' - local exit_codes - local values - - for key in "${keys[@]}"; do - local value - value="$(bash .gp/bash/helpers.sh get_starter_env_val "$key")" - values+=("$(bash .gp/bash/helpers.sh get_starter_env_val "$key")") - local code=$? - exit_codes+=$code - # show error message of called function - [ $code != 0 ] && echo "$value" - done - - if [[ ! $(echo "${exit_codes[@]}" | tr -d '[:space:]') =~ $all_zeros ]]; then - echo "$err retrieving values, no passwords were changed." - exit 1 - fi - - # Values have been set and there are no errors so far so change passwords - i=0 - for key in "${keys[@]}"; do - case $key in - "${keys[0]}") - msg="Changing password for phpmyadmin user 'pmasu' to the value found in .starter.env" - start_spinner "$msg" - mysql -e "ALTER USER 'pmasu'@'%' IDENTIFIED BY '${values[$i]}'; FLUSH PRIVILEGES;" - stop_spinner $? - ;; - "${keys[1]}") - msg="Changing password for phpmyadmin user 'pma' to the value found in .starter.env" - start_spinner "$msg" - mysql -e "ALTER USER 'pma'@'localhost' IDENTIFIED BY '${values[$i]}'; FLUSH PRIVILEGES;" - err_code=$? - stop_spinner $err_code - if [ $err_code == 0 ]; then - msg="Updating control user password in $config_file" - line="\$cfg['Servers'][\$i]['controlpass'] =" - _edit="\$cfg['Servers'][\$i]['controlpass'] = '${values[$i]}';" - start_spinner "$msg" - # The shellcheck SC2026 was not designed for awk so bypass it - # shellcheck disable=2026 - # Match the line where the password for the controluser is set - line_num=$(awk '/^\$cfg.*'controlpass'.*=.*;$/ {print FNR}' $config_file) - if [ -z "$line_num" ]; then - stop_spinner 1 - echo -e "ERROR: No line found beginning with: $line \n\tin the file: $config_file" - echo "You will need to manually update the control user password in $config_file" - else - sed -i "$line_num c\\$_edit" $config_file - err_code=$? - stop_spinner $err_code - unset _edit - [ $err_code == 0 ] && - echo -e "\e[38;5;171mPROCESS COMPLETE\e[0m" && - echo -e "\e[1;33mCheck the console output for any possible failures.\e[0m" && - echo -en "\e[1;36m" && - echo "If you are logged into phpmyadmin, log out and log back in." && - echo "For additional security you can delete .starter.env" && - echo "Just make sure you remember your passwords from that file." && - echo "If you ever loose your passwords you may always set them again" && - echo "using this script and new values set in .starter.env" && - echo -e "\e[0m" - fi - fi - ;; - *) - echo "$err unidentified key $value" - ;; - esac - ((i++)) - done -} - -# Call functions from this script gracefully -if declare -f "$1" > /dev/null -then - # call arguments verbatim - "$@" -else - echo "utils.sh: '$1' is not a known function name." >&2 - exit 1 -fi diff --git a/.gp/bash/examples/init-react-example.sh b/.gp/bash/examples/init-react-example.sh index cd72c44f..54e7a6b1 100644 --- a/.gp/bash/examples/init-react-example.sh +++ b/.gp/bash/examples/init-react-example.sh @@ -15,11 +15,11 @@ all_zeros='^[0]+$' task_msg="Setting up React example: Questions and Answers" log "$task_msg" -curl -LJO /~https://github.com/apolopena/qna-demo-skeleton/archive/refs/tags/1.1.0.tar.gz +curl -LJO /~https://github.com/apolopena/qna-demo-skeleton/archive/refs/tags/1.1.1.tar.gz exit_codes+=($?) -tar --overwrite -xvzf qna-demo-skeleton-1.1.0.tar.gz --strip-components=1 +tar --overwrite -xvzf qna-demo-skeleton-1.1.1.tar.gz --strip-components=1 exit_codes+=($?) -rm qna-demo-skeleton-1.1.0.tar.gz +rm qna-demo-skeleton-1.1.1.tar.gz exit_codes+=($?) if [[ $(echo "${exit_codes[@]}" | tr -d '[:space:]') =~ $all_zeros ]]; then diff --git a/.gp/bash/examples/init-react-typescript-example.sh b/.gp/bash/examples/init-react-typescript-example.sh index b9dd65e0..d1f3f506 100644 --- a/.gp/bash/examples/init-react-typescript-example.sh +++ b/.gp/bash/examples/init-react-typescript-example.sh @@ -15,11 +15,11 @@ declare -a exit_codes=() task_msg="Downloading React Typescript example: Questions and Answers" log "$task_msg" -curl -LJO /~https://github.com/apolopena/qna-typescript-demo-skeleton/archive/refs/tags/1.1.0.tar.gz +curl -LJO /~https://github.com/apolopena/qna-typescript-demo-skeleton/archive/refs/tags/1.1.1.tar.gz exit_codes+=($?) -tar --overwrite -xvzf qna-typescript-demo-skeleton-1.1.0.tar.gz --strip-components=1 +tar --overwrite -xvzf qna-typescript-demo-skeleton-1.1.1.tar.gz --strip-components=1 exit_codes+=($?) -rm qna-typescript-demo-skeleton-1.1.0.tar.gz +rm qna-typescript-demo-skeleton-1.1.1.tar.gz exit_codes+=($?) if [[ $(echo "${exit_codes[@]}" | tr -d '[:space:]') =~ ^[0]+$ ]]; then @@ -29,5 +29,3 @@ else fi - - diff --git a/.gp/bash/helpers.sh b/.gp/bash/helpers.sh index 68923b47..7178d36a 100644 --- a/.gp/bash/helpers.sh +++ b/.gp/bash/helpers.sh @@ -23,7 +23,7 @@ # gls_version() { local hard version title file - hard="1.3.0" + hard="1.4.0" title="Gitpod Laravel Starter Framework" file="$GITPOD_REPO_ROOT"/.gp/CHANGELOG.md if [[ -f $file ]]; then @@ -142,6 +142,7 @@ show_powered_by() { echo "This project is powered by:" echo -en "\e[38;5;34m" gls_version + echo "PHP $(bash .gp/bash/utils.sh php_version)" echo -e "$(php artisan --version)" composer show | grep laravel/ui >/dev/null && ui=1 || ui=0 if [[ $ui -eq 1 ]]; then @@ -374,6 +375,28 @@ laravel_ui_version() { fi } +# php_fpm_conf +# Configures the php-fpm.conf depending on PHP version ($1) and the output file ($2) +# NOTE: If you want to configure this further parse the result of this from elsewhere. +php_fpm_conf() { + [[ -z $1 || -z $2 ]] && 2>&1 echo " ERROR: utils.sh --> php_fpm_conf(): Bad args. Script aborted" && exit 1 + echo "\ +[global] +pid = /tmp/php$1-fpm.pid +error_log = /tmp/php$1-fpm.log + +[www] +listen = 127.0.0.1:9000 +listen.owner = gitpod +listen.group = gitpod + +pm = dynamic +pm.max_children = 5 +pm.start_servers = 2 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3" > "$2" +} + # Call functions from this script gracefully if declare -f "$1" > /dev/null then diff --git a/.gp/bash/init-complete.sh b/.gp/bash/init-complete.sh index 83747734..f6958299 100644 --- a/.gp/bash/init-complete.sh +++ b/.gp/bash/init-complete.sh @@ -17,6 +17,9 @@ allow_mixed_web=$(bash .gp/bash/utils.sh parse_ini_value starter.ini laravel allow_mixed_web) [[ $allow_mixed_web != 0 ]] && bash .gp/bash/directives/allow-mixed-web.sh +# Add Workspace/Project composer bin folder to $PATH +export PATH="$PATH:$HOME/.config/composer/vendor/bin:$GITPOD_REPO_ROOT/vendor/bin" + # Cleanup if rm -rf /home/gitpod/laravel-starter;then log "CLEANUP SUCCESS: removed ~/laravel-starter" diff --git a/.gp/bash/init-gitpod.sh b/.gp/bash/init-gitpod.sh index d4e0c827..b7e599f4 100644 --- a/.gp/bash/init-gitpod.sh +++ b/.gp/bash/init-gitpod.sh @@ -21,9 +21,40 @@ start_spinner "Initializing MySql..." && gp await-port 3306 && stop_spinner $? +# Globals +current_php_version="$(bash .gp/bash/utils.sh php_version)" + + # BEGIN: Autogenerate php-fpm.conf + php_fpm_conf_path=".gp/conf/php-fpm/php-fpm.conf" + active_php_version="$(. .gp/bash/utils.sh php_version)" + msg="Autogenerating $php_fpm_conf_path for PHP $active_php_version" + log_silent "$msg" && start_spinner "$msg" + if bash .gp/bash/helpers.sh php_fpm_conf "$active_php_version" "$php_fpm_conf_path"; then + stop_spinner $? + log_silent "SUCCESS: $msg" + else + stop_spinner $? + log -e "ERROR: $msg" + fi + # END: Autogenerate php-fpm.conf + +# BEGIN: parse .vscode/settings.json +if [[ $(bash .gp/bash/utils.sh parse_ini_value starter.ini development vscode_disable_preview_tab) == 1 ]]; then + msg="parsing .vscode/settings.json as per starter.ini" + log_silent "$msg" && start_spinner "$msg" + if bash .gp/bash/utils.sh add_file_to_file_after '{' ".gp/conf/vscode/disable_preview_tab.txt" ".vscode/settings.json"; then + stop_spinner $? + log_silent "SUCCESS: $msg" + else + stop_spinner $? + log -e "ERROR: $msg" + fi +fi +# END: parse .vscode/settings.json + # BEGIN: Update npm if needed -target_npm_ver='^7' -min_target_npm_ver='7.11.1' +target_npm_ver='^8' +min_target_npm_ver='8.3.2' current_npm_ver=$(npm -v) update_npm=$(bash .gp/bash/utils.sh comp_ver_lt "$current_npm_ver" "$min_target_npm_ver") if [[ $update_npm == 1 ]]; then @@ -41,6 +72,31 @@ if [[ $update_npm == 1 ]]; then fi # END: Update npm if needed + # BEGIN: Install https://www.ioncube.com/loaders.php + if [[ $(bash .gp/bash/utils.sh parse_ini_value starter.ini ioncube install) == 1 ]]; then + if [[ $current_php_version == 7.4 ]]; then + msg="Installing ioncube loader" + log_silent "$msg" && start_spinner "$msg" \ + && wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -O /tmp/ioncube.tar.gz \ + && tar xzf /tmp/ioncube.tar.gz -C /tmp \ + && sudo cp /tmp/ioncube/ioncube_loader_lin_7.4.so /usr/lib/php/20190902/ioncube_loader_lin_7.4.so \ + && sudo bash -c 'echo "zend_extension=ioncube_loader_lin_7.4.so" > /etc/php/7.4/apache2/conf.d/10-ioncube.ini' \ + && sudo bash -c 'echo "zend_extension=ioncube_loader_lin_7.4.so" > /etc/php/7.4/cli/conf.d/10-ioncube.ini' \ + && rm -rf /tmp/ioncube.tar.gz /tmp/ioncube + err_code=$? + if [[ $err_code != 0 ]]; then + stop_spinner $err_code + log -e "ERROR: $msg" + else + stop_spinner $err_code + log "SUCCESS: $msg" + fi + else + log "WARNING: ioncube loader cannot be installed with PHP $current_php_version. Fix your starter.ini" + fi + fi + # END: Install https://www.ioncube.com/loaders.php + # BEGIN: Bootstrapping if [ ! -d "$GITPOD_REPO_ROOT/vendor" ]; then @@ -71,6 +127,25 @@ if [ ! -d "$GITPOD_REPO_ROOT/vendor" ]; then fi # END: rsync any new Laravel project files from the docker image to the repository + # BEGIN: Autogenerate phpinfo.php + if [[ $(bash .gp/bash/utils.sh parse_ini_value starter.ini PHP generate_phpinfo) == 1 ]]; then + if [[ -z $GITPOD_REPO_ROOT ]]; then + p="public/phpinfo.php"; + else + p="$GITPOD_REPO_ROOT/public/phpinfo.php" + fi + msg="generating phpinfo.php file in /public " + log_silent "$msg" && start_spinner "$msg" + if echo "" > "$p"; then + stop_spinner $? + log_silent "SUCCESS: $msg" + else + stop_spinner $? + log -e "ERROR: $msg" + fi + fi + # END: Autogenerate phpinfo.php + # Move, rename or merge any project files that need it [[ -f "LICENSE" && -d ".gp" && ! -f .gp/LICENSE ]] && mv -f LICENSE .gp/LICENSE [[ -f "README.md" && -d ".gp" && ! -f .gp/README.md ]] && mv -f README.md .gp/README.md diff --git a/.gp/bash/init-optional-scaffolding.sh b/.gp/bash/init-optional-scaffolding.sh index f07399ac..7058826f 100644 --- a/.gp/bash/init-optional-scaffolding.sh +++ b/.gp/bash/init-optional-scaffolding.sh @@ -186,7 +186,6 @@ if [ $install_react == 1 ]; then log -e "ERROR: $sub_msg" fi fi - hotfix140 log " --> Installing node modules and running Laravel Mix" yarn install && npm run dev npm run dev @@ -220,7 +219,6 @@ if [[ $install_vue == 1 && $install_react != 1 ]]; then fi err_code=$? if [[ $err_code == 0 ]]; then - hotfix140 log "SUCCESS: Vue$auth_msg has been installed" log " --> Installing node modules and running Laravel Mix" yarn install && npm run dev diff --git a/.gp/bash/install-core-packages.sh b/.gp/bash/install-core-packages.sh new file mode 100644 index 00000000..ecf2b04d --- /dev/null +++ b/.gp/bash/install-core-packages.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# +# SPDX-License-Identifier: MIT +# Copyright Β© 2022 Apolo Pena +# +# install-core-packages.sh +# Description: +# Installs package dependencies for gitpod-laravel-starter +# +# Notes: +# This script assumes it is being run from .gitpod.Dockerfile as a sudo user +# and that all of this scripts dependencies have already been copied to /tmp +# If you change this script you must force a rebuild of the docker image +# + +log='/var/log/workspace-image.log' +php_version="$(. /tmp/utils.sh php_version)" +core='rsync grc shellcheck' + +# Append the appropriate phpfpm package to core if the current php version is greater than 7.4 +(( $(bc <<<"$php_version > 7.4") )) \ + && core="${core} php$php_version-fpm" + +IFS=" " read -r -a all_packages <<< "$core" + +echo "BEGIN: Installing core packages" | tee -a $log + +echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections \ + && sudo apt-get update -q \ + && sudo apt-get -yq install "${all_packages[@]}" +ec=$? +if [[ $ec -ne 0 ]]; then + 2>&1 echo " ERROR: failed while installing one or more of the following core packages: ${all_packages[*]}" | tee -a $log +else + echo " SUCCESS: Installing core packages: ${all_packages[*]}" | tee -a $log +fi +echo "END: Installing core packages" | tee -a $log \ No newline at end of file diff --git a/.gp/bash/install-project-packages.sh b/.gp/bash/install-project-packages.sh new file mode 100644 index 00000000..0d972d90 --- /dev/null +++ b/.gp/bash/install-project-packages.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# +# SPDX-License-Identifier: MIT +# Copyright Β© 2021 Apolo Pena +# +# install-project-packages.sh +# Description: +# Installs project specific packages +# +# Notes: +# This script assumes it is being run from .gitpod.Dockerfile as a sudo user +# and that all of this scripts dependencies have already been copied to /tmp +# If you change this script you must force a rebuild of the docker image +# + +# Put any packages you would like to install for your project here in single quotes delimited by a space +packages='' + +log='/var/log/workspace-image.log' +IFS=" " read -r -a all_packages <<< "$packages" + +# Abort if $packages has no value set OR contains all whitespace +[[ -z ${packages// } ]] && exit 0 + +echo "BEGIN: Installing user specified project packages" | tee -a $log +echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections \ + && sudo apt-get update -q \ + && sudo apt-get -yq install "${all_packages[@]}" +ec=$? +if [[ $ec -ne 0 ]]; then + 2>&1 echo " ERROR: failed while installing one or more of the following user specified project packages: ${all_packages[*]}" | tee -a $log +else + echo " SUCCESS: Installing user specified project packages: ${all_packages[*]}" | tee -a $log +fi +echo "END: Installing user specified project packages" | tee -a $log \ No newline at end of file diff --git a/.gp/bash/install-xdebug.sh b/.gp/bash/install-xdebug.sh new file mode 100644 index 00000000..cea20a63 --- /dev/null +++ b/.gp/bash/install-xdebug.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# +# SPDX-License-Identifier: MIT +# Copyright Β© 2021 Apolo Pena +# +# install-xdebug.sh +# Description: +# Installs xdebug from source +# +# Notes: +# This script assumes it is being run from .gitpod.Dockerfile as a sudo user +# and that all of this scripts dependencies have already been copied to /tmp +# If you change this script you must force a rebuild of the docker image +# +# For xdebug version compatibility with PHP see https://xdebug.org/docs/compat + +xdebug_version='3.1.2' + +xdebug_binary_url="http://xdebug.org/files/xdebug-$xdebug_version.tgz" +xdebug_ext_path="$(php -r 'echo ini_get("extension_dir");')/xdebug.so" +php_version="$(. /tmp/utils.sh php_version)" +log='/var/log/workspace-image.log' + +xdebug_zend_ext_conf() { + # shellcheck disable=SC2028 + echo "\nzend_extension = $xdebug_ext_path\n[XDebug]\nxdebug.client_host = 127.0.0.1\nxdebug.client_port = 9009\nxdebug.log = /var/log/xdebug.log\nxdebug.mode = debug\nxdebug.start_with_request = trigger\n" +} + +# Download/build xdebug and configure it for PHP +msg="Compiling and installing xdebug $xdebug_version from $xdebug_binary_url" +echo "BEGIN: $msg" | tee -a $log +echo -e "; configuration for xdebug +; priority=20 +$(xdebug_zend_ext_conf)" > "/etc/php/$php_version/mods-available/20-xdebug.ini" +ec=$? +[[ $ec -eq 0 ]] || 2>&1 echo " ERROR $ec: could not generate xdebug zend ext conf to file /etc/php/$php_version/mods-available/xdebug.ini" | tee -a $log +wget "$xdebug_binary_url" \ +&& tar -xvzf "xdebug-$xdebug_version.tgz" \ +&& cd "xdebug-$xdebug_version" \ +&& "/usr/bin/phpize$php_version" \ +&& ./configure --enable-xdebug \ +&& make \ +&& sudo cp modules/xdebug.so "$xdebug_ext_path" \ +&& sudo bash -c "echo -e \"$(xdebug_zend_ext_conf)\" > \"/etc/php/$php_version/cli/conf.d/20-xdebug.ini\"" \ +&& sudo bash -c "echo -e \"$(xdebug_zend_ext_conf)\" > \"/etc/php/$php_version/apache2/conf.d/20-xdebug.ini\"" \ +&& sudo ln -s "/etc/php/$php_version/mods-available/20-xdebug.ini" "/etc/php/$php_version/fpm/conf.d" +ec=$? +if [[ $ec -eq 0 ]]; then + echo " SUCCESS: $msg" | tee -a $log +else + 2>&1 echo " ERROR $ec: $msg" | tee -a $log +fi +echo "END: $msg" | tee -a $log + diff --git a/.gp/bash/php.sh b/.gp/bash/php.sh new file mode 100644 index 00000000..a067b286 --- /dev/null +++ b/.gp/bash/php.sh @@ -0,0 +1,177 @@ +#!/bin/bash +# +# SPDX-License-Identifier: MIT +# Copyright Β© 2022 Apolo Pena +# +# php.sh +# Description: +# Installs an optional PHP version if specified in the [PHP] section of starter.ini +# If an optional PHP version is installed then the original PHP version will be uninstalled and purged +# +# Notes: +# This script assumes it is being run from .gitpod.Dockerfile as a sudo user +# and that all of this scripts dependencies have already been copied to /tmp +# If you change this script you must force a rebuild of the docker image +# +# Gitpod currently implements PHP as an embedded Apache module (prefork MPM) +# This script assumes that case by installing libapache2-mod-phpX.X when an optional +# php version is required when X.X is the supported PHP version specified in starter.ini + +log='/var/log/workspace-image.log' +php7_4='php7.4 php7.4-fpm php7.4-dev libapache2-mod-php7.4 php7.4-bcmath php7.4-ctype php7.4-curl php-date php7.4-gd php7.4-intl php7.4-json php7.4-mbstring php7.4-mysql php-net-ftp php7.4-pgsql php7.4-sqlite3 php7.4-tokenizer php7.4-xml php7.4-zip' +latest_php="$(. /tmp/utils.sh php_version)" +php_version= +gp_php_url='/~https://github.com/gitpod-io/workspace-images/blob/master/full/Dockerfile' + +purge_gp_php() { + local msg="Purging existing PHP $latest_php installation" + echo " $msg" | tee -a $log + sudo apt-get purge -y "php${latest_php%%.*}.*" + local ec=$? + if [[ $ec -eq 0 ]]; then + echo " SUCCESS: $msg" | tee -a $log + else + 2>&1 echo " ERROR: $msg" | tee -a $log + return 1 + fi + + msg="Cleaning up from the purge of PHP $latest_php" + echo " $msg" | tee -a $log + sudo apt-get autoclean && + sudo apt-get autoremove + ec=$? + if [[ $ec -eq 0 ]]; then + echo " SUCCESS: $msg" | tee -a $log + else + 2>&1 echo " ERROR: $msg" | tee -a $log + fi +} + +install_php() { + local msg= + local ppa= + ppa=$(. /tmp/utils.sh parse_ini_value /tmp/starter.ini PHP ppa) + # Strip any potential leading or tailing whitepsace from the parsed ppa value + ppa=$(bash /tmp/utils.sh trim_external "$ppa") + + # Uncomment to debugging installed packages in the build image step + # sudo a2query -m + + # Disable existing php mod and prefork, this will automatically be reinstated when PHP is installed + sudo a2dismod "php$latest_php" mpm_prefork + + # Conditionally remove ppa:ondrej/php (if directed to do so AND it exists) + if [[ $ppa != "ondrej" ]]; then + if grep ^deb /etc/apt/sources.list /etc/apt/sources.list.d/* | grep -wq "ondrej/php"; then + msg="Removing ppa:ondrej/php (as specified in starter.ini)" + echo " $msg" | tee -a $log + if sudo add-apt-repository -y --remove "ppa:ondrej/php"; then + echo " SUCCESS: $msg" | tee -a $log + echo " The standard OS ppa will be used to install PHP $php_version" + else + 2>&1 echo " ERROR: $msg" | tee -a $log + fi # end removal of ppa:ondrej/php + fi # end check if ppa:ondrej/php is active + fi # end check ppa directive in starter.ini + + + msg="Installing PHP $php_version as specified in starter.ini" + echo " $msg" | tee -a $log + echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections \ + && sudo apt-get update -q \ + && sudo apt-get -yqo Dpkg::Options::="--force-confnew" install "${all_packages[@]}" + local ec=$? + if [[ $ec -eq 0 ]]; then + echo " SUCCESS: $msg" | tee -a $log + echo " The following packages were installed: ${all_packages[*]}" + else + 2>&1 echo " ERROR: $msg" | tee -a $log + 2>&1 echo " One or more of the following packages failed to install: ${all_packages[*]}" | tee -a $log + return 1 + fi +} + +configure_php() { + local msg="Setting PHP config, phar and phpize from $latest_php to $php_version" + echo " $msg" | tee -a $log + sudo update-alternatives --set php "/usr/bin/php$php_version" && + sudo update-alternatives --set phpize "/usr/bin/phpize$php_version" && + sudo update-alternatives --set phar "/usr/bin/phar$php_version" && + sudo update-alternatives --set phar.phar "/usr/bin/phar.phar$php_version" && + sudo update-alternatives --set php-config "/usr/bin/php-config$php_version" + local ec=$? + if [[ $ec -eq 0 ]]; then + echo " SUCCESS: $msg" | tee -a $log + else + 2>&1 echo " ERROR: $msg" | tee -a $log + return 1 + fi +} + +configure_apache() { + local loc=/var/log/apache2 + mv /tmp/apache2.conf /etc/apache2/apache2.conf + sudo chown gitpod:gitpod "$loc/access.log" "$loc/error.log" "$loc/other_vhosts_access.log" + return $? +} + +keep_existing_php() { + local msg1 msg2= + + [[ $1 == 'fallback' ]] && + msg1=" WARNING: unsupported PHP version $php_version found in starter.ini." && + msg2="Falling back to the existing PHP version $latest_php as specified in $gp_php_url" && + echo "$msg1 $msg2" | tee -a $log && + echo "END: php.sh" | tee -a $log && + return 0 + + msg1=" Using the existing 'gitpodlatest' version of PHP ($latest_php) as specified in $gp_php_url" && + echo "$msg1" | tee -a $log && + echo "END: php.sh" | tee -a $log +} + +# BEGIN: MAIN +echo "BEGIN: php.sh" | tee -a $log +php_version=$(. /tmp/utils.sh parse_ini_value /tmp/starter.ini PHP version) +ec=$? +if [[ $ec -ne 0 ]]; then + 2>&1 echo " WARNING: could not parse /tmp/starter.ini. Defaulting PHP version to 'gitpodlatest' as specified in $gp_php_url" | tee -a $log + php_version='gitpodlatest' +fi + +if [[ $php_version == '7.4' ]]; then + IFS=" " read -r -a all_packages <<< "$php7_4" +elif [[ $php_version == 'gitpodlatest' ]]; then + keep_existing_php + exit 0 +else + keep_existing_php 'fallback' + exit 0 +fi + +# Rebuild the package list so we can find the Gitpod installed PHP in order to purge it +sudo apt-get update + +# Installing multiple versions of PHP is possible but adds alot of complexity and decreases performance +# so remove the version of php that was installed via the gitpod base image before we get started +if ! purge_gp_php; then + 2>&1 echo " php.sh was aborted: Existing php installation failed to be purged!" | tee -a $log && exit 1 +fi + +# Install PHP +if ! install_php; then + 2>&1 echo " php.sh was aborted: Optional php installation failed!" | tee -a $log && exit 1 +fi + +# Configure PHP +if ! configure_php; then + 2>&1 echo " php.sh was aborted: Optional php installation failed to be configured!" | tee -a $log && exit 1 +fi + +# Configure Apache +if ! configure_apache; then + 2>&1 echo " WARNING: Apache configuration failed. Apache may not work properly." | tee -a $log +fi + +echo "END: php.sh" | tee -a $log +# END: MAIN \ No newline at end of file diff --git a/.gp/bash/start-server.sh b/.gp/bash/start-server.sh index 7fbf051b..405c7290 100644 --- a/.gp/bash/start-server.sh +++ b/.gp/bash/start-server.sh @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT # Copyright Β© 2021 Apolo Pena # -# open-preview.sh +# start-server.sh # Description: # Starts the default server once MySQL is ready. @@ -25,4 +25,4 @@ __server=$(bash .gp/bash/utils.sh parse_ini_value starter.ini development defaul start_spinner "Starting $__server server on port $__port when system is ready..." && gp sync-await gitpod-inited && stop_spinner $? && -bash -i .gp/bash/helpers.sh start_server \ No newline at end of file +bash -i .gp/bash/helpers.sh start_server diff --git a/.gp/bash/utils.sh b/.gp/bash/utils.sh index 904a35cb..d495fcb1 100644 --- a/.gp/bash/utils.sh +++ b/.gp/bash/utils.sh @@ -66,7 +66,7 @@ add_file_to_file_before() { # # Usage: # Example: add the contents of git-alises.txt to .gitconfig after the marker [aliases] -# add_file_to_file_before \\[alias\\] git-aliases.txt .gitconfig +# add_file_to_file_after \\[alias\\] git-aliases.txt .gitconfig # add_file_to_file_after() { check_files_exist "$2" "$3" && local c=$?; if [ $c -ne 0 ]; then exit 1; fi @@ -251,6 +251,24 @@ get_env_value() { echo "$val" } +# php_version() +# Description: +# Gets the major and minor version of PHP from the installed configuration file php.ini +# Fails if PHP is not installed +# +# Notes: +# Assumes that the file path for the loaded php.ini file is somewhat standard in that the first +# directory in the path with numbers with dots in them that resembles a version number is +# indeed the PHP version +# +# Usage: +# outputs x.y where x is the major PHP version and y in the minor PHP version: +# php_version +# +php_version() { + php --ini | head -n 1 | grep -Eo "([0-9]{1,}\.)[0-9]{1,}" +} + # split_ver # Description: # splits a version number ($1) into three numbers delimited by a space @@ -331,6 +349,16 @@ test_comp_ver_lt() { done } +# Trims all leading and trailing whitespace +trim_external() { + local var="$*" + # remove leading whitespace characters + var="${var#"${var%%[![:space:]]*}"}" + # remove trailing whitespace characters + var="${var%"${var##*[![:space:]]}"}" + printf '%s' "$var" +} + # Call functions from this script gracefully if declare -f "$1" > /dev/null diff --git a/.gp/bash/workspace-init-logger.sh b/.gp/bash/workspace-init-logger.sh index df2d601d..9dbc2dd2 100644 --- a/.gp/bash/workspace-init-logger.sh +++ b/.gp/bash/workspace-init-logger.sh @@ -15,17 +15,17 @@ # Log to the console and a file log () { if [ -z "$2" ]; then - bash .gp/bash/utils.sh log "$1" /var/log/workspace-init.log + bash "$GITPOD_REPO_ROOT/.gp/bash/utils.sh" log "$1" /var/log/workspace-init.log else - bash .gp/bash/utils.sh log -e "$2" /var/log/workspace-init.log + bash "$GITPOD_REPO_ROOT/.gp/bash/utils.sh" log -e "$2" /var/log/workspace-init.log fi } # Log only to a file log_silent () { if [ -z "$2" ]; then - bash .gp/bash/utils.sh log_silent "$1" /var/log/workspace-init.log + bash "$GITPOD_REPO_ROOT/.gp/bash/utils.sh" log_silent "$1" /var/log/workspace-init.log else - bash .gp/bash/utils.sh log_silent -e "$2" /var/log/workspace-init.log + bash "$GITPOD_REPO_ROOT/.gp/bash/utils.sh" log_silent -e "$2" /var/log/workspace-init.log fi } \ No newline at end of file diff --git a/.gp/conf/php-fpm/php-fpm.conf b/.gp/conf/php-fpm/php-fpm.conf index 4ab375ee..f1d28f06 100644 --- a/.gp/conf/php-fpm/php-fpm.conf +++ b/.gp/conf/php-fpm/php-fpm.conf @@ -1,14 +1,6 @@ -[global] -pid = /tmp/php7.4-fpm.pid -error_log = /tmp/php7.4-fpm.log +PLACEHOLDER FILE -[www] -listen = 127.0.0.1:9000 -listen.owner = gitpod -listen.group = gitpod - -pm = dynamic -pm.max_children = 5 -pm.start_servers = 2 -pm.min_spare_servers = 1 -pm.max_spare_servers = 3 \ No newline at end of file +Note: +This file will be autogenerated once by .gp/bash/install-project-packages.sh when the workspace is built +Be sure to save the autogenerated results to version control. +Only edit the autogenerated file if you know what you are doing. \ No newline at end of file diff --git a/.gp/conf/vscode/disable_preview_tab.txt b/.gp/conf/vscode/disable_preview_tab.txt new file mode 100644 index 00000000..a58ead8a --- /dev/null +++ b/.gp/conf/vscode/disable_preview_tab.txt @@ -0,0 +1,2 @@ + "workbench.editor.enablePreview": false, + "workbench.editor.enablePreviewFromQuickOpen": false, \ No newline at end of file diff --git a/.gp/conf/xdebug/xdebug.ini b/.gp/conf/xdebug/xdebug.ini deleted file mode 100644 index 8aec5485..00000000 --- a/.gp/conf/xdebug/xdebug.ini +++ /dev/null @@ -1,6 +0,0 @@ -zend_extension=/usr/lib/php/20190902/xdebug.so -xdebug.client_host = 127.0.0.1 -xdebug.client_port = 9009 -xdebug.log = /var/log/xdebug.log -xdebug.mode = debug -xdebug.start_with_request = trigger \ No newline at end of file diff --git a/.gp/snippets/messages/update-pma-pws-help.txt b/.gp/snippets/messages/update-pma-pws-help.txt index 848d2f36..f874aa07 100644 --- a/.gp/snippets/messages/update-pma-pws-help.txt +++ b/.gp/snippets/messages/update-pma-pws-help.txt @@ -1,6 +1,6 @@ The following steps are required to successfully run the `update-phpmyadmin-pws` command: - 1. Create a file in .gp named `.starter.env`. you can run this command from the project root: `cp .gp/.starter.env.example .starter.env` - 2. Or Copy and paste all the keys containing `PHPMYADMIN` from `.gp/.starter.env.example` to your blank `.starter.env` file - 3. In `.starter.env`, set your password values for the `PHPMYADMIN` keys and save the file + 1. Create a file in .gp named `.starter.env`. You can run this command from the project root: `cp .gp/.starter.env.example .gp/.starter.env` + 2. Or Copy and paste all the keys containing `PHPMYADMIN` from `.gp/.starter.env.example` to your blank `.gp/.starter.env` file + 3. In `.gp/.starter.env`, set your password values for the `PHPMYADMIN` keys and save the file 4. In a terminal run the alias: `update-phpmyadmin-pws` -This information can also be found at /~https://github.com/apolopena/gitpod-laravel-starter/blob/main/README.md#securing-phpmyadmin \ No newline at end of file +This information can also be found at /~https://github.com/apolopena/gitpod-laravel-starter/blob/main/README.md#securing-phpmyadmin diff --git a/.gp/snippets/server-functions.sh b/.gp/snippets/server-functions.sh index ba880011..d0235dc6 100644 --- a/.gp/snippets/server-functions.sh +++ b/.gp/snippets/server-functions.sh @@ -68,7 +68,9 @@ stop_apache() { } start_nginx() { - nginx & /usr/sbin/php-fpm7.4 --fpm-config .gp/conf/php-fpm/php-fpm.conf + local fpm= + fpm="/usr/sbin/php-fpm$(bash .gp/bash/utils.sh php_version)" + nginx & "$fpm" --fpm-config .gp/conf/php-fpm/php-fpm.conf local exit_code=$? (( exit_code == 0 )) || return local log_monitor_type= @@ -88,7 +90,7 @@ start_nginx() { } stop_nginx() { - nginx -s stop && pkill php-fpm7.4 + nginx -s stop && pkill "php-fpm$(bash .gp/bash/utils.sh php_version)" local exit_code=$? (( exit_code == 0 )) || return local pid diff --git a/README.md b/README.md index e90db15b..61c7f4f4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Welcome πŸš€ -`gitpod-laravel-starter` generates a starting point for you to [develop in the cloud](https://www.gitpod.io/) with [Laravel](https://laravel.com/) web application framework, [MySql](https://www.mysql.com/products/community/) and pretty much any other technoglogy you would like to add. +`gitpod-laravel-starter` generates a starting point for you to [develop in the cloud](https://www.gitpod.io/) with [Laravel](https://laravel.com/) web application framework, [MySql](https://www.mysql.com/products/community/) and pretty much any other technology you would like to add. * Supports Laravel 6, 7, and 8 * Develop in the cloud on the [Gitpod](https://www.gitpod.io/) platform * Preconfigured yet fully customizable [LAMP](https://en.wikipedia.org/wiki/LAMP_(software_bundle)) or [LEMP](https://lemp.io/) stack @@ -42,38 +42,44 @@ JavaScript Framework" width="72" > - 3.1 [Creating a new Gitpod Workspace from a GitHub repository](#creating-a-new-gitpod-workspace-from-a-github-repository) 4. [Running the Client](#running-the-client) 5. [Pushing Laravel scaffolding Files to Your Remote Repository](#pushing-laravel-scaffolding-files-to-your-remote-repository) - - 5.1 [Gitpod account permissions](#gitpod-account-permissions) - - 5.2 [GitHub email protection](#GitHub-email-protection) -6. [Starter Project Configuration](#Starter-Project-Configuration) + - 5.1 [Gitpod Account Permissions](#gitpod-account-permissions) + - 5.2 [GitHub Email Protection](#github-email-protection) +6. [Starter Project Configuration](#starter-project-configuration) - 6.1 [Preset Examples](#preset-examples) - 6.2 [Development Servers](#development-servers) - - 6.3 [Changing the default server](#changing-the-default-server) - - 6.4 [Running more than one server at a time](#running-more-than-one-server-at-a-time) - - 6.5 [Changing the Laravel Version](#changing-the-laravel-version) - - 6.6 [Breaking the Docker cache](#breaking-the-docker-cache) -7. [Additional Features](#additional-features) - - 7.1 [Hot Reloading](#hot-reloading) - - 7.2 [Typescript](#typescript) -8. [Debugging PHP](#debugging-php) - - 8.1 [The default development server](#the-default-development-server) - - 8.2 [Specific development servers](#specific-development-servers) - - 8.3 [Setting breakpoints](#setting-breakpoints) - - 8.4 [Debugging Blade templates](#debugging-blade-templates) - - 8.5 [Tailing the Xdebug Log](#tailing-the-xdebug-log) -9. [Debugging JavaScript](#debugging-javascript) -10. [phpMyAdmin](#phpmyadmin) - - 10.1 [Installing phpMyAdmin](#installing-phpmyadmin) - - 10.2 [Security Concerns](#security-concerns) - - 10.3 [Securing phpMyAdmin](#securing-phpmyadmin) -11. [Generating a CHANGELOG.md Using github-changelog-generator](#generating-a-changelogmd-using-github-changelog-generator) - - 11.1 [Setting up an Access Token for github-changelog-generator](#setting-up-an-access-token-for-github-changelog-generator) -12. [Project Specific Bash Code for Gitpod](#project-specific-bash-code-for-gitpod) -13. [Ruby Gems](#ruby-gems) -14. [Git Aliases](#git-aliases) - - 14.1 [Emoji-log and Gitmoji](#emoji-log-and-gitmoji) -15. [Deployment Outside of Gitpod](#deployment-outside-of-gitpod) -16. [Gitpod Caveats](#gitpod-caveats) -17. [Thanks](#thanks) + - 6.3 [Changing the Default Server](#changing-the-default-server) + - 6.4 [Running More Than one Server at a Time](#running-more-than-one-server-at-a-time) + - 6.5 [Changing the PHP Version and PPA](#changing-the-php-version-and-ppa) + - 6.6 [Changing the Laravel Version](#changing-the-laravel-version) + - 6.7 [Breaking the Docker cache](#breaking-the-docker-cache) +7. [Gitpod Environment Variables](#gitpod-environment-variables) + - 7.1 [Sign Git commits with a GPG key](#sign-git-commits-with-a-gpg-key) + - 7.2 [Activate an Intelliphense License Key](#activate-an-intelliphense-license-key) +8. [Additional Features](#additional-features) + - 8.1 [Hot Reloading](#hot-reloading) + - 8.2 [Typescript](#typescript) +9. [Debugging PHP](#debugging-php) + - 9.1 [The Default Development Server](#the-default-development-server) + - 9.2 [Specific Development Servers](#specific-development-servers) + - 9.3 [Setting Breakpoints](#setting-breakpoints) + - 9.4 [Debugging Blade Templates](#debugging-blade-templates) + - 9.5 [Tailing the Xdebug Log](#tailing-the-xdebug-log) +10. [Debugging JavaScript](#debugging-javascript) +11. [phpMyAdmin](#phpmyadmin) + - 11.1 [Installing phpMyAdmin](#installing-phpmyadmin) + - 11.2 [Security Concerns](#security-concerns) + - 11.3 [Securing phpMyAdmin](#securing-phpmyadmin) +12. [Generating a CHANGELOG.md Using github-changelog-generator](#generating-a-changelogmd-using-github-changelog-generator) + - 12.1 [Setting up an Access Token for github-changelog-generator](#setting-up-an-access-token-for-github-changelog-generator) +13. [Project Specific Bash Code and Package Installation](#project-specific-bash-code-and-package-installation) + - 13.1 [User Editable Files](#user-editable-files) + - 13.2 [Migration and Seeding](#migration-and-seeding) +14. [Ruby Gems](#ruby-gems) +15. [Git Aliases](#git-aliases) + - 15.1 [Emoji-log and Gitmoji](#emoji-log-and-gitmoji) +16. [Deployment Outside of Gitpod](#deployment-outside-of-gitpod) +17. [Gitpod Caveats](#gitpod-caveats) +18. [Thanks](#thanks)
@@ -114,11 +120,11 @@ A preview browser should automatically open and display the Laravel start page o If the result log summary in the console shows success, then you should push those newly created Laravel scaffolding files to your remote repository before you get started coding your project. -### Gitpod account permissions +### Gitpod Account Permissions You may need to allow Gitpod additional permissions to push to your repository in case you come across an issue like [this one](https://community.gitpod.io/t/i-cant-push-my-changes-to-my-github-remote-repository/629). -### GitHub email protection +### GitHub Email Protection If your GitHub account uses the protected email feature and the email address you are using in your git configuration looks something like this: @@ -194,11 +200,11 @@ You can toggle any server on and off from any terminal window by running the rel - Nginx `start_nginx` or `stop_nginx` - PHP built-in development server: `start_php_dev` or `stop_php_dev` -### Changing the default server +### Changing the Default Server Change the value of `default_server` in the `development` section of `starter.ini` to `apache`, `nginx`, or `php`. You will need to change the APP_URL and ASSET_URL in the `.env` file to use the port number for that server if you change the default development server *after* a workspace has been created. -### Running more than one server at a time +### Running More Than one Server at a Time You may start and stop multiple servers. @@ -210,7 +216,30 @@ The Nginx server will now be running in addition to the Apache server. Laravel requires a URL to be set in the `.env` file in the project root. This is done for you automatically when the workspace is initialized. The URL set in the `.env` file contains the server port. so if you want to properly serve Laravel pages from a server other than the default server you initialized the project with then will need to change the values for APP_URL and ASSET_URL accordingly. -### Changing the Laravel Version + +### __Changing the PHP version and PPA__ +In `starter.ini` there is a `[PHP]` section and directives to change the version of PHP and or the `ppa` used for downloading the PHP packages. + +
+ +Note: _See [`starter.ini`](/~https://github.com/apolopena/gitpod-laravel-starter/blob/main/starter.ini) for more details._ + +**The following values are supported in the `[PHP]` section of `starter.ini`:** +- `version` + - `7.4` + - The default value + - Installs PHP 7.4. See [php.sh](/~https://github.com/apolopena/gitpod-laravel-starter/blob/main/.gp/bash/php.sh) for specifics. + - The current version of PHP that gitpod installs by default in their [`workspace-full`](/~https://github.com/gitpod-io/workspace-images/blob/master/full/Dockerfile) image will be automatically purged. + - `gitpodlatest` + - This keeps the current version that gitpod installs by default in their [`workspace-full`](/~https://github.com/gitpod-io/workspace-images/blob/master/full/Dockerfile) image. +- `ppa` + - `OS` + - The default value + - Uses the standard Debian distribution ppa + - `ondrej` + - Uses `ppa:ondrej/php`. This [ppa](https://launchpad.net/~ondrej/+archive/ubuntu/php) is maintained by an individual but does support the of running multiple versions of PHP side by side. + +### __Changing the Laravel Version__ In `starter.ini` there is a directive to change the version of Laravel. You should only change the version of Larvel *before* you create a new workspace. The laravel version directive is cached in the workspace image so changing it sometimes requires you to [break the Docker cache](#breaking-the-docker-cache) **Important**: @@ -230,8 +259,28 @@ In `starter.ini` there is a directive to change the version of Laravel. You shou
+## Gitpod Environment Variables +The following features can be enabled through environment variables that have been set in your [Gitpod preferences](https://gitpod.io/variables).: +
+\* _Please note that storing sensitive data in environment variables is not ultimately secure but should be OK for most development situations._ +- ### Sign Git commits with a GPG key + - `GPG_KEY_ID` (required) + - The ID of the GPG key you want to use to sign your git commits + - `GPG_KEY` (required) + - Base64 encoded private GPG key that corresponds to your `GPG_KEY_ID` + - `GPG_MATCH_GIT_TO_EMAIL` (optional) + - Sets your git user.email in `~/.gitconfig` to the value provided + - `GPG_AUTO_ULTIMATE_TRUST` (optional) + - If the value is set to `yes` or `YES` then your `GPG_KEY` will be automatically ultimately trusted +- ### Activate an Intelliphense License Key + - `INTELEPHENSE_LICENSEKEY` + - Creates `~/intelephense/licence.txt` and will contain the value provided + - This will activate [Intelliphense](https://intelephense.com/) for you each time the workspace is created or restarted + +
+ ## Additional Features -To keep the `gitpod-laravel-framework` as flexible as possible, some features have been left out of the `starter.ini` configuration file. These additional features can be easily added to your project using a one-time set up process. Wiki pages are available for each additional feature below that you may want to add to your project. +To keep the `gitpod-laravel-framework` as flexible as possible, some features have been left out of the `starter.ini` configuration file. These additional features can be easily added to your project using a one-time set up process. Wiki pages are available for each additional feature below that you may want to add to your project. Some of these features are automatically enabled for certain [preset examples](#preset-examples). ### Hot Reloading - `gitpod-laravel-starter` makes it easy for you to add the ability to see your code changes in realtime without refreshing the browser. Take a look at the wiki [hot reload](/~https://github.com/apolopena/gitpod-laravel-starter/wiki/Hot-Reload) page for more details. @@ -249,12 +298,12 @@ When debugging is enabled or disabled, the preview browser will reload the index This system uses port `9009` for the debugging. A launch configuration file is included in `.vscode/launch.json` and in `.theia/launch.json`. -### The default development server +### The Default Development Server To enable a debugging session on the default development server run `debug_on` in a Gitpod terminal. To disable a debugging session on the default development server run `debug_off` in a Gitpod terminal. -### Specific development servers +### Specific Development Servers You can toggle a debugging session for a specific server: @@ -267,19 +316,19 @@ You can toggle a debugging session for a specific server: *The [hot reload](/~https://github.com/apolopena/gitpod-laravel-starter/wiki/Hot-Reload) webpack server on port 3005 is not supported by this debugging system. You may be able to [configure it on your own](https://stackoverflow.com/questions/28470601/how-to-do-remote-debugging-with-browser-sync) if you like.* -### Setting breakpoints +### Setting Breakpoints Set a breakpoint in the Gitpod IDE by clicking in the gutter next to the line of code you want in any PHP file in the `public` folder (or deeper) Then in the Gitpod IDE in the browser: 1. Click the debug icon in the left side panel to open the Debug panel. 2. Choose "Listen for XDebug" from the dropdown list. -3. Click the green play button (you should see the status "RUNNING" in the Threads panel) +3. Click the green play button (you should see the status "RUNNING" in the CALL STACK panel) 4. Refresh the preview browser either manually or by running the `op` command and your breakpoint will be hit in the IDE. All debugging is subject to a server timeout, just refresh preview browser or run the command `op` if this happens. -### Debugging Blade templates +### Debugging Blade Templates You may also debug blade templates by placing the following snippet above where you want to inspect the blade directive. @@ -332,7 +381,7 @@ phpMyAdmin also introduces some extra security concerns that you may want to add At a minimum the default passwords that phpMyAdmin uses to administer the MySQL databases should be changed right after a Gitpod workspace has been created for the first time. An `update-phpmyadmin-pws` command has been provided that automagically changes the default passwords for you.

The following steps are required to successfully run the `update-phpmyadmin-pws` command: - 1. Create a file in .gp named `.starter.env`. you can run this command from the project root: `cp .gp/.starter.env.example .starter.env` + 1. Create a file in .gp named `.starter.env`. You can run this command from the project root: `cp .gp/.starter.env.example .gp/.starter.env` 2. Or Copy and paste all the keys containing `PHPMYADMIN` from `.gp/.starter.env.example` to your blank `.starter.env` file 3. In `.starter.env`, set your password values for the `PHPMYADMIN` keys and save the file 4. In a terminal run the alias: `update-phpmyadmin-pws` @@ -365,12 +414,22 @@ Important Note: If you do not generate an access token for `github-changelog-gen
-## Project Specific Bash Code for Gitpod - -Bash code that you want to run when your Gitpod workspace is created for the first time such as database migrations and seeding should be put in the file: -`bash/init-project.sh` -This file contains some basic scaffolding and examples that you may use in your project. - +## Project Specific Bash Code and Package Installation +Most of the files in `gitpod-laravel-starter` are core files and should not be altered unless you open PR for `gitpod-laravel-starter` however some files are provided so that you can customize your project even further. +
+You are encouraged to put your project specific code in files mentioned below: +### User Editable Files +- `.gp/bash/init-project.sh` + - Contains some basic scaffolding and examples that you may use in your project. + - Bash code you would like to run when a workspace is created for the first time (initialization) should added here. +- `.gp/bash/install-project-packages.sh` + - Packages that you would like installed (via `apt-get`) when the docker image layers are built can be added as a single space delimited string to this file. + - Any changes made to `.gp/bash/install-project-packages.sh` will require a rebuild of the Docker image layers before the workspace is created for the first time. + - To rebuild the Docker image layers increment the `INVALIDATE_CACHE` value in `.gitpod/Dockerfile` and push that change to the remote repository +### Migration and Seeding +It is recommended that you migrate and seed your project in this file: `.gp/bash/init-project.sh`. +
+[For example](/~https://github.com/apolopena/qna-demo-skeleton/blob/main/.gp/bash/init-project.sh), the [react preset](#preset-examples) makes use of `.gp/bash/init-project` for [migration and seeding](/~https://github.com/apolopena/qna-demo-skeleton/blob/main/.gp/bash/init-project.sh).
## Ruby Gems diff --git a/starter.ini b/starter.ini index be4db393..871e6c96 100644 --- a/starter.ini +++ b/starter.ini @@ -3,20 +3,28 @@ # Configuration for gitpod to build your stack as you like it # Note: Boolean values should always be set to 1 (true) or 0 (false) # Note: Version numbers for node packages support semantic versioning or can be left blank -# Note: Unless in the comments for a section, configuration is -# used only the first time a workspace is started. +# IMPORTANT NOTE: Unless specified in the comments for a section, configuration values are +# only used first time a workspace is created and not when the workspace is restarted. +# Furthermore, unless stated otherwise in the comments, any changes made to a value before +# a workspace is created for the first time requires a rebuild of the Docker image layers +# To rebuild the Docker image layers, invalidate the docker cache by incrementing the +# value for INVALIDATE_CACHE in .gitpod.Dockerfile #################### -# Can be changed after a workspace is created +# [development] values can be changed after a workspace is created [development] # Valid values: apache, nginx, php default_server=nginx # Valid values: tail, multitail apache_log_monitor=tail -# Valid values: =tail, multitail +# Valid values: tail, multitail nginx_log_monitor=tail +# If vscode_disable_preview=1 then .gp/conf/vscode/disable_preview_tab.txt gets .vscode/settings.json added +# If vscode_disable_preview=0 then no action will be taken +# See /~https://github.com/apolopena/gitpod-laravel-starter/issues/161 +vscode_disable_preview_tab=1 -# Can be changed after a workspace is created +# [.editorconfig] values can be changed after a workspace is created [.editorconfig] # valid values are: # laravel-default: use the .editorconfig that comes with the laravel project scaffolding @@ -26,7 +34,31 @@ nginx_log_monitor=tail # Note: if left blank or set to an invalid value, laravel-default will be used type=laravel-js-2space +# Unless specified, if you change values in this section you must increment the +# INVALIDATE_CACHE value .gitpod.Dockerfile before the workspace is created. +[PHP] +# version, valid values are 7.4 and gitpodlatest. +# The value 'gitpodlatest' will install the version of php set in +# /~https://github.com/gitpod-io/workspace-images/blob/master/full/Dockerfile +# Invalid values will default to 'gitpodlatest' +version=7.4 +# ppa, valid values are OS and ondrej +# The value 'OS' will use the standard (default) operating system PPA +# The value 'ondrej' will use ppa:ondrej/php +# Blank and invalid values will default to: OS +# This directive will be skipped if the php version is invalid or set to 'gitpodlatest' +ppa=OS +# generate_phpinfo +# if generate_phpinfo = 1 then a simple pgpinfo.php page will be created in /public +# if generate_phpinfo = 0 or any other value no action will be taken +# Does not require a rebuild of the docker image layer when this value is changed. +generate_phpinfo=1 + +# Changing values in this section requires a rebuild of the docker image layers +# Increment the value for INVALIDATE_CACHE in .gitpod.Dockerfile before the workspace is created. [phpmyadmin] +# install, valid values are 0 (do not install) and 1 (install) +# Requires a docker image to rebuild. install=1 [react] @@ -65,6 +97,10 @@ install=0 since_tag= future_release= +[ioncube] +# Installs the latest ioncube loader from https://www.ioncube.com/loaders.php +install=0 + [laravel] # version # Important Note: If you change the laravel version you MUST force the docker image to rebuild. @@ -86,4 +122,4 @@ allow_mixed_web=1 # Default value is 0 # Allows for the ability to include or omit the LARAVEL_README.md file from your project root # This directive is ignored if LARAVEL_READEME.md is already in the project root and is in version control -include_readme=0 \ No newline at end of file +include_readme=0