Skip to content

Commit

Permalink
Improve container build: GRN2-156 (bigbluebutton#582)
Browse files Browse the repository at this point in the history
* Cache gems

* Remove debug statement

* Use postgress by default

* Update sample.env
  • Loading branch information
shawn-higgins1 authored and jfederico committed Jun 26, 2019
1 parent 1821403 commit ccbd46f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 23 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 17 additions & 17 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 changes: 13 additions & 2 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 6 additions & 1 deletion scripts/image_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit ccbd46f

Please sign in to comment.