diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..9dc1d690 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM opensuse:42.1 +RUN zypper -q -n --non-interactive install update-alternatives ruby-devel make gcc gcc-c++ libxml2 libxml2-devel libxslt-devel nodejs screen libmysqld-devel sqlite3-devel imagemagick + +ENV APP_HOME /osem +RUN mkdir $APP_HOME +WORKDIR $APP_HOME + +ADD Gemfile* $APP_HOME/ +COPY Gemfile Gemfile +COPY Gemfile.lock Gemfile.lock + +RUN echo 'install: --no-format-executable' >> /etc/gemrc +RUN gem install bundler +RUN gem install nokogiri -v '1.6.7.2' -- --use-system-libraries +RUN bundle install +RUN gem install tzinfo +RUN gem install tzinfo-data + +ADD . $APP_HOME +ADD config/database.yml.example config/database.yml +ADD config/config.yml.example config/config.yml +ADD config/secrets.yml.example config/secrets.yml +RUN touch db/production.sqlite3 +RUN touch db/development.sqlite3 +RUN touch db/test.sqlite3 + +EXPOSE 8080 +CMD rake db:create && rake db:migrate && rails:update:bin && rails s -p 8080 -b '0.0.0.0' diff --git a/Gemfile b/Gemfile index e7593f2f..0d9012c6 100644 --- a/Gemfile +++ b/Gemfile @@ -56,6 +56,9 @@ gem 'sass-rails', '>= 4.0.2' # as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' +# for correct time zones at some environments +gem 'tzinfo-data' + # as the front-end framework gem 'bootstrap-sass', '~> 3.3.4.1' gem 'autoprefixer-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 5af62e75..fc3d42c4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -464,6 +464,8 @@ GEM coffee-rails tzinfo (1.2.2) thread_safe (~> 0.1) + tzinfo-data (1.2016.3) + tzinfo (>= 1.0.0) uglifier (2.5.0) execjs (>= 0.3.0) json (>= 1.8.0) @@ -574,8 +576,12 @@ DEPENDENCIES timecop transitions turbolinks + tzinfo-data uglifier (>= 1.3.0) unobtrusive_flash (>= 3) web-console (~> 2.0) webmock whenever + +BUNDLED WITH + 1.11.2 diff --git a/INSTALL.md b/INSTALL.md index e9e031cd..331b0087 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -52,6 +52,57 @@ You can access the app [localhost:3000](http://localhost:3000). Whatever you cha ``` vagrant exec rake db:migrate ``` +### Run OSEM in Docker containter using Docker Compose tool + +1. Install [Docker](https://docs.docker.com/linux/step_one/) and [Docker-Compose](https://docs.docker.com/compose/install/). It is better run on Linux, but you can run it on MacOS or Windows with Docker-Machine. Don't forget to add your user to ```docker``` group. + +2. Clone this code repository: + + ``` + git clone https://github.com/openSUSE/osem.git + ``` + +3. Change current directory to OSEM project: + + ``` + cd osem/ + ``` + +4. Start building your OSEM rails app container: + + ``` + docker-compose build + ``` + +5. Run your OSEM rails app container for the first time: + + ``` + docker-compose up + ``` + +6. In another terminal change directory to your OSEM rails app and make a create db and make migrations: + + ``` + docker-compose run web rake db:create db:migrate + ``` + +7. Press ```Ctrl-C``` in previous terminal to stop running container and start container again: + + ``` + docker-compose start + ``` + +8. Check that new OSEM rails app container is running: + + ``` + docker-compose ps + ``` + +9. Now you can look at browser by passing url ```http:\\localhost:8080\```. Stop container with + + ``` + docker-compose stop + ``` **Note**: We use [letter_opener](https://github.com/ryanb/letter_opener) in development environment. However, letter_opener uses launchy to present the emails in your browser which doesn't work in combination with Vagrant. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..2b31838c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +web: + build: . + command: bash -c "bundle exec rails s -p 8080 -b '0.0.0.0'" + volumes: + - ./:/osem + ports: + - "8080:8080"