Last active
September 29, 2015 16:32
-
-
Save vovimayhem/688210476eab4b5a8651 to your computer and use it in GitHub Desktop.
docker rails starter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Include the app's bin directory to $PATH: | |
export PATH=/usr/src/app/bin:$PATH | |
set -e | |
# The container was invoked without any particular command... we must check if is a new development environment, install whatever we need to install, and then run the default command: | |
if [ -z "$1" ]; then | |
# Install bundler unless already present. | |
# If using the official ruby image with gems in a mounted data volume, | |
# the first run will not find bundler installed. | |
which bundle || gem install bundler --version "$BUNDLER_VERSION" --no-rdoc --no-ri | |
# Check if the app dependencies are met, or install them - using bundler: | |
bundle check || bundle | |
# Check if the database is initialized, or else try a database setup: | |
rake db:migrate || rake db:setup | |
# Set the default command: | |
set -- rails s -p 3000 -b 0.0.0.0 "$@" | |
fi | |
# Run the given/default command: | |
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
set -e | |
# 1: Agregar los binstubs a $PATH: | |
export PATH=/usr/src/app/bin:$PATH | |
# 2: Esperar a que algún otro container termine de inicializar | |
# los datos comunes (gems compartidos, base de datos) | |
if [ -z "$APP_SETUP_WAIT" ]; then APP_SETUP_WAIT=5; fi | |
while [ -f /usr/src/app/tmp/app-setup-is-busy ] | |
do | |
echo "Waiting $APP_SETUP_WAIT seconds for app setup process to finish..." | |
sleep $APP_SETUP_WAIT | |
done | |
# 3: "Apartar" el proceso de inicialización: | |
touch /usr/src/app/tmp/app-setup-is-busy | |
# 4: Checar o Instalar dependencias con Bundler: | |
bundle check || bundle | |
# 5: "Liberar" el proceso de inicialización: | |
rm -rf /usr/src/app/tmp/app-setup-is-busy | |
if [ -z "$1" ]; then | |
set -- ruby service-a.rb "$@" | |
fi | |
# ejecutar el comando o el default: | |
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# App gems and configuration: | |
gems: &app_base | |
image: ruby:2.2.3 | |
volumes: [ ".:/usr/src/app", "/usr/local/bundle" ] | |
working_dir: /usr/src/app | |
command: "true" | |
webuno: &app | |
<<: *app_base | |
volumes_from: [ gems ] | |
entrypoint: /usr/src/app/dev-entrypoint.sh | |
command: ruby service-a.rb | |
ports: [ "4567:4567" ] | |
webdos: | |
<<: *app | |
command: ruby service-b.rb | |
ports: [ "4568:4567" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment