Skip to content

Commit 97074a6

Browse files
authored
Merge pull request #97 from OpenDSA/docker-lti
Docker lti
2 parents 056610d + 0388062 commit 97074a6

File tree

13 files changed

+109
-192
lines changed

13 files changed

+109
-192
lines changed

Dockerfile

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ruby:2.7.1
1+
FROM docker.io/bitnami/ruby:2.7
22

33
MAINTAINER Jihane Najdi <jnajdi@vt.edu>
44

@@ -10,45 +10,31 @@ ARG LTI_BRANCH='master'
1010
ENV TZ=America/New_York
1111
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
1212

13-
# Setting the default opendsa Makefile variable ODSA_ENV to 'PROD' and PYTHON to 'python'
14-
ENV PYTHON='python'
13+
# Setting the default opendsa Makefile variable ODSA_ENV to 'PROD'
1514
ENV ODSA_ENV='PROD'
1615

17-
ENV GEM_HOME /usr/local/bundle
18-
ENV PATH $GEM_HOME/bin:$PATH
1916
ENV BUNDLER_VERSION 2.1.4
2017

2118
ENV RAILS_ENV=$RAILS_ENV
2219
ENV ODSA_BRANCH=$ODSA_BRANCH
2320
ENV LTI_BRANCH=$LTI_BRANCH
2421

22+
# shared-mime-info temporary due to mimemagic issues
2523
RUN apt-get update -qq \
26-
&& apt-get install -y apt-utils build-essential libpq-dev lsof vim cron curl \
27-
&& apt-get install -y nodejs npm python3-pip git-core zlib1g-dev libssl-dev libreadline-dev libyaml-dev libevent-dev libsqlite3-dev libxml2-dev libxml2 libxslt1-dev libffi-dev libxslt-dev sqlite3 dkms python-dev python-feedvalidator python-sphinx \
28-
&& apt-get install -y default-jre \
29-
&& apt-get upgrade -y \
30-
&& pip3 install --upgrade pip \
31-
&& npm install uglify-js -g \
32-
&& npm install clean-css-cli -g \
33-
&& rm -f /usr/bin/python && ln -s /usr/bin/python3 /usr/bin/python \
34-
&& rm -f /usr/bin/pip && ln -s /usr/bin/pip3 /usr/bin/pip \
35-
&& rm -rf /var/apt/lists/*
36-
37-
RUN gem install bundler -v $BUNDLER_VERSION \
38-
&& bundle config --global path "$GEM_HOME" \
39-
&& bundle config --global bin "$GEM_HOME/bin" \
40-
&& bundle config git.allow_insecure true
24+
&& apt-get install -y apt-utils build-essential cron \
25+
&& apt-get install -y libyaml-dev libevent-dev libxml2 libffi-dev libxslt-dev libmariadb-dev-compat libmariadb-dev \
26+
&& apt-get install -y shared-mime-info \
27+
&& rm -rf /var/apt/lists/*
28+
29+
RUN gem install bundler -v $BUNDLER_VERSION
4130

4231
RUN mkdir /opendsa-lti && echo "cd /opendsa-lti" >> /root/.bashrc
4332
WORKDIR /opendsa-lti
4433

45-
COPY requirements.txt requirements.txt
46-
47-
RUN pip3 install -r requirements.txt
48-
4934
COPY Gemfile Gemfile
5035
COPY Gemfile.lock Gemfile.lock
5136

37+
RUN bundle config build.nokogiri --use-system-libraries
5238
RUN bundle install
5339

5440
EXPOSE 80

Gemfile

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ gem 'progress_job'
5656

5757
# For JSON support
5858
gem 'rabl'
59-
gem 'oj'
60-
gem 'oj_mimic_json'
59+
# gem 'oj'
60+
# gem 'oj_mimic_json'
6161

6262
group :assets do
6363
gem 'sass-rails'
@@ -68,25 +68,22 @@ end
6868
gem 'mysql2'
6969

7070
group :development, :test do
71-
gem 'sqlite3'
7271
gem 'rspec-rails', '>=3.4.2'
7372
gem 'annotate'
7473
gem 'rails-erd', github: 'voormedia/rails-erd'
7574
gem 'pry'
76-
gem 'thin'
7775
gem 'request-log-analyzer'
78-
# gem 'byebug'
79-
gem 'debase'
80-
gem 'ruby-debug-ide'
76+
# gem 'debase'
77+
# gem 'ruby-debug-ide'
8178
end
8279

8380
gem 'faker'
8481
gem 'factory_bot_rails'
8582
gem 'log_file'
8683

87-
group :test do
88-
gem 'capybara'
89-
end
84+
# group :test do
85+
# gem 'capybara'
86+
# end
9087

9188
group :production, :staging do
9289

@@ -105,7 +102,6 @@ gem 'omniauth-google-oauth2'
105102
gem 'omniauth-cas'
106103
gem 'cancancan'
107104
gem 'activeadmin', '~> 2.7'
108-
# update this gem
109105
gem 'exception_handler', '~> 0.3.45'
110106

111107
gem 'nokogiri', '1.10.9', require: false
@@ -131,16 +127,6 @@ gem 'cocoon'
131127
# For handling converting to booleans
132128
gem 'wannabe_bool'
133129

134-
# Gems for deployment.
135-
gem 'capistrano3-delayed-job', '~> 1.0'
136-
gem 'capistrano-bower'
137-
gem 'capistrano'
138-
gem 'capistrano-figaro-yml', '~> 1.0.2'
139-
gem 'capistrano-bundler'
140-
gem 'capistrano-rails'
141-
gem 'capistrano-rbenv', github: "capistrano/rbenv"
142-
gem 'capistrano-passenger'
143-
gem 'capistrano-rake', require: false
144130
gem 'net-ssh', :github => 'net-ssh/net-ssh'
145131

146132
#for multi-color progress bar
@@ -164,9 +150,11 @@ gem "mustache", "~> 1.0"
164150
gem "whenever", :require => false
165151

166152
#for setting SameSite=None to cookies generated
167-
#gem 'user_agent_parser', '< 2.5.2' # 2.6.0 or higher requires ruby>=2.4
168153
gem 'user_agent_parser' # 2.6.0 or higher requires ruby>=2.4
169154

170155
gem 'rails_same_site_cookie'
171156
gem 'rack-cors'
172-
gem 'simple_oauth', '0.3.1'
157+
gem 'simple_oauth', '0.3.1'
158+
gem 'therubyracer'
159+
gem 'ffi' # speed up sassc install
160+
gem 'sassc', '2.1.0'

Gemfile.lock

Lines changed: 9 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
GIT
2-
remote: https://github.com/capistrano/rbenv.git
3-
revision: 1fdb93a6dd4a4ab3fb786c995055cf6949daf7a4
4-
specs:
5-
capistrano-rbenv (2.2.0)
6-
capistrano (~> 3.1)
7-
sshkit (~> 1.3)
8-
91
GIT
102
remote: https://github.com/net-ssh/net-ssh.git
113
revision: d731c11d8bd0feb9d252416611474e1694245272
@@ -108,8 +100,6 @@ GEM
108100
activerecord (>= 4.2)
109101
addressable (2.7.0)
110102
public_suffix (>= 2.0.2, < 5.0)
111-
airbrussh (1.4.0)
112-
sshkit (>= 1.6.1, != 1.7.0)
113103
annotate (3.1.1)
114104
activerecord (>= 3.2, < 7.0)
115105
rake (>= 10.4, < 14.0)
@@ -136,36 +126,6 @@ GEM
136126
browser (4.2.0)
137127
builder (3.2.4)
138128
cancancan (3.1.0)
139-
capistrano (3.14.1)
140-
airbrussh (>= 1.0.0)
141-
i18n
142-
rake (>= 10.0.0)
143-
sshkit (>= 1.9.0)
144-
capistrano-bower (1.1.0)
145-
capistrano (~> 3.0)
146-
capistrano-bundler (2.0.1)
147-
capistrano (~> 3.1)
148-
capistrano-figaro-yml (1.0.5)
149-
capistrano (~> 3.1)
150-
sshkit (~> 1.2, >= 1.2.0)
151-
capistrano-passenger (0.2.0)
152-
capistrano (~> 3.0)
153-
capistrano-rails (1.6.1)
154-
capistrano (~> 3.1)
155-
capistrano-bundler (>= 1.1, < 3)
156-
capistrano-rake (0.2.0)
157-
capistrano (>= 3.0)
158-
capistrano3-delayed-job (1.7.6)
159-
capistrano (~> 3.0, >= 3.0.0)
160-
daemons (~> 1.3)
161-
capybara (3.33.0)
162-
addressable
163-
mini_mime (>= 0.1.3)
164-
nokogiri (~> 1.8)
165-
rack (>= 1.6.0)
166-
rack-test (>= 0.6.3)
167-
regexp_parser (~> 1.5)
168-
xpath (~> 3.2)
169129
celluloid (0.17.4)
170130
celluloid-essentials
171131
celluloid-extras
@@ -206,9 +166,6 @@ GEM
206166
daemons (1.3.1)
207167
data-confirm-modal (1.6.3)
208168
railties (>= 3.0)
209-
debase (0.2.4.1)
210-
debase-ruby_core_source (>= 0.10.2)
211-
debase-ruby_core_source (0.10.9)
212169
declarative (0.0.20)
213170
declarative-option (0.1.0)
214171
delayed_job (4.1.8)
@@ -228,7 +185,6 @@ GEM
228185
equalizer (0.0.11)
229186
erubi (1.10.0)
230187
erubis (2.7.0)
231-
eventmachine (1.2.7)
232188
exception_handler (0.3.45)
233189
execjs (2.7.0)
234190
factory_bot (6.1.0)
@@ -317,6 +273,7 @@ GEM
317273
activerecord
318274
kaminari-core (= 1.2.1)
319275
kaminari-core (1.2.1)
276+
libv8 (3.16.14.19)
320277
link_header (0.0.8)
321278
log_file (0.0.3)
322279
loofah (2.5.0)
@@ -340,8 +297,6 @@ GEM
340297
multipart-post (2.1.1)
341298
mustache (1.1.1)
342299
mysql2 (0.5.3)
343-
net-scp (3.0.0)
344-
net-ssh (>= 2.6.5, < 7.0.0)
345300
nio4r (2.5.5)
346301
nokogiri (1.10.9)
347302
mini_portile2 (~> 2.4.0)
@@ -352,8 +307,6 @@ GEM
352307
multi_json (~> 1.3)
353308
multi_xml (~> 0.5)
354309
rack (>= 1.2, < 3)
355-
oj (3.10.8)
356-
oj_mimic_json (1.0.1)
357310
omniauth (1.9.1)
358311
hashie (>= 3.4.6)
359312
rack (>= 1.6.2, < 3)
@@ -431,7 +384,7 @@ GEM
431384
polyamorous (= 2.3.2)
432385
rdoc (6.2.1)
433386
redcarpet (3.5.0)
434-
regexp_parser (1.7.1)
387+
ref (2.0.0)
435388
remotipart (1.4.4)
436389
representable (3.0.4)
437390
declarative (< 0.1.0)
@@ -459,15 +412,13 @@ GEM
459412
rspec-mocks (~> 3.9)
460413
rspec-support (~> 3.9)
461414
rspec-support (3.9.3)
462-
ruby-debug-ide (0.7.2)
463-
rake (>= 0.8.1)
464415
ruby-graphviz (1.2.5)
465416
rexml
466417
ruby_parser (3.14.2)
467418
sexp_processor (~> 4.9)
468419
sass-rails (6.0.0)
469420
sassc-rails (~> 2.1, >= 2.1.1)
470-
sassc (2.4.0)
421+
sassc (2.1.0)
471422
ffi (~> 1.9)
472423
sassc-rails (2.1.2)
473424
railties (>= 4.0.0)
@@ -486,19 +437,14 @@ GEM
486437
actionpack (>= 4.0)
487438
activesupport (>= 4.0)
488439
sprockets (>= 3.0.0)
489-
sqlite3 (1.4.2)
490-
sshkit (1.21.0)
491-
net-scp (>= 1.1.2)
492-
net-ssh (>= 2.8.0)
493440
sucker_punch (1.6.0)
494441
celluloid (~> 0.17.2)
495442
temple (0.8.2)
496443
test-unit (3.0.9)
497444
power_assert
498-
thin (1.7.2)
499-
daemons (~> 1.0, >= 1.0.9)
500-
eventmachine (~> 1.0, >= 1.0.4)
501-
rack (>= 1, < 3)
445+
therubyracer (0.12.3)
446+
libv8 (~> 3.16.14.15)
447+
ref
502448
thor (1.1.0)
503449
thread_safe (0.3.6)
504450
tilt (2.0.10)
@@ -523,8 +469,6 @@ GEM
523469
websocket-extensions (0.1.5)
524470
whenever (1.0.0)
525471
chronic (>= 0.6.3)
526-
xpath (3.2.0)
527-
nokogiri (~> 1.8)
528472
zeitwerk (2.4.2)
529473

530474
PLATFORMS
@@ -547,16 +491,6 @@ DEPENDENCIES
547491
bootstrap3-datetimepicker-rails (~> 4.14.30)
548492
browser
549493
cancancan
550-
capistrano
551-
capistrano-bower
552-
capistrano-bundler
553-
capistrano-figaro-yml (~> 1.0.2)
554-
capistrano-passenger
555-
capistrano-rails
556-
capistrano-rake
557-
capistrano-rbenv!
558-
capistrano3-delayed-job (~> 1.0)
559-
capybara
560494
clipboard-rails
561495
cocoon
562496
coffee-rails (~> 5.0)
@@ -565,12 +499,12 @@ DEPENDENCIES
565499
csv_shaper
566500
daemons
567501
data-confirm-modal
568-
debase
569502
delayed_job_active_record
570503
devise (~> 4.7.1)
571504
exception_handler (~> 0.3.45)
572505
factory_bot_rails
573506
faker
507+
ffi
574508
figaro
575509
font-awesome-rails
576510
formtastic (~> 3.1)
@@ -598,8 +532,6 @@ DEPENDENCIES
598532
nokogiri (= 1.10.9)
599533
oauth (= 0.5.4)
600534
oauth2 (= 1.4.4)
601-
oj
602-
oj_mimic_json
603535
omniauth
604536
omniauth-cas
605537
omniauth-facebook
@@ -623,15 +555,14 @@ DEPENDENCIES
623555
request-log-analyzer
624556
responders
625557
rspec-rails (>= 3.4.2)
626-
ruby-debug-ide
627558
sass-rails
559+
sassc (= 2.1.0)
628560
sdoc
629561
simple_oauth (= 0.3.1)
630562
sprockets (= 3.7.2)
631-
sqlite3
632563
sucker_punch (~> 1.0)
633564
test-unit (~> 3.0.9)
634-
thin
565+
therubyracer
635566
truncate_html
636567
tzinfo
637568
uglifier (~> 4.2)

app/admin/inst_book.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,17 @@ def upload_books
6565
end
6666

6767
def upload_create
68-
script_path = "public/OpenDSA/tools/simple2full.py"
6968
input_file = params[:form][:file].path
7069
output_file = sanitize_filename('temp_' + current_user.id.to_s + '_' + Time.now.getlocal.to_s) + '_full.json'
7170
output_file_path = "public/OpenDSA/config/temp/#{output_file}"
72-
require 'open3'
73-
command = ". $(echo $python_venv_path) && python3 #{script_path} #{input_file} #{output_file_path}"
74-
stdout, stderr, status = Open3.capture3(command)
75-
76-
unless status.success?
77-
Rails.logger.info(stderr)
71+
output_path = output_file_path[15..-1] # without the public/OpenDSA
72+
input_path = input_file[15..-1] # without the public/OpenDSA
73+
require 'net/http'
74+
uri = URI(ENV["simple_api_link"])
75+
res = Net::HTTP.post_form(uri, 'input_path' => input_path, 'output_path' => output_path, 'rake' => false)
76+
77+
unless res.kind_of? Net::HTTPSuccess
78+
Rails.logger.info(res['stderr_compressed'])
7879
end
7980
hash = JSON.load(File.read(output_file_path))
8081
if params.has_key?(:inst_book)

app/controllers/exception_handler/exception_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def show
2727

2828
#Info
2929
def status
30-
@exception = env['action_dispatch.exception']
31-
@status = ActionDispatch::ExceptionWrapper.new(env, @exception).status_code
30+
@exception = request.env['action_dispatch.exception']
31+
@status = ActionDispatch::ExceptionWrapper.new(request.env, @exception).status_code
3232
@response = ActionDispatch::ExceptionWrapper.rescue_responses[@exception.class.name]
3333
end
3434

0 commit comments

Comments
 (0)