diff --git a/Dockerfile b/Dockerfile index 33a873c6..665cb8f2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,12 +17,12 @@ WORKDIR $RAILS_ROOT # Set Rails environment. ENV RAILS_ENV production +COPY Gemfile* ./ +RUN bundle install --without development test --deployment --clean + # Adding project files. COPY . . -# Install gems. -RUN bundle install --without development test --deployment --clean - # Precompile assets. RUN bundle exec rake assets:clean RUN bundle exec rake assets:precompile diff --git a/docker-compose.yml b/docker-compose.yml index 2ba18f2f..4293ce93 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,9 +10,9 @@ services: ports: - 5000:80 # When using sqlite3 as the database - volumes: - - ./db/production:/usr/src/app/db/production - - ./log:/usr/src/app/log +# volumes: +# - ./db/production:/usr/src/app/db/production +# - ./log:/usr/src/app/log # When using external logging # logging: # driver: $LOG_DRIVER @@ -22,18 +22,18 @@ services: # When using postgresql as the database -# links: -# - db + links: + - db # -# db: -# image: postgres:9.5 -# restart: on-failure -# ports: -# - 5432:5432 -# volumes: -# - database_data:/var/lib/postgresql/data -# environment: -# - PGHOST=postgres -# - PGDATABASE=postgres -# - PGUSER=postgres -# - PGPASSWORD=password + db: + image: postgres:9.5 + restart: on-failure + ports: + - 5432:5432 + volumes: + - ./db/production:/var/lib/postgresql/data + environment: + - PGHOST=postgres + - PGDATABASE=postgres + - PGUSER=postgres + - PGPASSWORD=password diff --git a/sample.env b/sample.env index b256013b..ff094c8b 100644 --- a/sample.env +++ b/sample.env @@ -178,10 +178,21 @@ ENABLE_GOOGLE_CALENDAR_BUTTON= # ENABLE_SSL=true # Database settings -# Greenlight works out of the box with sqlite3, but if postgresql is required, especially for production -# These variables should also be included. +# +# Greenlight may work out of the box with sqlite3, but for production it is recommended to use postgresql. +# In such case, these variables must be included. +# # DB_ADAPTER=postgresql # DB_HOST=postgres.example.com # DB_NAME=greenlight_production # DB_USERNAME=postgres # DB_PASSWORD=password +# +# Note that the example provided, works for deployments based on the docker-compose script wich is also included. +# But should you need to use an external Postgres server, the right values for HOST, USERNAME and PASSWORD should be applied. +# +DB_ADAPTER=postgresql +DB_HOST=db +DB_NAME=greenlight_production +DB_USERNAME=postgres +DB_PASSWORD=password diff --git a/scripts/image_build.sh b/scripts/image_build.sh index 3b15a761..adf1e987 100755 --- a/scripts/image_build.sh +++ b/scripts/image_build.sh @@ -56,7 +56,12 @@ if [ "$CD_REF_NAME" != "master" ] && [[ "$CD_REF_NAME" != *"release"* ]] && ( [ fi # Include sqlite for production -sed -i "/^group :production do/a\ \ gem 'sqlite3', '~> 1.3.6'" Gemfile +sqliteCount="$(grep "gem 'sqlite3'" Gemfile | wc -l)" + +if [ $sqliteCount -lt 2 ]; then + sed -i "/^group :production do/a\ \ gem 'sqlite3', '~> 1.3.6'" Gemfile +fi + # Set the version tag when it is a release or the commit sha was included. if [[ "$CD_REF_NAME" == *"release"* ]]; then export CD_VERSION_CODE=${CD_REF_NAME:8}