Skip to content
Snippets Groups Projects
Commit eae8e36d authored by Iain Bryson's avatar Iain Bryson
Browse files

Update to use the Centos7/RVM Ruby 2.4.3 base image.

parent 5a5484ac
No related branches found
No related tags found
No related merge requests found
FROM fedora:24
FROM dtucompute/enote-base-centos:v2018
ARG DEPENDENCY_HASH=1
EXPOSE 3000
RUN dnf -y update
RUN dnf -y install redhat-rpm-config ruby rubygem-rails ruby-devel make gcc zlib-devel tar patch gcc-c++ libxml2-devel
# required for the asset pipeline (uglifier, e.g.)
RUN dnf -y install npm nodejs
# Enable installing gems from git repos
RUN dnf -y install git
# required by letsencrypt. if it's not present, the SSL connection to the let's encrypt server will fail
RUN dnf -y install openssl
# to handle running as a normal user
RUN dnf -y install sudo
# run as a non-root user (Issue#57)
RUN adduser dtuuser && \
echo "dtuuser ALL=(root) NOPASSWD:ALL" >> /etc/sudoers
ENV APP_ROOT /app
WORKDIR $APP_ROOT/
USER dtuuser
RUN sudo mkdir -p /dtu-course
RUN sudo chown -R dtuuser:dtuuser /dtu-course
WORKDIR /dtu-course
#
# COURSE
#
RUN sudo gem install foreman
RUN sudo gem install rspec
RUN sudo gem install thin
LABEL "github"="https://github.com/dtu-compute/dtu-course-website"
LABEL version="2018"
LABEL description="This Dockerfile builds the container \
to house the DTU course website."
# Install the necessary gems
COPY Gemfile /dtu-course/Gemfile
COPY Gemfile $APP_ROOT/Gemfile
#COPY dtu-core/ /dtu-core
RUN bundle config github.https true
RUN bundle install
RUN /bin/bash -l -c "env"
RUN /bin/bash -l -c "bundle config github.https true"
RUN /bin/bash -l -c "bundle install"
# install client-side components
COPY package.json /dtu-course/package.json
COPY package.json $APP_ROOT/package.json
RUN npm install
# install bower
COPY .bowerrc /dtu-course/
COPY bower.json /dtu-course/
COPY .bowerrc $APP_ROOT/
COPY bower.json $APP_ROOT/
RUN sudo npm install -g bower
RUN bower install --allow-root
# Add PDF.JS
COPY pdfjs.head.txt /dtu-course/
COPY pdfjs.head.txt $APP_ROOT/
RUN git clone https://github.com/dtu-compute/pdf.js pdfjs
#Local version useful for development. Just clone into this directory
#COPY pdfjs pdfjs
#RUN sudo chown -R dtuuser:dtuuser pdfjs
RUN pushd pdfjs && \
RUN cd pdfjs && \
npm install && \
npm install gulp && \
sudo npm install -g gulp && \
gulp generic
gulp generic && \
cd $APP_ROOT
# Copy application code to container
COPY . /dtu-course
RUN sudo chown -R dtuuser:dtuuser /dtu-course
RUN rm -rf /dtu-course/log
RUN mkdir /dtu-course/tmp
COPY . $APP_ROOT
RUN sudo chown -R dtuuser:dtuuser $APP_ROOT
RUN rm -rf $APP_ROOT/log
RUN mkdir -p $APP_ROOT/tmp
RUN mkdir -p $APP_ROOT/log
# generate cookie key
RUN PRECOMPILE=1 bundle exec rake secret > ~/secret-key-base.txt
RUN /bin/bash -l -c "PRECOMPILE=1 bundle exec rake secret > ~/secret-key-base.txt"
RUN mkdir -p /dtu-course/log/
RUN RAILS_ENV=production PRECOMPILE=1 bundle exec rake assets:clobber
RUN /bin/bash -l -c "RAILS_ENV=production PRECOMPILE=1 bundle exec rake assets:clobber"
# Copy bower scripts to public
# This bypasses the rails pipeline to ensure that the assets are available
# as-is for askbot (in the case of MathJax) and as a fallback if we decide to
# implement fallback.js if/when the CDNs fail
RUN ls -als
RUN cp -R vendor/assets/components public/vendor/
RUN mkdir -p public/assets/pdfjs-viewer
......@@ -86,8 +70,10 @@ RUN cp -R pdfjs/build/generic/web/* public/assets/pdfjs-viewer/
RUN cp -R pdfjs/build/generic/web public/assets/pdfjs-viewer/
RUN cp -R pdfjs/build/generic/build public/assets/pdfjs-viewer/
RUN RAILS_ENV=production PRECOMPILE=1 bundle exec rake assets:precompile
RUN /bin/bash -l -c "RAILS_ENV=production PRECOMPILE=1 bundle exec rake assets:precompile"
RUN /bin/bash -l -c "RAILS_ENV=test bundle install"
RUN COURSE_ENV=00000 RAILS_ENV=test PRECOMPILE=1 bundle exec rspec spec
RUN /bin/bash -l -c "COURSE_ENV=00000 RAILS_ENV=test PRECOMPILE=1 bundle exec rspec spec"
CMD ["/bin/sh", "-c", "./run-server.sh 2>&1 | tee /dtu-course/log/run-server.log"]
CMD ["/bin/bash", "-l", "-c", "./run-server.sh 2>&1 | tee $APP_ROOT/log/run-server.log"]
source 'https://rubygems.org'
ruby "2.4.3"
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 4.2.7'
......@@ -70,7 +71,7 @@ end
group :test do
gem 'fakefs', :require => "fakefs/safe"
gem 'fakeredis', :require => "fakeredis/rspec"
gem 'fakeredis', '~> 0.6.0', :require => "fakeredis/rspec"
gem 'database_cleaner'
gem 'factory_girl_rails'
end
......@@ -80,7 +81,7 @@ gem 'rubycas-client', '~> 2.3.8', :git => 'https://github.com/rubycas/rubycas-cl
gem 'nokogiri', '~> 1.6'
# redis
gem 'redis'
gem 'redis', '~> 3.2'
gem 'redis-namespace'
gem 'redis-rails'
gem 'redis-rack-cache'
......
......@@ -7,6 +7,15 @@ timestamp()
echo RUNNING WEBSITE SERVER AS `whoami`
source ~/.bashrc
ruby -v | grep "2\.4\.3"
rc=$?; if [[ $rc != 0 ]]; then
echo "Wrong version of Ruby installed!"
ruby -v
exit $rc;
fi
RAILS_ENV=$RAILS_ENV
: ${RAILS_ENV:="development"}
export RAILS_ENV
......@@ -19,8 +28,8 @@ export SECRET_KEY_BASE=$SECRET_KEY_BASE
echo REMOVING TMP
rm -rf tmp/*
rm -rf /dtu-course/log/*
mkdir -p /dtu-course/log/
rm -rf $APP_ROOT/log/*
mkdir -p $APP_ROOT/log/
echo LINKING SHARED ASSETS AND LOGFILES
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment