Improve container build: GRN2-156 (#582)
* Cache gems * Remove debug statement * Use postgress by default * Update sample.env
This commit is contained in:
parent
18214037c3
commit
ccbd46f045
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
15
sample.env
15
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
|
||||
|
|
|
@ -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}
|
||||
|
|
Reference in New Issue