Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes and enhancements #51

Merged
merged 10 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
# Begin: merged in from laravel8 starter project
.starter.env
/vendor/
/node_modules/
/public/phpmyadmin
# END: merged in from laravel8 starter project
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
# Laravel Mix artifacts
/public/js
/public/css
/public/build
/public/mix-manifest.json
20 changes: 16 additions & 4 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,22 @@ RUN sudo touch /var/log/workspace-init.log \

RUN sudo touch /var/log/xdebug.log \
&& sudo chmod 666 /var/log/xdebug.log

RUN sudo mkdir /var/log/apache2 \
&& sudo chmod 755 /var/log/apache2

RUN sudo apt-get update -q \
&& sudo apt-get install -y php-dev
RUN sudo touch /var/log/apache2/access.log \
&& sudo chmod 666 /var/log/apache2/access.log

RUN sudo touch /var/log/apache2/error.log \
&& sudo chmod 666 /var/log/apache2/error.log

RUN sudo touch /var/log/apache2/other_vhosts_access.log \
&& sudo chmod 666 /var/log/apache2/other_vhosts_access.log

RUN sudo apt-get update -q \
&& sudo apt-get install -y rsync

RUN wget http://xdebug.org/files/xdebug-3.0.2.tgz \
&& tar -xvzf xdebug-3.0.2.tgz \
&& cd xdebug-3.0.2 \
Expand All @@ -29,7 +41,7 @@ RUN sudo bash -c ". /tmp/update-composer.sh" && rm /tmp/update-composer.sh

# 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=121
ENV INVALIDATE_CACHE=123

COPY --chown=gitpod:gitpod bash/utils.sh /tmp
COPY --chown=gitpod:gitpod starter.ini /tmp
Expand All @@ -42,4 +54,4 @@ COPY --chown=gitpod:gitpod bash/snippets/browser-functions /tmp
RUN echo "# BEGIN: custom code (not internal to gitpod)" \
&& cat /tmp/server-functions >> ~/.bashrc \
&& echo -e "\n" | cat /tmp/browser-functions >> ~/.bashrc \
&& echo "# END: custom code (not internal to gitpod)"
&& echo "# END: custom code (not internal to gitpod)"
13 changes: 11 additions & 2 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
image:
file: .gitpod.Dockerfile

ports:
- port: 8001
onOpen: ignore
Expand All @@ -16,10 +16,14 @@ tasks:
init: |
bash bash/init-gitpod.sh &&
bash bash/init-optional-scaffolding.sh &&
bash bash/init-project.sh &&
bash bash/init-complete.sh
name: Startup
- openMode: split-left
command: |
if [ $(bash bash/helpers.sh is_inited) == 1 ]; then \
gp sync-done gitpod-inited
fi;
UP=$(pgrep mysql | wc -l); \
if [ "$UP" -ne 1 ]; then \
. bash/third-party/spinner.sh &&
Expand All @@ -33,7 +37,12 @@ tasks:
name: Web Server
- openMode: split-top
command: |
default_server=$(bash bash/utils.sh parse_ini_value starter.ini development default_server); open_preview $default_server
. bash/third-party/spinner.sh &&
start_spinner "Opening preview when system is ready..."
gp sync-await gitpod-inited &&
default_server=$(bash bash/utils.sh parse_ini_value starter.ini development default_server); \
open_preview $default_server &&
stop_spinner $?
name: Main Terminal

vscode:
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,15 @@ The exception right now is the optional installation of `phpmyadmin`. This optio



### Development Servers
### Development Servers

This starter project comes pre packaged with two development servers.

- Apache2
- PHP Development Sever

By default the server listed in `starter.ini` will be the server used. You can however run both servers at the same time or change your default sever.
By default the server listed in `starter.ini` will be the server used. You can however run both servers at the same time or change your default sever.
You may also run the php development server manually via the command `php artisan serve`.

The default server will be started automatically when the workspace is started

Expand Down
3 changes: 2 additions & 1 deletion bash/init-complete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ echo -e "\e[38;5;194mIf everything looks good in the above results then push the
bash bash/helpers.sh persist_file /var/log/workspace-init.log

# Set initialized flag - Keep this at the bottom of the file
bash bash/helpers.sh mark_as_inited
bash bash/helpers.sh mark_as_inited
gp sync-done gitpod-inited
75 changes: 59 additions & 16 deletions bash/init-gitpod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,28 @@ start_spinner "Initializing MySql..." &&
gp await-port 3306 &&
stop_spinner $?

# Bootstrap scaffolding
if [ ! -d "$GITPOD_REPO_ROOT/bootstrap" ]; then
msg="\nMoving Laravel project from ~/temp-app to $GITPOD_REPO_ROOT"
# BEGIN: Bootstrap Laravel scaffolding

# Move Laravel project files if they are not already in version control
if [ ! -d "$GITPOD_REPO_ROOT/vendor" ]; then
msg="\nMoving Laravel project from ~/temp-app to $GITPOD_REPO_ROOT using rsync"
# TODO: replace spinner with a real progress bar for coreutils
log_silent "$msg" && start_spinner "$msg"
shopt -s dotglob
mv --no-clobber ~/test-app/* $GITPOD_REPO_ROOT
rsync -rlptgoD --ignore-existing ~/test-app/ $GITPOD_REPO_ROOT
err_code=$?
if [ $err_code != 0 ]; then
stop_spinner $err_code
log "ERROR: Failed to move Laravel project from ~/temp-app to $GITPOD_REPO_ROOT" -e
log "ERROR: Failed to move Laravel project from ~/temp-app to $GITPOD_REPO_ROOT using rsync" -e
else
stop_spinner $err_code
log "SUCCESS: moved Laravel project from ~/temp-app to $GITPOD_REPO_ROOT"
log "SUCCESS: moved Laravel project from ~/temp-app to $GITPOD_REPO_ROOT using rsync"
fi

# BEGIN: parse configurations

# Configure .editorconfig
if [ -e .editorconfig ]; then
if [ -e .editorconfig ]; then
ec_type=$(bash bash/utils.sh parse_ini_value starter.ini .editorconfig type)
case $(echo "$ec_type" | tr '[:upper:]' '[:lower:]') in
'laravel-js-2space')
Expand All @@ -59,17 +61,44 @@ if [ ! -d "$GITPOD_REPO_ROOT/bootstrap" ]; then
;;
esac
fi
# Laravel .env

# Laravel .env
[ -e .env ] && url=$(gp url 8000); sed -i'' "s#^APP_URL=http://localhost*#APP_URL=$url\nASSET_URL=$url#g" .env
# END: parse configurations

# Create laravel database if it does not exist
# TODO: think more about making this dynamic as per .env
__laravel_db_exists=$(mysqlshow 2>/dev/null | grep laravel >/dev/null 2>&1 && echo "1" || echo "0")
if [ $__laravel_db_exists == 0 ]; then
__laravel_db_msg="laravel database did not exist in mysql. Creating database: laravel"
log_silent "$__laravel_db_msg" && start_spinner "$__laravel_db_msg"
mysql -e "CREATE DATABASE laravel;"
err_code=$?
if [ $err_code != 0 ]; then
stop_spinner $err_code
log "ERROR: Failed to move createe mysql database: laravel" -e
else
stop_spinner $err_code
log "SUCCESS: created mysql database: laravel"
fi
fi
# Install node packages if needed, in case the Laravel Ui front end is already in version control
if [[ -f "package.json" && ! -d "node_modules" ]]; then
log "Found a package.json but there are no node modules installed"
log " --> Installing node packages..."
yarn install
log " --> Node packages installed"
log " --> Running Laravel Mix..."
yarn run dev
log " --> Running of Laravel Mix complete"
fi

# BEGIN: Optional configurations
# Super user account for phpmyadmin
installed_phpmyadmin=$(. bash/utils.sh parse_ini_value starter.ini phpmyadmin install)
if [ "$installed_phpmyadmin" == 1 ]; then
msg="Creating phpmyadmin superuser: pmasu"
log_silent "$msg" && start_spinner "$msg"
log_silent "$msg" && start_spinner "$msg"
mysql -e "CREATE USER 'pmasu'@'%' IDENTIFIED BY '123456';"
mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'pmasu'@'%';"
err_code=$?
Expand All @@ -79,6 +108,20 @@ if [ ! -d "$GITPOD_REPO_ROOT/bootstrap" ]; then
else
stop_spinner $err_code
fi
if [ ! -d 'public/phpmyadmin/node_modules' ]; then
log "phpmyadmin node modules have not yet been installed, installing now..."
cd public/phpmyadmin && yarn install && cd ../../
if [ $? == 0 ]; then
__pmaurl=$(gp url 8001)/phpmyadmin
log "phpmyadmin node modules installed."
log "To login to phpmyadmin:"
log " --> 1. Make sure you are serving it with apache"
log " --> 2. In the browser go to $__pmaurl"
log " --> 3. You should be able to login here using the default account. user: pmasu, pw: 123456"
else
log "ERROR: installing phpmyadmin node modules. Try installing them manually." -e
fi
fi
fi
# Install https://github.com/github-changelog-generator/github-changelog-generator
installed_changelog_gen=$(bash bash/utils.sh parse_ini_value starter.ini github-changelog-generator install)
Expand All @@ -90,14 +133,14 @@ if [ ! -d "$GITPOD_REPO_ROOT/bootstrap" ]; then
fi
# END: Optional configurations

# Move and or merge necessary failes then cleanup
(echo; cat ~/test-app/.gitignore) >> $GITPOD_REPO_ROOT/.gitignore && rm ~/test-app/.gitignore
# Move and merge necessary files, then cleanup
mv ~/test-app/README.md $GITPOD_REPO_ROOT/README_LARAVEL.md
rmdir ~/test-app
rm -rf ~/test-app
fi
# END: Bootstrap Laravel scaffolding

# Messages for github_changelog_generator
[ "$installed_changelog_gen" == 1 ] &&
[ "$installed_changelog_gen" == 1 ] &&
log "You may auto generate a CHANGELOG.md from github commits by running the command:\nrake changelog [...options]\n" &&
log "See starter.ini (github_changelog_generator section) for configurable options" &&
log "For a full list of options see the github-changelog-generator repository on github"
log "For a full list of options see the github-changelog-generator repository on github"
Loading