docbrown/docker-entrypoint.sh
Hector Bustillos 27a7a199d7 #4129 Reduce Dockerfile size (#4251)
* The previous Dockerfile was using and outdated format and was causing
heavy load times.

The number of the lines in the Dockerfile are defined as layer, with more
layers more time and bigger is the final image.

There were many things that were able to be delegated to the official ruby
docker image.

*  - Use yarn community package
 - Don't create the workdir directory since is created by docker if doesn't exists
 - Remove config/application.yml from .dockerignore

* Update Dockerfile

Co-Authored-By: Abenet Tamiru <mail@abenet.me>

* Update Dockerfile

Co-Authored-By: Abenet Tamiru <mail@abenet.me>

* Add directory copy, and user correct folder in compose

* Update docker-compose and Dockerfile

* Fix typo

Co-Authored-By: Mac Siri <krairit.siri@gmail.com>

* Update wording

Co-Authored-By: Mac Siri <krairit.siri@gmail.com>
2019-10-10 18:01:04 -04:00

84 lines
2.3 KiB
Bash
Executable file

#!/bin/sh
#
# Lets setup the alias file
# @TODO - add as scripts instead within /bin? - this will help auto fill?
#
echo "" > ~/.bashrc
echo "alias devto-setup='cd /usr/src/app/ && gem install bundler && bundle install --jobs 20 --retry 5 && yarn install && yarn check --integrity && bin/setup'" >> ~/.bashrc
echo "alias devto-migrate='cd /usr/src/app/ && bin/rails db:migrate'" >> ~/.bashrc
echo "alias devto-start='cd /usr/src/app/ && bundle exec rails server -b 0.0.0.0 -p 3000'" >> ~/.bashrc
#
# Lets ensure we are in the correct workspace
#
cd /usr/src/app/
#
# Lets handle "DEV" RUN_MODE
#
if [[ "$RUN_MODE" = "DEV" ]]
then
echo ">---"
echo "> [dev.to/docker-entrypoint.sh] DEV mode"
echo "> "
echo "> Welcome to the dev.to, DEVELOPMENT container, for convenience your repository"
echo "> should be mounted onto '/usr/src/app/', and port 3000 should be forwarded to your host machine"
echo "> "
echo "> In addition the following alias commands has been preconfigured to get you up and running quickly"
echo "> "
echo "> devto-setup : Does the gem/yarn dependency installation, along with database setup"
echo "> devto-migrate : Calls the database migration script"
echo "> devto-start : Start the rails application server on port 3000"
echo "> "
echo "> Finally to exit this container bash terminal (and stop the container), use the command 'exit'"
echo ">---"
# Lets startup bash for the user to interact with
/bin/bash
exit $?;
fi
#
# Lets handle "DEMO" RUN_MODE
#
echo ">---"
echo "> [dev.to/docker-entrypoint.sh] DEMO mode"
echo "> "
echo "> Time to rock & roll"
echo ">---"
#
# DB setup
# note this will fail (intentionally), if DB was previously setup
#
if [[ "$DB_SETUP" == "true" ]]
then
echo ">---"
echo "> [dev.to/docker-entrypoint.sh] Performing DB_SETUP : you can skip this step by setting DB_SETUP=false"
echo ">---"
bin/setup
fi
#
# DB migration script
#
if [[ "$DB_MIGRATE" == "true" ]]
then
echo ">---"
echo "> [dev.to/docker-entrypoint.sh] Performing DB_MIGRATE : you can skip this step by setting DB_MIGRATE=false"
echo ">---"
bin/rails db:migrate
fi
#
# Execute rails server on port 3000
#
if [[ "$APP_SERVER" == "true" ]]
then
echo ">---"
echo "> [dev.to/docker-entrypoint.sh] Starting the rails servers - whheee!"
echo ">---"
rm -f tmp/pids/server.pid
bundle exec rails server -b 0.0.0.0 -p 3000
fi