Revert "asset install in Dockerfile"
This reverts commit 655cecbd5d
.
Reason for revert: broke dev environments
Change-Id: I97f47a8ef7ac369b3cb30e448a3cfa9997c03930
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/267650
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kyle Rosenbaum <krosenbaum@instructure.com>
Reviewed-by: Andrea Cirulli <andrea.cirulli@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: James Butters <jbutters@instructure.com>
This commit is contained in:
parent
ce77de7e4d
commit
cc32af3ccd
50
Dockerfile
50
Dockerfile
|
@ -9,7 +9,7 @@ LABEL maintainer="Instructure"
|
|||
|
||||
ARG POSTGRES_CLIENT=12
|
||||
ENV APP_HOME /usr/src/app/
|
||||
ENV RAILS_ENV development
|
||||
ENV RAILS_ENV production
|
||||
ENV NGINX_MAX_UPLOAD_SIZE 10g
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV LANGUAGE en_US.UTF-8
|
||||
|
@ -27,7 +27,6 @@ ENV BUNDLE_APP_CONFIG /home/docker/.bundle
|
|||
WORKDIR $APP_HOME
|
||||
|
||||
USER root
|
||||
COPY --chown=docker:docker . ${APP_HOME}
|
||||
|
||||
ARG USER_ID
|
||||
# This step allows docker to write files to a host-mounted volume with the correct user permissions.
|
||||
|
@ -56,7 +55,6 @@ RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - \
|
|||
fontforge \
|
||||
autoconf \
|
||||
automake \
|
||||
gosu \
|
||||
git \
|
||||
build-essential \
|
||||
&& ([ $(lsb_release -rs) = "18.04" ] || apt-get install -qqy --no-install-recommends \
|
||||
|
@ -86,21 +84,41 @@ RUN if [ -e /var/lib/gems/$RUBY_MAJOR.0/gems/bundler-* ]; then BUNDLER_INSTALL="
|
|||
&& gem uninstall --all --ignore-dependencies --force $BUNDLER_INSTALL bundler \
|
||||
&& gem install bundler --no-document -v $BUNDLER_VERSION \
|
||||
&& find $GEM_HOME ! -user docker | xargs chown docker:docker
|
||||
|
||||
RUN npm install -g npm@latest && npm cache clean --force
|
||||
|
||||
USER docker
|
||||
|
||||
RUN set -eux; \
|
||||
\
|
||||
# set up bundle config options \
|
||||
bundle config --global build.nokogiri --use-system-libraries \
|
||||
&& bundle config --global build.ffi --enable-system-libffi \
|
||||
&& mkdir -p /home/docker/.bundle \
|
||||
&& bundle install --jobs $(nproc)
|
||||
|
||||
RUN (yarn install --ignore-optional --pure-lockfile || yarn install --ignore-optional --pure-lockfile --network-concurrency 1)
|
||||
RUN bundle exec rake canvas:compile_assets
|
||||
|
||||
USER root
|
||||
COPY docker-entrypoint.sh /root/entrypoint.sh
|
||||
mkdir -p \
|
||||
.yardoc \
|
||||
app/stylesheets/brandable_css_brands \
|
||||
app/views/info \
|
||||
config/locales/generated \
|
||||
gems/canvas_i18nliner/node_modules \
|
||||
log \
|
||||
node_modules \
|
||||
packages/canvas-media/es \
|
||||
packages/canvas-media/lib \
|
||||
packages/canvas-media/node_modules \
|
||||
packages/canvas-planner/lib \
|
||||
packages/canvas-planner/node_modules \
|
||||
packages/canvas-rce/canvas \
|
||||
packages/canvas-rce/lib \
|
||||
packages/canvas-rce/node_modules \
|
||||
packages/jest-moxios-utils/node_modules \
|
||||
packages/js-utils/es \
|
||||
packages/js-utils/lib \
|
||||
packages/js-utils/node_modules \
|
||||
packages/k5uploader/es \
|
||||
packages/k5uploader/lib \
|
||||
packages/k5uploader/node_modules \
|
||||
packages/old-copy-of-react-14-that-is-just-here-so-if-analytics-is-checked-out-it-doesnt-change-yarn.lock/node_modules \
|
||||
pacts \
|
||||
public/dist \
|
||||
public/doc/api \
|
||||
public/javascripts/translations \
|
||||
reports \
|
||||
tmp \
|
||||
/home/docker/.bundler/ \
|
||||
/home/docker/.cache/yarn \
|
||||
/home/docker/.gem/
|
||||
|
|
|
@ -48,7 +48,6 @@ RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - \
|
|||
fontforge \
|
||||
autoconf \
|
||||
automake \
|
||||
gosu \
|
||||
git \
|
||||
build-essential \
|
||||
&& ([ $(lsb_release -rs) = "18.04" ] || apt-get install -qqy --no-install-recommends \
|
||||
|
@ -78,7 +77,6 @@ RUN if [ -e /var/lib/gems/$RUBY_MAJOR.0/gems/bundler-* ]; then BUNDLER_INSTALL="
|
|||
&& gem uninstall --all --ignore-dependencies --force $BUNDLER_INSTALL bundler \
|
||||
&& gem install bundler --no-document -v $BUNDLER_VERSION \
|
||||
&& find $GEM_HOME ! -user docker | xargs chown docker:docker
|
||||
|
||||
RUN npm install -g npm@latest && npm cache clean --force
|
||||
|
||||
USER docker
|
||||
|
|
|
@ -81,9 +81,10 @@ EOF
|
|||
set -o errexit -o errtrace -o nounset -o pipefail -o xtrace
|
||||
source script/common/canvas/build_helpers.sh
|
||||
|
||||
check_gemfile
|
||||
build_images
|
||||
check_gemfile
|
||||
docker_compose_up
|
||||
build_assets
|
||||
'''
|
||||
}
|
||||
|
||||
|
|
|
@ -10,11 +10,7 @@ LABEL maintainer="Instructure"
|
|||
|
||||
ARG POSTGRES_CLIENT=12
|
||||
ENV APP_HOME /usr/src/app/
|
||||
<% if development? -%>
|
||||
ENV RAILS_ENV development
|
||||
<% else -%>
|
||||
ENV RAILS_ENV production
|
||||
<% end -%>
|
||||
ENV NGINX_MAX_UPLOAD_SIZE 10g
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV LANGUAGE en_US.UTF-8
|
||||
|
@ -33,7 +29,6 @@ WORKDIR $APP_HOME
|
|||
|
||||
USER root
|
||||
<% if development? -%>
|
||||
COPY --chown=docker:docker . ${APP_HOME}
|
||||
|
||||
ARG USER_ID
|
||||
# This step allows docker to write files to a host-mounted volume with the correct user permissions.
|
||||
|
@ -63,7 +58,6 @@ RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - \
|
|||
fontforge \
|
||||
autoconf \
|
||||
automake \
|
||||
gosu \
|
||||
git \
|
||||
build-essential \
|
||||
&& ([ $(lsb_release -rs) = "18.04" ] || apt-get install -qqy --no-install-recommends \
|
||||
|
@ -93,7 +87,6 @@ RUN if [ -e /var/lib/gems/$RUBY_MAJOR.0/gems/bundler-* ]; then BUNDLER_INSTALL="
|
|||
&& gem uninstall --all --ignore-dependencies --force $BUNDLER_INSTALL bundler \
|
||||
&& gem install bundler --no-document -v $BUNDLER_VERSION \
|
||||
&& find $GEM_HOME ! -user docker | xargs chown docker:docker
|
||||
|
||||
RUN npm install -g npm@latest && npm cache clean --force
|
||||
|
||||
USER docker
|
||||
|
@ -114,16 +107,6 @@ RUN set -eux; \
|
|||
<% end -%>
|
||||
<% if development? -%>
|
||||
RUN set -eux; \
|
||||
\
|
||||
# set up bundle config options \
|
||||
bundle config --global build.nokogiri --use-system-libraries \
|
||||
&& bundle config --global build.ffi --enable-system-libffi \
|
||||
&& mkdir -p /home/docker/.bundle \
|
||||
&& bundle install --jobs $(nproc)
|
||||
|
||||
RUN (yarn install --ignore-optional --pure-lockfile || yarn install --ignore-optional --pure-lockfile --network-concurrency 1)
|
||||
RUN bundle exec rake canvas:compile_assets
|
||||
|
||||
USER root
|
||||
COPY docker-entrypoint.sh /root/entrypoint.sh
|
||||
mkdir -p \
|
||||
<%= docker_compose_volume_paths.join(" \\\n ") %>
|
||||
<% end -%>
|
||||
|
|
|
@ -5,16 +5,42 @@ services:
|
|||
build:
|
||||
context: .
|
||||
volumes:
|
||||
- '.:/usr/src/app'
|
||||
- .:/usr/src/app
|
||||
- api_docs:/usr/src/app/public/doc/api
|
||||
- brandable_css_brands:/usr/src/app/app/stylesheets/brandable_css_brands
|
||||
- bundler:/home/docker/.bundler/
|
||||
- canvas-docker-gems:/home/docker/.gem/
|
||||
- canvas-media_es:/usr/src/app/packages/canvas-media/es
|
||||
- canvas-media_lib:/usr/src/app/packages/canvas-media/lib
|
||||
- canvas-media_node_modules:/usr/src/app/packages/canvas-media/node_modules
|
||||
- canvas-planner_node_modules:/usr/src/app/packages/canvas-planner/node_modules
|
||||
- canvas-planner_lib:/usr/src/app/packages/canvas-planner/lib
|
||||
- canvas-rce_canvas:/usr/src/app/packages/canvas-rce/canvas
|
||||
- canvas-rce_lib:/usr/src/app/packages/canvas-rce/lib
|
||||
- canvas-rce_node_modules:/usr/src/app/packages/canvas-rce/node_modules
|
||||
- i18nliner_node_modules:/usr/src/app/gems/canvas_i18nliner/node_modules
|
||||
- jest-moxios-utils_node_modules:/usr/src/app/packages/jest-moxios-utils/node_modules
|
||||
- js-utils_es:/usr/src/app/packages/js-utils/es
|
||||
- js-utils_lib:/usr/src/app/packages/js-utils/lib
|
||||
- js-utils_node_modules:/usr/src/app/packages/js-utils/node_modules
|
||||
- k5uploader_es:/usr/src/app/packages/k5uploader/es
|
||||
- k5uploader_lib:/usr/src/app/packages/k5uploader/lib
|
||||
- k5uploader_node_modules:/usr/src/app/packages/k5uploader/node_modules
|
||||
- locales:/usr/src/app/config/locales/generated
|
||||
- log:/usr/src/app/log
|
||||
- node_modules:/usr/src/app/node_modules
|
||||
- old-copy-of-react-14-that-is-just-here-so-if-analytics-is-checked-out-it-doesnt-change-yarn.lock_node_modules:/usr/src/app/packages/old-copy-of-react-14-that-is-just-here-so-if-analytics-is-checked-out-it-doesnt-change-yarn.lock/node_modules
|
||||
- pacts:/usr/src/app/pacts
|
||||
- public_dist:/usr/src/app/public/dist
|
||||
- reports:/usr/src/app/reports
|
||||
- styleguide:/usr/src/app/app/views/info
|
||||
- tmp:/usr/src/app/tmp
|
||||
- translations:/usr/src/app/public/javascripts/translations
|
||||
- yardoc:/usr/src/app/.yardoc
|
||||
- yarn-cache:/home/docker/.cache/yarn
|
||||
environment: &BASE-ENV
|
||||
ENCRYPTION_KEY: facdd3a131ddd8988b14f6e4e01039c93cfa0160
|
||||
RAILS_ENV: development
|
||||
cap_add:
|
||||
- SYS_ADMIN
|
||||
# for linux the default profile restricts mount usage, set to have no restrictions
|
||||
security_opt:
|
||||
- apparmor:unconfined
|
||||
entrypoint: /root/entrypoint.sh
|
||||
|
||||
webpack:
|
||||
<<: *BASE
|
||||
|
@ -43,4 +69,36 @@ services:
|
|||
- ./script:/tmp/script
|
||||
|
||||
volumes:
|
||||
api_docs: {}
|
||||
brandable_css_brands: {}
|
||||
bundler: {}
|
||||
canvas-docker-gems: {}
|
||||
canvas-media_es: {}
|
||||
canvas-media_lib: {}
|
||||
canvas-media_node_modules: {}
|
||||
canvas-planner_node_modules: {}
|
||||
canvas-planner_lib: {}
|
||||
canvas-rce_canvas: {}
|
||||
canvas-rce_lib: {}
|
||||
canvas-rce_node_modules: {}
|
||||
i18nliner_node_modules: {}
|
||||
jest-moxios-utils_node_modules: {}
|
||||
js-utils_es: {}
|
||||
js-utils_lib: {}
|
||||
js-utils_node_modules: {}
|
||||
k5uploader_es: {}
|
||||
k5uploader_lib: {}
|
||||
k5uploader_node_modules: {}
|
||||
locales: {}
|
||||
log: {}
|
||||
node_modules: {}
|
||||
old-copy-of-react-14-that-is-just-here-so-if-analytics-is-checked-out-it-doesnt-change-yarn.lock_node_modules: {}
|
||||
pg_data: {}
|
||||
pacts: {}
|
||||
public_dist: {}
|
||||
reports: {}
|
||||
styleguide: {}
|
||||
tmp: {}
|
||||
translations: {}
|
||||
yardoc: {}
|
||||
yarn-cache: {}
|
||||
|
|
|
@ -9,14 +9,6 @@ services:
|
|||
- redis
|
||||
environment:
|
||||
POSTGRES_PASSWORD: sekret
|
||||
cap_add:
|
||||
- SYS_ADMIN
|
||||
# for linux the default profile restricts mount usage, set to have no restrictions
|
||||
security_opt:
|
||||
- apparmor:unconfined
|
||||
entrypoint: /root/entrypoint.sh
|
||||
command: [ "/tini", "--", "/usr/src/entrypoint" ]
|
||||
|
||||
|
||||
jobs:
|
||||
<<: *WEB
|
||||
|
|
|
@ -6,16 +6,12 @@ services:
|
|||
context: .
|
||||
volumes:
|
||||
- code:/usr/src/app
|
||||
- bundler:/home/docker/.bundler/
|
||||
- canvas-docker-gems:/home/docker/.gem/
|
||||
- yarn-cache:/home/docker/.cache/yarn
|
||||
environment: &BASE-ENV
|
||||
ENCRYPTION_KEY: facdd3a131ddd8988b14f6e4e01039c93cfa0160
|
||||
RAILS_ENV: development
|
||||
MUTAGEN: 'true'
|
||||
cap_add:
|
||||
- SYS_ADMIN
|
||||
# for linux the default profile restricts mount usage, set to have no restrictions
|
||||
security_opt:
|
||||
- apparmor:unconfined
|
||||
entrypoint: /root/entrypoint.sh
|
||||
|
||||
webpack:
|
||||
<<: *BASE
|
||||
|
@ -43,7 +39,10 @@ services:
|
|||
|
||||
volumes:
|
||||
code: {}
|
||||
bundler: {}
|
||||
canvas-docker-gems: {}
|
||||
pg_data: {}
|
||||
yarn-cache: {}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
export TMP_APP_HOME="/tmp/assets/src/app/"
|
||||
|
||||
asset_dirs=(
|
||||
"node_modules/"
|
||||
"packages/js-utils/node_modules"
|
||||
"packages/js-utils/lib"
|
||||
"packages/js-utils/es"
|
||||
"packages/canvas-media/node_modules"
|
||||
"packages/canvas-media/lib"
|
||||
"packages/canvas-media/es"
|
||||
"packages/jest-moxios-utils/node_modules"
|
||||
"packages/k5uploader/node_modules"
|
||||
"packages/k5uploader/lib"
|
||||
"packages/k5uploader/es"
|
||||
"packages/canvas-planner/node_modules"
|
||||
"packages/canvas-planner/lib"
|
||||
"packages/canvas-planner/es"
|
||||
"packages/canvas-rce/node_modules"
|
||||
"packages/canvas-rce/lib"
|
||||
"packages/canvas-rce/es"
|
||||
"packages/canvas-rce/canvas"
|
||||
"packages/translations/node_modules"
|
||||
"packages/old-copy-of-react-14-that-is-just-here-so-if-analytics-is-checked-out-it-doesnt-change-yarn.lock/node_modules"
|
||||
"public/javascripts/translations"
|
||||
"public/dist"
|
||||
"log/"
|
||||
"config/locales/generated"
|
||||
"stylesheets/brandable_css_brands"
|
||||
"app/views/info"
|
||||
"pacts"
|
||||
"public/doc/api"
|
||||
".yardoc"
|
||||
"reports"
|
||||
"tmp"
|
||||
)
|
||||
umask 0000
|
||||
[ ! -z "${MUTAGEN-}" ] && chown docker:docker /usr/src/app
|
||||
function copy_if_needed() {
|
||||
if [ -f "$APP_HOME$1" ]; then
|
||||
if ! diff -q "$TMP_APP_HOME$1" "$APP_HOME$1"; then
|
||||
cp "$TMP_APP_HOME$1" "$APP_HOME$1"
|
||||
fi
|
||||
else
|
||||
cp "$TMP_APP_HOME$1" "$APP_HOME$1"
|
||||
fi
|
||||
}
|
||||
|
||||
mkdir -p /tmp/assets/src
|
||||
mount --bind /usr/src /tmp/assets/src
|
||||
copy_if_needed Gemfile.lock
|
||||
copy_if_needed yarn.lock
|
||||
for dir in "${asset_dirs[@]}"; do
|
||||
if [ -d "$TMP_APP_HOME$dir" ]; then
|
||||
mkdir -p "$APP_HOME$dir"
|
||||
mount --bind "$TMP_APP_HOME$dir" "$APP_HOME$dir"
|
||||
fi
|
||||
done
|
||||
find "$TMP_APP_HOME"gems/ -maxdepth 3 -name 'node_modules' -type d -printf "%P\n" | xargs -I% sh -c "mkdir -p ${APP_HOME}gems/% && mount --bind ${TMP_APP_HOME}gems/% ${APP_HOME}gems/%"
|
||||
|
||||
exec gosu docker "$@"
|
|
@ -40,6 +40,28 @@ need to remove it before we can install gems, to prevent conflicting dependency
|
|||
errors.'
|
||||
confirm_command 'rm -f Gemfile.lock' || true
|
||||
fi
|
||||
|
||||
# Fixes 'error while trying to write to `/usr/src/app/Gemfile.lock`'
|
||||
if ! _canvas_lms_track_with_log $DOCKER_COMMAND run --no-deps --rm web touch Gemfile.lock; then
|
||||
message \
|
||||
"The 'docker' user is not allowed to write to Gemfile.lock. We need write
|
||||
permissions so we can install gems."
|
||||
touch Gemfile.lock
|
||||
confirm_command 'chmod a+rw Gemfile.lock' || true
|
||||
fi
|
||||
}
|
||||
|
||||
function build_assets {
|
||||
message "Building assets..."
|
||||
start_spinner "> Bundle install..."
|
||||
_canvas_lms_track_with_log run_command ./script/install_assets.sh -c bundle
|
||||
stop_spinner
|
||||
start_spinner "> Yarn install...."
|
||||
_canvas_lms_track_with_log run_command ./script/install_assets.sh -c yarn
|
||||
stop_spinner
|
||||
start_spinner "> Compile assets...."
|
||||
_canvas_lms_track_with_log run_command ./script/install_assets.sh -c compile
|
||||
stop_spinner
|
||||
}
|
||||
|
||||
function database_exists {
|
||||
|
@ -59,28 +81,26 @@ permissions so we can run migrations."
|
|||
if database_exists; then
|
||||
stop_spinner
|
||||
message \
|
||||
'An existing database was found.'
|
||||
if ! is_running_on_jenkins; then
|
||||
prompt "Do you want to drop and create new or migrate existing? [DROP/migrate] " dropped
|
||||
fi
|
||||
if [[ ${dropped:-migrate} == 'DROP' ]]; then
|
||||
message \
|
||||
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
'An existing database was found.
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
This script will destroy ALL EXISTING DATA if it continues
|
||||
If you want to migrate the existing database, cancel now
|
||||
If you want to migrate the existing database, use docker_dev_update
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
|
||||
message 'About to run "bundle exec rake db:drop"'
|
||||
if ! is_running_on_jenkins; then
|
||||
prompt "type NUKE in all caps: " nuked
|
||||
[[ ${nuked:-n} == 'NUKE' ]] || exit 1
|
||||
fi
|
||||
start_spinner "Deleting db....."
|
||||
_canvas_lms_track_with_log run_command bundle exec rake db:drop
|
||||
stop_spinner
|
||||
fi
|
||||
fi
|
||||
stop_spinner
|
||||
if [[ ${dropped:-DROP} == 'DROP' ]]; then
|
||||
|
||||
start_spinner "Creating new database...."
|
||||
_canvas_lms_track_with_log run_command bundle exec rake db:create
|
||||
stop_spinner
|
||||
fi
|
||||
# Rails db:migrate only runs on development by default
|
||||
# https://discuss.rubyonrails.org/t/db-drop-create-migrate-behavior-with-rails-env-development/74435
|
||||
start_spinner "Migrating (Development env)...."
|
||||
|
@ -89,7 +109,7 @@ If you want to migrate the existing database, cancel now
|
|||
start_spinner "Migrating (Test env)...."
|
||||
_canvas_lms_track_with_log run_command bundle exec rake db:migrate RAILS_ENV=test
|
||||
stop_spinner
|
||||
[[ ${dropped:-DROP} == 'migrate' ]] || _canvas_lms_track run_command bundle exec rake db:initial_setup
|
||||
_canvas_lms_track run_command bundle exec rake db:initial_setup
|
||||
}
|
||||
|
||||
function sync_bundler_version {
|
||||
|
@ -149,10 +169,12 @@ function setup_docker_compose_override {
|
|||
message 'Setup override yaml and .env...'
|
||||
if is_mutagen; then
|
||||
message "Copying default configuration from docker-compose/mutagen/docker-compose.override.yml to docker-compose.override.yml"
|
||||
confirm_command 'cp docker-compose/mutagen/docker-compose.override.yml docker-compose.override.yml' || true
|
||||
cp docker-compose/mutagen/docker-compose.override.yml docker-compose.override.yml
|
||||
elif [ -f "docker-compose.override.yml" ]; then
|
||||
message "docker-compose.override.yml exists, skipping copy of default configuration"
|
||||
else
|
||||
message "Copying default configuration from config/docker-compose.override.yml.example to docker-compose.override.yml"
|
||||
confirm_command 'cp config/docker-compose.override.yml.example docker-compose.override.yml' || true
|
||||
cp config/docker-compose.override.yml.example docker-compose.override.yml
|
||||
fi
|
||||
if [ -f ".env" ]; then
|
||||
prompt '.env file exists, would you like to reset it to default? [y/n]' confirm
|
||||
|
|
|
@ -130,6 +130,7 @@ function docker_compose_up {
|
|||
if is_mutagen; then
|
||||
start_spinner "Starting mutagen containers..."
|
||||
_canvas_lms_track_with_log mutagen compose up --no-start web
|
||||
_canvas_lms_track_with_log mutagen compose run -u root --rm web chown docker:docker /usr/src/app
|
||||
stop_spinner
|
||||
fi
|
||||
start_spinner "Starting docker containers..."
|
||||
|
@ -165,6 +166,24 @@ function is_running_on_jenkins() {
|
|||
[[ -n "${JENKINS:-}" ]]
|
||||
}
|
||||
|
||||
function rebuild_docker_images {
|
||||
if [ -n "$(git diff --name-only "${before_rebase_sha:-origin/master}" | grep -E 'Dockerfile$|Dockerfile.githook$|docker-compose/postgres/Dockerfile$')" ]; then
|
||||
message "There have been some updates made to Dockerfile, you should rebuild your docker images."
|
||||
prompt "Rebuild docker images? [y/n]" rebuild_image
|
||||
if [ "${rebuild_image:n}" == 'y' ]; then
|
||||
start_spinner "Rebuilding docker images..."
|
||||
if [[ "${OS:-}" == 'Linux' && -z "${CANVAS_SKIP_DOCKER_USERMOD:-}" ]]; then
|
||||
_canvas_lms_track_with_log docker-compose build --pull --build-arg USER_ID=$(id -u)
|
||||
else
|
||||
_canvas_lms_track_with_log $DOCKER_COMMAND build --pull
|
||||
fi
|
||||
stop_spinner
|
||||
else
|
||||
echo "Your docker image is now outdated and needs to be rebuilt! You should run \"${DOCKER_COMMAND} build\"."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function is_mutagen {
|
||||
[ -f ".mutagen" ]
|
||||
}
|
||||
|
@ -180,19 +199,6 @@ function docker_running {
|
|||
fi
|
||||
}
|
||||
|
||||
function containers_running {
|
||||
if [[ "$(docker-compose top | wc -l)" -gt 0 ]]; then
|
||||
echo "You should probably stop docker containers before rebasing code"
|
||||
prompt "Would you like to attempt to stop containers with docker-compose stop? [y/n]" stop
|
||||
if [[ ${stop:-n} == 'y' ]]; then
|
||||
docker-compose stop
|
||||
else
|
||||
echo "Continuing with docker containers running, this may cause errors."
|
||||
fi
|
||||
fi
|
||||
echo ""
|
||||
}
|
||||
|
||||
function os_setup {
|
||||
if [[ $OS == 'Darwin' ]]; then
|
||||
. script/common/os/mac/dev_setup.sh
|
||||
|
|
|
@ -23,8 +23,6 @@ rm .mutagen &> /dev/null || true
|
|||
usage () {
|
||||
echo "usage:"
|
||||
printf " --mutagen\t\t\t\tUse Mutagen with Docker to setup development environment.\n"
|
||||
printf " --update-code [skip-canvas] [skip-plugins [<plugin1>,...]\tRebase canvas-lms and plugins. Optional skip-canvas and\n"
|
||||
printf " \t\t\t\t\t\t\t\tskip-plugins. Comma separated list of plugins to skip.\n"
|
||||
printf " -h|--help\t\t\t\tDisplay usage\n\n"
|
||||
}
|
||||
|
||||
|
@ -40,31 +38,6 @@ while :; do
|
|||
usage # Display a usage synopsis.
|
||||
exit
|
||||
;;
|
||||
--update-code)
|
||||
UPDATE_CODE=true
|
||||
before_rebase_sha="$(git rev-parse HEAD)"
|
||||
params=()
|
||||
while :; do
|
||||
case $2 in
|
||||
skip-canvas)
|
||||
unset before_rebase_sha
|
||||
params+=(--skip-canvas)
|
||||
;;
|
||||
skip-plugins)
|
||||
if [ "$3" ] && [[ "$3" != "skip-canvas" ]]; then
|
||||
repos=$3
|
||||
params+=(--skip-plugins $repos)
|
||||
shift
|
||||
else
|
||||
params+=(--skip-plugins)
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
break
|
||||
esac
|
||||
shift
|
||||
done
|
||||
;;
|
||||
--mutagen)
|
||||
touch .mutagen
|
||||
DOCKER_COMMAND="mutagen compose"
|
||||
|
@ -81,17 +54,16 @@ done
|
|||
|
||||
print_canvas_intro
|
||||
|
||||
|
||||
create_log_file
|
||||
init_log_file "Docker Dev Setup"
|
||||
os_setup
|
||||
message 'Now we can set up Canvas!'
|
||||
docker_running || exit 1
|
||||
containers_running
|
||||
[[ -n "$UPDATE_CODE" ]] && ./script/rebase_canvas_and_plugins.sh "${params[@]}"
|
||||
copy_docker_config
|
||||
setup_docker_compose_override
|
||||
check_gemfile
|
||||
build_images
|
||||
docker_compose_up
|
||||
check_gemfile
|
||||
build_assets
|
||||
create_db
|
||||
display_next_steps
|
||||
|
|
|
@ -1,7 +1,104 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
source script/common/utils/common.sh
|
||||
source script/common/canvas/build_helpers.sh
|
||||
SCRIPT_NAME="$0"
|
||||
warning_message "$SCRIPT_NAME is deprecated and will removed in the near future. Please use script/docker_dev_setup.sh
|
||||
for updating your docker environment."
|
||||
|
||||
LOG="$(pwd)/log/docker_dev_update.log"
|
||||
DOCKER='true'
|
||||
SCRIPT_NAME=$0
|
||||
|
||||
trap trap_result EXIT
|
||||
trap "printf '\nTerminated\n' && exit 130" SIGINT
|
||||
|
||||
usage () {
|
||||
echo "usage:"
|
||||
printf " --update-code [skip-canvas] [skip-plugins [<plugin1>,...]\tRebase canvas-lms and plugins. Optional skip-canvas and\n"
|
||||
printf " \t\t\t\t\t\t\t\tskip-plugins. Comma separated list of plugins to skip.\n"
|
||||
printf " -h|--help\t\t\t\t\t\t\tDisplay usage\n\n"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo "$*" 1>&2
|
||||
usage
|
||||
exit 1
|
||||
}
|
||||
|
||||
_canvas_lms_opt_in_telemetry "$SCRIPT_NAME" "$LOG"
|
||||
if is_mutagen; then
|
||||
DOCKER_COMMAND="mutagen compose"
|
||||
CANVAS_SKIP_DOCKER_USERMOD='true'
|
||||
print_mutagen_intro
|
||||
fi
|
||||
|
||||
while :; do
|
||||
case $1 in
|
||||
-h|-\?|--help)
|
||||
usage
|
||||
exit
|
||||
;;
|
||||
--update-code)
|
||||
UPDATE_CODE=true
|
||||
before_rebase_sha="$(git rev-parse HEAD)"
|
||||
params=()
|
||||
while :; do
|
||||
case $2 in
|
||||
skip-canvas)
|
||||
unset before_rebase_sha
|
||||
params+=(--skip-canvas)
|
||||
;;
|
||||
skip-plugins)
|
||||
if [ "$3" ] && [[ "$3" != "skip-canvas" ]]; then
|
||||
repos=$3
|
||||
params+=(--skip-plugins $repos)
|
||||
shift
|
||||
else
|
||||
params+=(--skip-plugins)
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
break
|
||||
esac
|
||||
shift
|
||||
done
|
||||
;;
|
||||
?*)
|
||||
die 'ERROR: Unknown option: ' "$1" >&2
|
||||
;;
|
||||
*)
|
||||
break
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# check for docker daemon running before anything else
|
||||
docker_running || exit 1
|
||||
|
||||
if [ -f "docker-compose.override.yml" ]; then
|
||||
echo "docker-compose.override.yml exists, skipping copy of default configuration"
|
||||
else
|
||||
echo "Copying default configuration from config/docker-compose.override.yml.example to docker-compose.override.yml"
|
||||
cp config/docker-compose.override.yml.example docker-compose.override.yml
|
||||
fi
|
||||
|
||||
if [[ -n "$UPDATE_CODE" ]] && [[ "$(docker-compose top | wc -l)" -gt 0 ]]; then
|
||||
echo "You should probably stop docker containers before rebasing code"
|
||||
prompt "Would you like to attempt to stop containers with docker-compose stop? [y/n]" stop
|
||||
if [[ ${stop:-n} == 'y' ]]; then
|
||||
docker-compose stop
|
||||
else
|
||||
echo "Continuing with docker containers running, this may cause errors."
|
||||
fi
|
||||
fi
|
||||
echo ""
|
||||
|
||||
create_log_file
|
||||
message "Bringing Canvas up to date ..."
|
||||
init_log_file "Docker Dev Update"
|
||||
[[ -n "$UPDATE_CODE" ]] && ./script/rebase_canvas_and_plugins.sh "${params[@]}"
|
||||
rebuild_docker_images
|
||||
docker_compose_up
|
||||
bundle_install_with_check
|
||||
install_node_packages
|
||||
compile_assets
|
||||
rake_db_migrate_dev_and_test
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -o nounset -o errexit -o errtrace
|
||||
|
||||
|
||||
function bundle_config_and_install() {
|
||||
# set up bundle config options \
|
||||
echo "Running bundle config and bundle install..."
|
||||
bundle config --global build.nokogiri --use-system-libraries &&
|
||||
bundle config --global build.ffi --enable-system-libffi &&
|
||||
mkdir -p /home/docker/.bundle &&
|
||||
bundle install --jobs $(nproc)
|
||||
}
|
||||
|
||||
function yarn_install() {
|
||||
echo "Running yarn install..."
|
||||
yarn install --ignore-optional --pure-lockfile || yarn install --ignore-optional --pure-lockfile --network-concurrency 1
|
||||
}
|
||||
|
||||
function compile_assets() {
|
||||
echo "Running compile assets dev (css and js only, no docs or styleguide)..."
|
||||
bundle exec rails canvas:compile_assets_dev
|
||||
}
|
||||
|
||||
ALL_COMMANDS='y'
|
||||
while getopts ":c:" opt; do
|
||||
case ${opt} in
|
||||
c )
|
||||
command=${OPTARG}
|
||||
if [ "$command" = "bundle" ]
|
||||
then
|
||||
BUNDLE_CONFIG='y'
|
||||
ALL_COMMANDS='n'
|
||||
elif [ "$command" = "yarn" ]
|
||||
then
|
||||
YARN_INSTALL='y'
|
||||
ALL_COMMANDS='n'
|
||||
elif [ "$command" = "compile" ]
|
||||
then
|
||||
COMPILE='y'
|
||||
ALL_COMMANDS='n'
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ ${BUNDLE_CONFIG-n} = 'y' ]] || [[ ${ALL_COMMANDS-n} = 'y' ]]; then
|
||||
bundle_config_and_install
|
||||
fi
|
||||
if [[ ${YARN_INSTALL-n} = 'y' ]] || [[ ${ALL_COMMANDS-n} = 'y' ]]; then
|
||||
yarn_install
|
||||
fi
|
||||
if [[ ${COMPILE-n} = 'y' ]] || [[ ${ALL_COMMANDS-n} = 'y' ]]; then
|
||||
compile_assets
|
||||
fi
|
Loading…
Reference in New Issue