Skip to content

Commit

Permalink
Merge pull request #97 from OpenDSA/docker-lti
Browse files Browse the repository at this point in the history
Docker lti
  • Loading branch information
awhicks authored Aug 18, 2021
2 parents 056610d + 0388062 commit 97074a6
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 192 deletions.
34 changes: 10 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:2.7.1
FROM docker.io/bitnami/ruby:2.7

MAINTAINER Jihane Najdi <[email protected]>

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

# Setting the default opendsa Makefile variable ODSA_ENV to 'PROD' and PYTHON to 'python'
ENV PYTHON='python'
# Setting the default opendsa Makefile variable ODSA_ENV to 'PROD'
ENV ODSA_ENV='PROD'

ENV GEM_HOME /usr/local/bundle
ENV PATH $GEM_HOME/bin:$PATH
ENV BUNDLER_VERSION 2.1.4

ENV RAILS_ENV=$RAILS_ENV
ENV ODSA_BRANCH=$ODSA_BRANCH
ENV LTI_BRANCH=$LTI_BRANCH

# shared-mime-info temporary due to mimemagic issues
RUN apt-get update -qq \
&& apt-get install -y apt-utils build-essential libpq-dev lsof vim cron curl \
&& 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 \
&& apt-get install -y default-jre \
&& apt-get upgrade -y \
&& pip3 install --upgrade pip \
&& npm install uglify-js -g \
&& npm install clean-css-cli -g \
&& rm -f /usr/bin/python && ln -s /usr/bin/python3 /usr/bin/python \
&& rm -f /usr/bin/pip && ln -s /usr/bin/pip3 /usr/bin/pip \
&& rm -rf /var/apt/lists/*

RUN gem install bundler -v $BUNDLER_VERSION \
&& bundle config --global path "$GEM_HOME" \
&& bundle config --global bin "$GEM_HOME/bin" \
&& bundle config git.allow_insecure true
&& apt-get install -y apt-utils build-essential cron \
&& apt-get install -y libyaml-dev libevent-dev libxml2 libffi-dev libxslt-dev libmariadb-dev-compat libmariadb-dev \
&& apt-get install -y shared-mime-info \
&& rm -rf /var/apt/lists/*

RUN gem install bundler -v $BUNDLER_VERSION

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

COPY requirements.txt requirements.txt

RUN pip3 install -r requirements.txt

COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock

RUN bundle config build.nokogiri --use-system-libraries
RUN bundle install

EXPOSE 80
34 changes: 11 additions & 23 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ gem 'progress_job'

# For JSON support
gem 'rabl'
gem 'oj'
gem 'oj_mimic_json'
# gem 'oj'
# gem 'oj_mimic_json'

group :assets do
gem 'sass-rails'
Expand All @@ -68,25 +68,22 @@ end
gem 'mysql2'

group :development, :test do
gem 'sqlite3'
gem 'rspec-rails', '>=3.4.2'
gem 'annotate'
gem 'rails-erd', github: 'voormedia/rails-erd'
gem 'pry'
gem 'thin'
gem 'request-log-analyzer'
# gem 'byebug'
gem 'debase'
gem 'ruby-debug-ide'
# gem 'debase'
# gem 'ruby-debug-ide'
end

gem 'faker'
gem 'factory_bot_rails'
gem 'log_file'

group :test do
gem 'capybara'
end
# group :test do
# gem 'capybara'
# end

group :production, :staging do

Expand All @@ -105,7 +102,6 @@ gem 'omniauth-google-oauth2'
gem 'omniauth-cas'
gem 'cancancan'
gem 'activeadmin', '~> 2.7'
# update this gem
gem 'exception_handler', '~> 0.3.45'

gem 'nokogiri', '1.10.9', require: false
Expand All @@ -131,16 +127,6 @@ gem 'cocoon'
# For handling converting to booleans
gem 'wannabe_bool'

# Gems for deployment.
gem 'capistrano3-delayed-job', '~> 1.0'
gem 'capistrano-bower'
gem 'capistrano'
gem 'capistrano-figaro-yml', '~> 1.0.2'
gem 'capistrano-bundler'
gem 'capistrano-rails'
gem 'capistrano-rbenv', github: "capistrano/rbenv"
gem 'capistrano-passenger'
gem 'capistrano-rake', require: false
gem 'net-ssh', :github => 'net-ssh/net-ssh'

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

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

gem 'rails_same_site_cookie'
gem 'rack-cors'
gem 'simple_oauth', '0.3.1'
gem 'simple_oauth', '0.3.1'
gem 'therubyracer'
gem 'ffi' # speed up sassc install
gem 'sassc', '2.1.0'
87 changes: 9 additions & 78 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
GIT
remote: https://github.com/capistrano/rbenv.git
revision: 1fdb93a6dd4a4ab3fb786c995055cf6949daf7a4
specs:
capistrano-rbenv (2.2.0)
capistrano (~> 3.1)
sshkit (~> 1.3)

GIT
remote: https://github.com/net-ssh/net-ssh.git
revision: d731c11d8bd0feb9d252416611474e1694245272
Expand Down Expand Up @@ -108,8 +100,6 @@ GEM
activerecord (>= 4.2)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
airbrussh (1.4.0)
sshkit (>= 1.6.1, != 1.7.0)
annotate (3.1.1)
activerecord (>= 3.2, < 7.0)
rake (>= 10.4, < 14.0)
Expand All @@ -136,36 +126,6 @@ GEM
browser (4.2.0)
builder (3.2.4)
cancancan (3.1.0)
capistrano (3.14.1)
airbrussh (>= 1.0.0)
i18n
rake (>= 10.0.0)
sshkit (>= 1.9.0)
capistrano-bower (1.1.0)
capistrano (~> 3.0)
capistrano-bundler (2.0.1)
capistrano (~> 3.1)
capistrano-figaro-yml (1.0.5)
capistrano (~> 3.1)
sshkit (~> 1.2, >= 1.2.0)
capistrano-passenger (0.2.0)
capistrano (~> 3.0)
capistrano-rails (1.6.1)
capistrano (~> 3.1)
capistrano-bundler (>= 1.1, < 3)
capistrano-rake (0.2.0)
capistrano (>= 3.0)
capistrano3-delayed-job (1.7.6)
capistrano (~> 3.0, >= 3.0.0)
daemons (~> 1.3)
capybara (3.33.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (~> 1.5)
xpath (~> 3.2)
celluloid (0.17.4)
celluloid-essentials
celluloid-extras
Expand Down Expand Up @@ -206,9 +166,6 @@ GEM
daemons (1.3.1)
data-confirm-modal (1.6.3)
railties (>= 3.0)
debase (0.2.4.1)
debase-ruby_core_source (>= 0.10.2)
debase-ruby_core_source (0.10.9)
declarative (0.0.20)
declarative-option (0.1.0)
delayed_job (4.1.8)
Expand All @@ -228,7 +185,6 @@ GEM
equalizer (0.0.11)
erubi (1.10.0)
erubis (2.7.0)
eventmachine (1.2.7)
exception_handler (0.3.45)
execjs (2.7.0)
factory_bot (6.1.0)
Expand Down Expand Up @@ -317,6 +273,7 @@ GEM
activerecord
kaminari-core (= 1.2.1)
kaminari-core (1.2.1)
libv8 (3.16.14.19)
link_header (0.0.8)
log_file (0.0.3)
loofah (2.5.0)
Expand All @@ -340,8 +297,6 @@ GEM
multipart-post (2.1.1)
mustache (1.1.1)
mysql2 (0.5.3)
net-scp (3.0.0)
net-ssh (>= 2.6.5, < 7.0.0)
nio4r (2.5.5)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
Expand All @@ -352,8 +307,6 @@ GEM
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
oj (3.10.8)
oj_mimic_json (1.0.1)
omniauth (1.9.1)
hashie (>= 3.4.6)
rack (>= 1.6.2, < 3)
Expand Down Expand Up @@ -431,7 +384,7 @@ GEM
polyamorous (= 2.3.2)
rdoc (6.2.1)
redcarpet (3.5.0)
regexp_parser (1.7.1)
ref (2.0.0)
remotipart (1.4.4)
representable (3.0.4)
declarative (< 0.1.0)
Expand Down Expand Up @@ -459,15 +412,13 @@ GEM
rspec-mocks (~> 3.9)
rspec-support (~> 3.9)
rspec-support (3.9.3)
ruby-debug-ide (0.7.2)
rake (>= 0.8.1)
ruby-graphviz (1.2.5)
rexml
ruby_parser (3.14.2)
sexp_processor (~> 4.9)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
sassc (2.4.0)
sassc (2.1.0)
ffi (~> 1.9)
sassc-rails (2.1.2)
railties (>= 4.0.0)
Expand All @@ -486,19 +437,14 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.4.2)
sshkit (1.21.0)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
sucker_punch (1.6.0)
celluloid (~> 0.17.2)
temple (0.8.2)
test-unit (3.0.9)
power_assert
thin (1.7.2)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thor (1.1.0)
thread_safe (0.3.6)
tilt (2.0.10)
Expand All @@ -523,8 +469,6 @@ GEM
websocket-extensions (0.1.5)
whenever (1.0.0)
chronic (>= 0.6.3)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.4.2)

PLATFORMS
Expand All @@ -547,16 +491,6 @@ DEPENDENCIES
bootstrap3-datetimepicker-rails (~> 4.14.30)
browser
cancancan
capistrano
capistrano-bower
capistrano-bundler
capistrano-figaro-yml (~> 1.0.2)
capistrano-passenger
capistrano-rails
capistrano-rake
capistrano-rbenv!
capistrano3-delayed-job (~> 1.0)
capybara
clipboard-rails
cocoon
coffee-rails (~> 5.0)
Expand All @@ -565,12 +499,12 @@ DEPENDENCIES
csv_shaper
daemons
data-confirm-modal
debase
delayed_job_active_record
devise (~> 4.7.1)
exception_handler (~> 0.3.45)
factory_bot_rails
faker
ffi
figaro
font-awesome-rails
formtastic (~> 3.1)
Expand Down Expand Up @@ -598,8 +532,6 @@ DEPENDENCIES
nokogiri (= 1.10.9)
oauth (= 0.5.4)
oauth2 (= 1.4.4)
oj
oj_mimic_json
omniauth
omniauth-cas
omniauth-facebook
Expand All @@ -623,15 +555,14 @@ DEPENDENCIES
request-log-analyzer
responders
rspec-rails (>= 3.4.2)
ruby-debug-ide
sass-rails
sassc (= 2.1.0)
sdoc
simple_oauth (= 0.3.1)
sprockets (= 3.7.2)
sqlite3
sucker_punch (~> 1.0)
test-unit (~> 3.0.9)
thin
therubyracer
truncate_html
tzinfo
uglifier (~> 4.2)
Expand Down
15 changes: 8 additions & 7 deletions app/admin/inst_book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,17 @@ def upload_books
end

def upload_create
script_path = "public/OpenDSA/tools/simple2full.py"
input_file = params[:form][:file].path
output_file = sanitize_filename('temp_' + current_user.id.to_s + '_' + Time.now.getlocal.to_s) + '_full.json'
output_file_path = "public/OpenDSA/config/temp/#{output_file}"
require 'open3'
command = ". $(echo $python_venv_path) && python3 #{script_path} #{input_file} #{output_file_path}"
stdout, stderr, status = Open3.capture3(command)

unless status.success?
Rails.logger.info(stderr)
output_path = output_file_path[15..-1] # without the public/OpenDSA
input_path = input_file[15..-1] # without the public/OpenDSA
require 'net/http'
uri = URI(ENV["simple_api_link"])
res = Net::HTTP.post_form(uri, 'input_path' => input_path, 'output_path' => output_path, 'rake' => false)

unless res.kind_of? Net::HTTPSuccess
Rails.logger.info(res['stderr_compressed'])
end
hash = JSON.load(File.read(output_file_path))
if params.has_key?(:inst_book)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/exception_handler/exception_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def show

#Info
def status
@exception = env['action_dispatch.exception']
@status = ActionDispatch::ExceptionWrapper.new(env, @exception).status_code
@exception = request.env['action_dispatch.exception']
@status = ActionDispatch::ExceptionWrapper.new(request.env, @exception).status_code
@response = ActionDispatch::ExceptionWrapper.rescue_responses[@exception.class.name]
end

Expand Down
Loading

0 comments on commit 97074a6

Please sign in to comment.