canvas-lms/docker-compose.yml

24 lines
454 B
YAML
Raw Normal View History

# See doc/docker/README.md or https://github.com/instructure/canvas-lms/tree/master/doc/docker
version: '2.3'
services:
web: &WEB
build:
context: .
links:
- postgres
- redis
Configure databases in a unified manner This patchset removes the much duplicated database.yml and instead defaults to a DATABASE_URL scheme. There is however still present a docker-compose/config/new-jenkins/database.yml file to temporarily allow our internal portal service to still function until such time we can reconfigure it. To set up custom connection options all that is needed is setting DATABASE_URL. See examples of this in docker-compose.yml and docker-compose.new-jenkins.yml. Test Plan ========= Image: - pulling canvas-lms:master image boots without database errors Repo: - given default dev environment where COMPOSE_FILE=docker-compose.yml:docker-compose.override.yml - build the web and postgres images: docker-compose build web postgres (feel free to comment out `yarn install` and `compile_assets` in the Dockerfile since we won't be needing them for this test and this speeds things up) - set a custom DATABASE_URL to change the database name and echo it to see it gets into the image correctly: $ docker run -it -e \ DATABASE_URL=postgres://postgres:sekret@postgres/canvas_custom_env \ $(docker-compose ps -q web) bash -c "echo \$DATABASE_URL" => postgres://postgres:sekret@postgres/canvas_custom_env $ docker-compose run --rm -e \ DATABASE_URL=postgres://postgres:sekret@postgres/canvas_custom_env \ web bash -c "echo \$DATABASE_URL" => postgres://postgres:sekret@postgres/canvas_custom_env - Test that setting a custom database name via DATABASE_URL can create the database $ docker-compose run --rm -e \ DATABASE_URL=postgres://postgres:sekret@postgres/canvas_custom_env \ web bash -c "bin/rails db:create" => Created database 'canvas_custom_env' - This patchset boots on portal Change-Id: Ic6f3819550df94b6c98b17ef05ac2029a578cfe4 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/234213 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Jacob Powell <spowell@instructure.com> Reviewed-by: James Butters <jbutters@instructure.com> QA-Review: Robin Kuss <rkuss@instructure.com> QA-Review: Rex Fleischer <rfleischer@instructure.com> QA-Review: Jacob Powell <spowell@instructure.com> Product-Review: Rex Fleischer <rfleischer@instructure.com>
2020-04-16 02:52:10 +08:00
environment:
Remove DATABASE_URL from docker dev envs Fixes: CCI-347 This will allow connecting to the test environment again. Copy over the updated config/docker-compose.override.yml (or delete the relevant line from your existing docker-compose.override.yml). Also copy over the restored and modified config/database.yml.example. $ cp -iv config/docker-compose.override.yml.example \ docker-compose.override.yml $ cp -iv docker-compose/,}config/database.yml If you have existing databases that don't match the naming scheme of "canvas_<ENV>" then you'll need to do a custom configuration for your database names in config/database.yml or rename your databases in postgres. Test Plan - update your override config and database.yml: $ cp -iv config/docker-compose.override.yml.example \ docker-compose.override.yml $ cp -iv {docker-compose/,}config/database.yml - make sure your postgres image is up to date from earlier patchset (this will remove all your data): $ docker-compose down --volumes $ docker-compose build --no-cache postgres - boot the app, bundle, and wait for postgres to be available (for internal start up scripts to run): $ docker-compose run --rm web bundle \ && docker-compose run --rm web build/new-jenkins/wait-for-it \ postgres:5432 -t 30 - test that connctions to both development and test databases work: - developement: $ docker-compose run --rm web bin/rails runner \ 'puts ActiveRecord::Base.connection.current_database' => 'canvas_development' - test: $ docker-compose run --rm -e RAILS_ENV=test web bin/rails runner \ 'puts ActiveRecord::Base.connection.current_database' => 'canvas_test' - set a custom database name: $ docker-compose run --rm \ -e RAILS_ENV=test \ -e CANVAS_DATABASE_TEST=canvas_rails3_ \ web bin/rails runner \ 'Rails.application.load_tasks; \ Rake::Task["db:create"].invoke; \ puts ActiveRecord::Base.connection.current_database' => 'canvas_rails3_' flag = none Change-Id: Ia19038586508dc91c6a4d4386d812752e00a4ad6 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/235642 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Rex Fleischer <rfleischer@instructure.com> Reviewed-by: James Butters <jbutters@instructure.com> Reviewed-by: Augusto Callejas <acallejas@instructure.com> QA-Review: James Butters <jbutters@instructure.com> Product-Review: Derek Bender <djbender@instructure.com>
2020-04-29 23:04:42 +08:00
POSTGRES_PASSWORD: sekret
jobs:
<<: *WEB
command: bundle exec script/delayed_job run
postgres:
build: ./docker-compose/postgres
Configure databases in a unified manner This patchset removes the much duplicated database.yml and instead defaults to a DATABASE_URL scheme. There is however still present a docker-compose/config/new-jenkins/database.yml file to temporarily allow our internal portal service to still function until such time we can reconfigure it. To set up custom connection options all that is needed is setting DATABASE_URL. See examples of this in docker-compose.yml and docker-compose.new-jenkins.yml. Test Plan ========= Image: - pulling canvas-lms:master image boots without database errors Repo: - given default dev environment where COMPOSE_FILE=docker-compose.yml:docker-compose.override.yml - build the web and postgres images: docker-compose build web postgres (feel free to comment out `yarn install` and `compile_assets` in the Dockerfile since we won't be needing them for this test and this speeds things up) - set a custom DATABASE_URL to change the database name and echo it to see it gets into the image correctly: $ docker run -it -e \ DATABASE_URL=postgres://postgres:sekret@postgres/canvas_custom_env \ $(docker-compose ps -q web) bash -c "echo \$DATABASE_URL" => postgres://postgres:sekret@postgres/canvas_custom_env $ docker-compose run --rm -e \ DATABASE_URL=postgres://postgres:sekret@postgres/canvas_custom_env \ web bash -c "echo \$DATABASE_URL" => postgres://postgres:sekret@postgres/canvas_custom_env - Test that setting a custom database name via DATABASE_URL can create the database $ docker-compose run --rm -e \ DATABASE_URL=postgres://postgres:sekret@postgres/canvas_custom_env \ web bash -c "bin/rails db:create" => Created database 'canvas_custom_env' - This patchset boots on portal Change-Id: Ic6f3819550df94b6c98b17ef05ac2029a578cfe4 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/234213 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Jacob Powell <spowell@instructure.com> Reviewed-by: James Butters <jbutters@instructure.com> QA-Review: Robin Kuss <rkuss@instructure.com> QA-Review: Rex Fleischer <rfleischer@instructure.com> QA-Review: Jacob Powell <spowell@instructure.com> Product-Review: Rex Fleischer <rfleischer@instructure.com>
2020-04-16 02:52:10 +08:00
environment:
POSTGRES_PASSWORD: sekret
redis:
image: redis:alpine