Skip to content

Commit

Permalink
🚀 RELEASE: Version 1.5.0 (#199)
Browse files Browse the repository at this point in the history
* 🐛 FIX: #195 Allow lint-scripts.sh to be run locally

* 🐛 FIX: #197

* 🐛 FIX: #194

* 🐛 FIX: #193

* 🐛 FIX: #196

* 🤖 TEST: #196

* 🐛 FIX: #196

* 🐛 FIX: #198

* 🤖 TEST: force docker image build

* 🤖 TEST: #198

* 🐛 FIX: #198

* 🤖 TEST: force docker image build

* 🐛 FIX: #159

* 🐛 FIX: #198

* 🐛 FIX: typo in #198

* 🤖 TEST: force docker image build

* 🐛 FIX: #159

* 💡 UPDATE COMMENTS: fix

* 🤖 TEST: force dockerm image build

* 🤖 TEST: remove test install packages

* 🐛 FIX: add sudo back in for composer update

* 🐛 FIX: #196

* 🐛 FIX: #192

* 🤖 TEST: force docker image build
  • Loading branch information
apolopena authored Feb 8, 2022
1 parent fdc77c3 commit c6098d0
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 80 deletions.
8 changes: 4 additions & 4 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ RUN sudo bash -c ". /tmp/install-project-packages.sh" && rm /tmp/install-project
# Download, compile, install and configure xdebug from source
RUN sudo bash -c ". /tmp/install-xdebug.sh" && rm /tmp/install-xdebug.sh

# 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
# Update composer
RUN 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
RUN bash -c ". /tmp/scaffold-project.sh" && rm /tmp/scaffold-project.sh

# Force the docker image to build by incrementing this value
ENV INVALIDATE_CACHE=226
ENV INVALIDATE_CACHE=232
108 changes: 56 additions & 52 deletions .gp/bash/init-gitpod.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# SPDX-License-Identifier: MIT
# Copyright © 2021 Apolo Pena
# Copyright © 2022 Apolo Pena
#
# init-gitpod.sh
# Description:
Expand All @@ -24,34 +24,6 @@ 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='^8'
min_target_npm_ver='8.3.2'
Expand All @@ -72,32 +44,64 @@ 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
# 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
log "WARNING: ioncube loader cannot be installed with PHP $current_php_version. Fix your starter.ini"
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: Bootstrap non-laravel
if [[ ! -d $GITPOD_REPO_ROOT/routes ]]; then
# 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: Install https://www.ioncube.com/loaders.php
# END: parse .vscode/settings.json
fi;
# END: Bootstrap non-laravel

# BEGIN: Bootstrapping
# BEGIN: Bootstrap Laravel
if [ ! -d "$GITPOD_REPO_ROOT/vendor" ]; then

# Handle laravel README.md
Expand Down Expand Up @@ -255,4 +259,4 @@ if [ ! -d "$GITPOD_REPO_ROOT/vendor" ]; then
log " --> Running of Laravel Mix complete"
fi # end node_modules/ check
fi # end vendor/ check for bootstrapping
# END: Bootstrapping
# END: Bootstrap Laravel
1 change: 1 addition & 0 deletions .gp/bash/install-core-packages.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# shellcheck disable=SC1091
#
# SPDX-License-Identifier: MIT
# Copyright © 2022 Apolo Pena
Expand Down
9 changes: 4 additions & 5 deletions .gp/bash/install-project-packages.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
#!/bin/bash
# shellcheck disable=SC1091
#
# SPDX-License-Identifier: MIT
# Copyright © 2021 Apolo Pena
# Copyright © 2022 Apolo Pena
#
# install-project-packages.sh
# Description:
# Installs project specific packages
# Installs project specific packages as per starter.ini
#
# 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=''

packages="$(bash /tmp/utils.sh parse_ini_value /tmp/starter.ini apt-get packages)"
log='/var/log/workspace-image.log'
IFS=" " read -r -a all_packages <<< "$packages"

Expand Down
3 changes: 2 additions & 1 deletion .gp/bash/install-xdebug.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash
# shellcheck disable=SC1091
#
# SPDX-License-Identifier: MIT
# Copyright © 2021 Apolo Pena
# Copyright © 2022 Apolo Pena
#
# install-xdebug.sh
# Description:
Expand Down
3 changes: 2 additions & 1 deletion .gp/bash/lint-scripts.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# SPDX-License-Identifier: MIT
# Copyright © 2021 Apolo Pena
# Copyright © 2022 Apolo Pena
#
# lint-scripts.sh
# Description:
Expand All @@ -13,6 +13,7 @@
# Pass in an optional -V or --verbose if you would like to output a list of the files being checked

path() {
[[ -z $GITPOD_REPO_ROOT ]] && GITPOD_REPO_ROOT="$(pwd)"
echo "$GITPOD_REPO_ROOT/.gp"
}

Expand Down
16 changes: 7 additions & 9 deletions .gp/bash/open-preview.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# SPDX-License-Identifier: MIT
# Copyright © 2021 Apolo Pena
# Copyright © 2022 Apolo Pena
#
# open-preview.sh
# Description:
Expand All @@ -11,22 +11,20 @@
# Can take a port option to open a specific port, for example op -3005
# In the case of using the port option, the path segment to open will be $2

[[ $(pwd) != "$GITPOD_REPO_ROOT" ]] &&
echo -e "\e[1;31mThis command can only be run from the project root of a gitpod workspace:\e[0m $GITPOD_REPO_ROOT" &&
exit 1

function main() {
local rp="$GITPOD_REPO_ROOT/.gp/"
local path port
[[ $1 == '-h' || $1 == '--help' ]] && cat .gp/snippets/messages/op-help.txt && exit 0
[[ $1 == '-h' || $1 == '--help' ]] && cat "$rp/snippets/messages/op-help.txt" && exit 0
if [[ $1 =~ ^-[1-9][0-9]+$ ]]; then
port="${1:1}"
path="/$2"
else
path="/$1"
port=$(bash .gp/bash/helpers.sh get_default_server_port)
port=$(bash "$rp/bash/helpers.sh" get_default_server_port)
fi
if [[ $(bash .gp/bash/helpers.sh is_inited) == 0 ]]; then
. .gp/bash/spinner.sh &&
if [[ $(bash "$rp/bash/helpers.sh" is_inited) == 0 ]]; then
# shellcheck disable=SC1090,SC1091
. "$rp/bash/spinner.sh" &&
start_spinner "Opening preview when system is ready..."
gp sync-await gitpod-inited &&
stop_spinner 0 &&
Expand Down
1 change: 1 addition & 0 deletions .gp/bash/php.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# shellcheck disable=SC1091
#
# SPDX-License-Identifier: MIT
# Copyright © 2022 Apolo Pena
Expand Down
4 changes: 2 additions & 2 deletions .gp/bash/scaffold-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ _exitcode=$?
if [ $_exitcode -ne 0 ]; then
>&2 echo " ERROR $?: failed to create Laravel $_lv project scaffolding in $_scaff_dest" | tee -a $_log
else
chown -R gitpod:gitpod "$_scaff_dest"
sudo chown -R gitpod:gitpod "$_scaff_dest"
cd "$_scaff_dest" || exit 1
echo " SUCCESS: $(php artisan --version) project scaffolding created in $_scaff_dest" | tee -a $_log

Expand All @@ -49,7 +49,7 @@ else
cd "$_scaff_dest/public" && composer create-project phpmyadmin/phpmyadmin
_exitcode_phpmyadmin=$?
if [ $_exitcode_phpmyadmin -eq 0 ]; then
chown -R gitpod:gitpod "$_scaff_dest/public/phpmyadmin"
sudo chown -R gitpod:gitpod "$_scaff_dest/public/phpmyadmin"
echo " SUCCESS: phpmyadmin installed to $_scaff_dest/public" | tee -a $_log
else
>&2 echo " ERROR $?: phpmyadmin failed to install" | tee -a $_log
Expand Down
8 changes: 4 additions & 4 deletions .gp/bash/update-composer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ fi

echo " Installing latest version of composer" | tee -a $LOG
EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"

if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then
>&2 echo " ERROR: Invalid installer checksum - failed to install latest version of composer." | tee -a $LOG
rm composer-setup.php
sudo rm composer-setup.php
else
php composer-setup.php --install-dir=/usr/bin --filename=composer
sudo php composer-setup.php --install-dir=/usr/bin --filename=composer
COMP_VAL=$?
if [ $COMP_VAL -ne 0 ]; then
>&2 echo " ERROR $COMP_VAL: Failed to install latest version of composer." | tee -a $LOG
else
echo " SUCCESS: latest version of composer installed: $(composer --version)" | tee -a $LOG
fi
rm composer-setup.php
sudo rm composer-setup.php
fi

echo "END: update composer" | tee -a $LOG
Expand Down
2 changes: 1 addition & 1 deletion .gp/conf/php-fpm/php-fpm.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PLACEHOLDER FILE

Note:
This file will be autogenerated once by .gp/bash/install-project-packages.sh when the workspace is built
This file will be autogenerated once by .gp/bash/init-gitpod.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.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ The file [`starter.ini`](https://github.com/apolopena/gitpod-laravel-starter/blo
- `.editorconfig`: You can omit this file or use a less opinionated version of this file than what Laravel gives you by default
- [github-change-log-generator](https://github.com/github-changelog-generator/github-changelog-generator)

*Please note that many of the configurations found in `starter.ini` should be made just once __prior__ to creating your workspace for the first time. Have a look at the comments in [`starter.ini`](https://github.com/apolopena/gitpod-laravel-starter/blob/main/starter.ini) for specifics.*
*Please note that a project's package.json can supercede any installation directives that have been set to zero in starter.ini.*

*Also please note that many of the configurations found in `starter.ini` should be made just once __prior__ to creating your workspace for the first time. Have a look at the comments in [`starter.ini`](https://github.com/apolopena/gitpod-laravel-starter/blob/main/starter.ini) for specifics.*

### Preset Examples
`gitpod-laravel-starter` preset examples are auto-configured examples of React and Vue projects that you can learn from or use as starting points for your own projects.
Expand Down
7 changes: 7 additions & 0 deletions starter.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ nginx_log_monitor=tail
# See https://github.com/apolopena/gitpod-laravel-starter/issues/161
vscode_disable_preview_tab=1

# If you change values in this section you must force a new docker image by incrementing the
# INVALIDATE_CACHE value .gitpod.Dockerfile before the workspace is created.
[apt-get]
# Packages to install during the Docker image build phase of a project
# Valid value is a space delimited list of valid packages to be installed via apt-get
packages=

# [.editorconfig] values can be changed after a workspace is created
[.editorconfig]
# valid values are:
Expand Down

0 comments on commit c6098d0

Please sign in to comment.