From 45cdb2b0f80ad92955704cb247a07b6fed687181 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Date: Thu, 8 Dec 2016 10:17:15 -0800 Subject: [PATCH] (Feat) Skip DB migration, setup and waiting using env variables Typo New section in Readme Refactoring Feedback Bump version Fix documentation --- bitnami/rails/Dockerfile | 2 +- bitnami/rails/README.md | 28 ++++++++++++++++++++++++++ bitnami/rails/rootfs/app-entrypoint.sh | 8 +++++--- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/bitnami/rails/Dockerfile b/bitnami/rails/Dockerfile index f259b96b3b61..e4ae3f2d34ba 100644 --- a/bitnami/rails/Dockerfile +++ b/bitnami/rails/Dockerfile @@ -39,7 +39,7 @@ RUN gem install therubyracer ENV RAILS_ENV=development ENV BITNAMI_APP_NAME=rails -ENV BITNAMI_IMAGE_VERSION=5.0.0.1-r3 +ENV BITNAMI_IMAGE_VERSION=5.0.0.1-r4 USER bitnami WORKDIR /app diff --git a/bitnami/rails/README.md b/bitnami/rails/README.md index 77188eff8567..038860535c14 100644 --- a/bitnami/rails/README.md +++ b/bitnami/rails/README.md @@ -117,6 +117,34 @@ Following are a few examples of launching some commonly used Rails development c > $ docker-compose restart myapp > ``` +## Running additional services: + + Sometimes, your application will require extra pieces, such as background processing tools like Resque +or Sidekiq. + + For these cases, it is possible to re-use this container to be run as an additional +service in your docker-compose file by modifying the command +executed. + +For example, you could run a Sidekiq container by adding the following to your +`docker-compose.yml` file: + +```yaml +services: + ... + sidekiq: + image: bitnami/rails:latest + environment: + # This skips the execution of rake db:create and db:migrate + # since it is being executed by the rails service. + - SKIP_DB_SETUP=true + command: bundle exec sidekiq +``` + +> **Note** +> +> You can skip database wait period and creation/migration by setting the SKIP_DB_WAIT and SKIP_DB_SETUP environment variables. + ## Installing Rubygems To add a Rubygem to your application, update the `Gemfile` in the application directory as you would normally do and restart the `myapp` service container. diff --git a/bitnami/rails/rootfs/app-entrypoint.sh b/bitnami/rails/rootfs/app-entrypoint.sh index b2ce5abd5fde..95828dcd7923 100755 --- a/bitnami/rails/rootfs/app-entrypoint.sh +++ b/bitnami/rails/rootfs/app-entrypoint.sh @@ -58,7 +58,7 @@ if [ "$1" == "bundle" -a "$2" == "exec" ]; then log "Gems updated" fi - wait_for_db + [[ -z $SKIP_DB_WAIT ]] && wait_for_db if ! fresh_container; then echo "#########################################################################" @@ -70,12 +70,14 @@ if [ "$1" == "bundle" -a "$2" == "exec" ]; then echo " " echo "#########################################################################" else - setup_db + + [[ -z $SKIP_DB_SETUP ]] && setup_db + log "Initialization finished" touch $INIT_SEM fi - migrate_db + [[ -z $SKIP_DB_SETUP ]] && migrate_db fi exec /entrypoint.sh "$@"