#! /bin/bash

# Tired of building canvas?
# now you can add a `image: instructure/canvas-lms:master` to your docker-compose.local.yml
# then just `docker-compose pull web`
# note if you do a `docker-compose build` it will try to build everything
# but if you do a `docker-compose up` it will just use the image you pulled down
# there is some weirdness to the way canvas is setup, that make this a little more
# difficult. We need to copy the Gemfile.lock from the container, and nuke stale
# volumes. You should be able to go while without pulling the new image down by
# running `bundle` and `yarn install` in your container after pulling
#
# ```yml
# version: '2'
# services:
#   web: &WEB
#     image: instructure/canvas-lms:master
#     build:
#       context: .
#   guard:
#     <<: *WEB
#   jobs:
#     <<: *WEB
#   webpack:
#     <<: *WEB
# ```
#

docker-compose down
docker-compose pull web
docker volume rm canvaslms_bundler canvaslms_canvas-docker-gems canvaslms_node_modules canvaslms_quizzes_node_modules canvaslms_selinimum_node_modules canvaslms_yarn-cache
docker run --rm instructure/canvas-lms:master cat Gemfile.lock > Gemfile.lock
docker-compose run --rm web bash -c "bundle; bundle exec rake db:migrate"

Add script to assist those not wanting to build canvas :D
Add script to assist those not wanting to build canvas :D

Change-Id: I597a91f4bf092729ee4d292b65fc5e65c6511247
Reviewed-on: https://gerrit.instructure.com/107876
Reviewed-by: Josh Orr <a2b6e8624e42637b1fd540dea491d88242856463@instructure.com>
Tested-by: Jenkins
Reviewed-by: Tyler Pickett <3f20fcf21b1970c94966160adcf831eedd808a06@instructure.com>
Product-Review: Caleb Guanzon <54fa1f30d451e4f3c341a8f3c47c9215fd0be9c6@instructure.com>
QA-Review: Caleb Guanzon <54fa1f30d451e4f3c341a8f3c47c9215fd0be9c6@instructure.com>
