forked from beyond-z/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile.production
173 lines (157 loc) · 7.34 KB
/
Dockerfile.production
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# This is end-of-lifed Ubuntu 14, but we want to at least get canvas into a container and
# running first before we figure out how to uprade the OS and all dependencies (like versions
# of node and native built gems).
FROM heroku/cedar:14
# Required to prevent: Error: lib/dress_code/extractor.rb:31:in `scan': invalid byte sequence in US-ASCII
ENV LC_ALL "en_US.UTF-8"
ENV LANG "en_US.UTF-8"
# Needed by heroku ps:exec to work. Also the re-linking of /bin/sh below is for that too.
# See: https://devcenter.heroku.com/articles/exec#using-with-docker
WORKDIR /tmp
RUN wget "https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/openssh/1:7.2p2-4ubuntu2.8/openssh_7.2p2.orig.tar.gz" \
&& tar xfz openssh_7.2p2.orig.tar.gz \
&& cd openssh-7.2p2 \
&& ./configure \
&& make \
&& make install
RUN rm /bin/sh && ln -s /bin/bash /bin/sh \
&& apt-get -qqy remove ruby ruby-dev ruby1.9.1 ruby1.9.1-dev libruby1.9.1 \
&& apt-get -qqy autoremove \
&& apt-get update -qq \
&& apt-get install -qqy software-properties-common \
&& apt-add-repository -y ppa:brightbox/ruby-ng \
&& apt-get update -qq \
&& apt-get install -qqy ruby2.1 ruby2.1-dev
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN DEBIAN_FRONTEND=noninteractive apt-get update -qq \
&& apt-get install -qqy \
libsqlite3-dev \
nodejs \
postgresql-client \
libxmlsec1-dev \
unzip \
fontforge \
vim \
python-lxml \
&& npm cache clean -f \
&& npm install -g n \
&& n 0.12.14 \
&& rm -rf /var/lib/apt/lists/* \
&& gem install bundler -v 1.15.2 \
&& mkdir /app \
&& useradd -m dockeruser \
&& chown dockeruser:dockeruser /app
ARG RAILS_ENV=production
ENV RAILS_ENV ${RAILS_ENV}
WORKDIR /app
# Copy files needed for bundle install to work.
# By explicitly doing only the files needed, rebuilds won't re-run
# 'bundle install' unless one of these changes.
COPY --chown=dockeruser:dockeruser Gemfile Gemfile.lock /app/
COPY --chown=dockeruser:dockeruser Gemfile.d /app/Gemfile.d
COPY --chown=dockeruser:dockeruser gems /app/gems
COPY --chown=dockeruser:dockeruser config/canvas_rails4_2.rb /app/config/
USER dockeruser
#RUN bundle install --path vendor/bundle --without=sqlite mysql --jobs 4 --verbose
RUN bundle install --path vendor/bundle --without=sqlite mysql --jobs 4
# This sets up the QTI Migration tool. This used to be part of the deploy script
# in config/deploy. Moving to containers we left this step out
RUN git clone https://github.com/instructure/QTIMigrationTool.git ./vendor/QTIMigrationTool \
&& chmod +x ./vendor/QTIMigrationTool/migrate.py
# TODO: when copying all the individual files over, the manifest gets too big for Heroku to handle
# aka: latest: digest: sha256:XXXXXX size: 7655
# Heroku only seems to be able to handle manifests smaller than 7K bytes.
# See this for the exact issue I'm running into: https://github.com/moby/moby/issues/24444
# Since we always build the full image when pushing to heroku, this isn't necessary,
# and I'm just copying the whole app over.
# but we should switch the Dockerfiles over to use a multi-stage build as a solution
# once I verify this works.
# Note: in .dockerignore we exclude vendor/bundle and other things like node_modules and public/dist so the
# host machine values in there (maybe from a manual build)
# don't get copied in. Only the fresh built ones are inside the container.
USER root
COPY --chown=dockeruser:dockeruser . /app
#COPY .babelrc .bowerrc .fontcustom-manifest.json .i18nignore .jshintrc .npmrc .selinimumignore \
# package.json \
# npm-shrinkwrap.json \
# Rakefile \
# gulpfile.babel.js /app/
#COPY app/stylesheets /app/app/stylesheets
#COPY app/coffeescripts /app/app/coffeescripts
#COPY app/jsx /app/app/jsx
#COPY app/assets /app/app/assets
#COPY app/views/jst /app/app/views/jst
#COPY bin /app/bin
#COPY config/application.rb \
# config/boot.rb \
# config/build.js.erb \
# config/brandable_css.yml \
# config/browsers.yml \
# config/routes.rb \
# config/styleguide.yml /app/config/
#COPY config/initializers/webpack.rb \
# config/initializers/plugin_symlinks.rb \
# config/initializers/client_app_symlinks.rb \
# config/initializers/json.rb /app/config/initializers/
#COPY config/locales /app/config/locales
#COPY client_apps/canvas_quizzes /app/client_apps/canvas_quizzes
#COPY doc /app/doc
#COPY lib/tasks /app/lib/tasks
#COPY lib/canvas.rb \
# lib/canvas_yaml.rb \
# lib/logging_filter.rb \
# lib/canvas_logger.rb \
# lib/ember_bundle.rb \
# lib/brandable_css.rb \
# lib/api_routes.rb \
# lib/api_route_set.rb /app/lib/
#COPY lib/canvas/draft_state_validations.rb \
# lib/canvas/coffee_script.rb \
# lib/canvas/require_js.rb /app/lib/canvas/
#COPY lib/canvas/require_js/plugin_extension.rb \
# lib/canvas/require_js/client_app_extension.rb /app/lib/canvas/require_js/
#COPY lib/lti/re_reg_constraint.rb /app/lib/lti/
#COPY public /app/public
#COPY script /app/script
#COPY spec/javascripts /app/spec/javascripts
#COPY spec/coffeescripts /app/spec/coffeescripts
# Setup the Delayed Jobs so that it can be run as a service.
# Note that in Heroku, we don't do this. See heroku.yml.
RUN ln -s /app/script/canvas_init /etc/init.d/canvas_init \
&& update-rc.d canvas_init defaults
# Heroku doesn't run with root privilege, so setup the app as a non-root user
# See: https://devcenter.heroku.com/articles/container-registry-and-runtime#testing-an-image-locally
USER dockeruser
# We have to mkdir app/views/info b/c bin/dress_code tries to write styleguide.html.erb to this dir.
#
# We have to explicitly run `npm install` for canvas_i18nliner b/c it uses an older version
# of the i18nliner gem ([email protected]) than the rest of the app ([email protected]). Ideally,
# we would upgrade canvas_i18nliner as shown in these commits:
# - https://github.com/instructure/canvas-lms/commit/f02b43f5744c32fdf0864c14d6c21c8a77311596#diff-8e298f3a69736b529005b3495d96c273
# - https://github.com/instructure/canvas-lms/commit/e4d7de76e391f9af6222f5374a4fef1a99c25f5a#diff-8e298f3a69736b529005b3495d96c273
# but we'd have to upgrade node 0.12.14 to node 6.x.x
# Note: we could look into downgrading the main app to this same version of 18nliner. I'm not sure anything else other than
# canvas_i18nliner uses it...
#
# Here is the error you get if we try and use [email protected]
#/app/gems/canvas_i18nliner/js/main.js:2
#var Commands = I18nliner.Commands;
# ^
#TypeError: Cannot read property 'Commands' of undefined
# at Object.<anonymous> (/app/gems/canvas_i18nliner/js/main.js:2:25)
# ... ommitted ...
# at Object.<anonymous> (/app/gems/canvas_i18nliner/bin/i18nliner:3:1)
#Error extracting JS translations; confirm that `./gems/canvas_i18nliner/bin/i18nliner generate_js` works
#
# Passing the JS_BUILD_NO_UGLIFY variable into the build context will cause compile_assets to skip
# uglify'ing the JS which takes several minutes.
ARG JS_BUILD_NO_UGLIFY
RUN mkdir -p /app/app/views/info/ \
&& mkdir -p /app/tmp/pids/ \
&& cd /app/gems/canvas_i18nliner/ && npm install \
&& bundle exec rake canvas:compile_assets --trace
# Let either heroku.yml (for prod) or docker-compose.yml (for dev) specify the start command)
# Decouple the container itself from how we'll start it in each env.
CMD ["bash"]
#CMD ["rails", "s", "-p", "3001", "-b", "0.0.0.0"]
#CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]