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.
|
# Set Rails environment.
|
||||||
ENV RAILS_ENV production
|
ENV RAILS_ENV production
|
||||||
|
|
||||||
|
COPY Gemfile* ./
|
||||||
|
RUN bundle install --without development test --deployment --clean
|
||||||
|
|
||||||
# Adding project files.
|
# Adding project files.
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Install gems.
|
|
||||||
RUN bundle install --without development test --deployment --clean
|
|
||||||
|
|
||||||
# Precompile assets.
|
# Precompile assets.
|
||||||
RUN bundle exec rake assets:clean
|
RUN bundle exec rake assets:clean
|
||||||
RUN bundle exec rake assets:precompile
|
RUN bundle exec rake assets:precompile
|
||||||
|
|
|
@ -10,9 +10,9 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- 5000:80
|
- 5000:80
|
||||||
# When using sqlite3 as the database
|
# When using sqlite3 as the database
|
||||||
volumes:
|
# volumes:
|
||||||
- ./db/production:/usr/src/app/db/production
|
# - ./db/production:/usr/src/app/db/production
|
||||||
- ./log:/usr/src/app/log
|
# - ./log:/usr/src/app/log
|
||||||
# When using external logging
|
# When using external logging
|
||||||
# logging:
|
# logging:
|
||||||
# driver: $LOG_DRIVER
|
# driver: $LOG_DRIVER
|
||||||
|
@ -22,18 +22,18 @@ services:
|
||||||
|
|
||||||
|
|
||||||
# When using postgresql as the database
|
# When using postgresql as the database
|
||||||
# links:
|
links:
|
||||||
# - db
|
- db
|
||||||
#
|
#
|
||||||
# db:
|
db:
|
||||||
# image: postgres:9.5
|
image: postgres:9.5
|
||||||
# restart: on-failure
|
restart: on-failure
|
||||||
# ports:
|
ports:
|
||||||
# - 5432:5432
|
- 5432:5432
|
||||||
# volumes:
|
volumes:
|
||||||
# - database_data:/var/lib/postgresql/data
|
- ./db/production:/var/lib/postgresql/data
|
||||||
# environment:
|
environment:
|
||||||
# - PGHOST=postgres
|
- PGHOST=postgres
|
||||||
# - PGDATABASE=postgres
|
- PGDATABASE=postgres
|
||||||
# - PGUSER=postgres
|
- PGUSER=postgres
|
||||||
# - PGPASSWORD=password
|
- PGPASSWORD=password
|
||||||
|
|
15
sample.env
15
sample.env
|
@ -178,10 +178,21 @@ ENABLE_GOOGLE_CALENDAR_BUTTON=
|
||||||
# ENABLE_SSL=true
|
# ENABLE_SSL=true
|
||||||
|
|
||||||
# Database settings
|
# 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_ADAPTER=postgresql
|
||||||
# DB_HOST=postgres.example.com
|
# DB_HOST=postgres.example.com
|
||||||
# DB_NAME=greenlight_production
|
# DB_NAME=greenlight_production
|
||||||
# DB_USERNAME=postgres
|
# DB_USERNAME=postgres
|
||||||
# DB_PASSWORD=password
|
# 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
|
fi
|
||||||
|
|
||||||
# Include sqlite for production
|
# 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.
|
# Set the version tag when it is a release or the commit sha was included.
|
||||||
if [[ "$CD_REF_NAME" == *"release"* ]]; then
|
if [[ "$CD_REF_NAME" == *"release"* ]]; then
|
||||||
export CD_VERSION_CODE=${CD_REF_NAME:8}
|
export CD_VERSION_CODE=${CD_REF_NAME:8}
|
||||||
|
|
Reference in New Issue