Skip to content

Commit

Permalink
Merge pull request #12 from sameersbn/custom-command-execution
Browse files Browse the repository at this point in the history
allow users to launch the container with a custom command
  • Loading branch information
migmartri authored Jun 21, 2016
2 parents 1dea726 + 0c0266b commit 9148a2d
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions rootfs/app-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,36 @@ log () {
echo -e "\033[0;33m$(date "+%H:%M:%S")\033[0;37m ==> $1."
}

if ! app_present; then
log "Creating rails application"
rails new . --skip-bundle --database mysql
fi
if [ "$1" == "bundle" -a "$2" == "exec" ]; then
if ! app_present; then
log "Creating rails application"
rails new . --skip-bundle --database mysql
fi

if ! gems_up_to_date; then
log "Installing/Updating Rails dependencies (gems)"
bundle install
log "Gems updated"
fi
if ! gems_up_to_date; then
log "Installing/Updating Rails dependencies (gems)"
bundle install
log "Gems updated"
fi

wait_for_db
wait_for_db

if ! fresh_container; then
echo "#########################################################################"
echo " "
echo " App initialization skipped:"
echo " Delete the file $INIT_SEM and restart the container to reinitialize"
echo " You can alternatively run specific commands using docker-compose exec"
echo " e.g docker-compose exec rails bundle exec rake db:migrate"
echo " "
echo "#########################################################################"
else
setup_db
log "Initialization finished"
touch $INIT_SEM
fi
if ! fresh_container; then
echo "#########################################################################"
echo " "
echo " App initialization skipped:"
echo " Delete the file $INIT_SEM and restart the container to reinitialize"
echo " You can alternatively run specific commands using docker-compose exec"
echo " e.g docker-compose exec rails bundle exec rake db:migrate"
echo " "
echo "#########################################################################"
else
setup_db
log "Initialization finished"
touch $INIT_SEM
fi

migrate_db
migrate_db
fi

exec /entrypoint.sh "$@"

0 comments on commit 9148a2d

Please sign in to comment.