Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSEM Installation using Docker doesn't work #2511

Open
1 of 2 tasks
medwinz opened this issue May 2, 2019 · 4 comments
Open
1 of 2 tasks

OSEM Installation using Docker doesn't work #2511

medwinz opened this issue May 2, 2019 · 4 comments
Labels
bug 🐛 Something is wrong and needs to be fixed

Comments

@medwinz
Copy link

medwinz commented May 2, 2019

I'm submitting a ..

  • Bug Report
  • Feature Request

Current behavior:

When following INSTALL.md to install osem using docker in openSUSE Leap 15.0, it doesn't work as expected. When I run

docker-compose -f docker-compose.yml.production-example build

it produce some errors. The errors are:

ost-install message from rails-assets-markdown:
This component doesn't define main assets in bower.json.
Please open new pull request in component's repository:
https://github.com/evilstreak/markdown-js
Removing intermediate container b64c91e84b75
 ---> 457949717fa5
Step 6/8 : RUN export RAILS_ENV=production; bundle exec rake assets:clobber assets:precompile
 ---> Running in d17ce16eb04a
rake aborted!
LoadError: cannot load such file -- rubocop/rake_task
/osem/lib/tasks/rubocop.rake:3:in `<top (required)>'
/osem/Rakefile:9:in `<top (required)>'
(See full trace by running task with --trace)
ERROR: Service 'production_web' failed to build: The command '/bin/sh -c export RAILS_ENV=production; bundle exec rake assets:clobber assets:precompile' returned a non-zero code: 1

Expected correct behavior:

Images are build.

Steps to reproduce:

In openSUSE Leap 15.0 follow the step in INSTALL.md and run

docker-compose -f docker-compose.yml.production-example build

Other information:

I can install it by adding tmp directory in osem directory and give it sticky bit.

cd osem
mkdir tmp
chmod 777 tmp/
chmod o+t tmp/

Then running

docker-compose up -d

The container is up and running and I can access it through browser

Screenshot_20190502_190524

Without adding tmp directory with sticky bit in osem directory there will be a problem with the permission when trying to acces it using browser. Below is the example
Screenshot_20190426_183850

@Ana06 Ana06 added the bug 🐛 Something is wrong and needs to be fixed label May 2, 2019
@OndraX
Copy link

OndraX commented Sep 28, 2019

I'm having the same issue, though with the current version of the Dockerfile.production and the tmp file commands in osem directory don't seem to fix it.

Step 5/8 : RUN export NOKOGIRI_USE_SYSTEM_LIBRARIES=1; bundle install --system --jobs=3 --retry=3 --without test development
 ---> Running in 5b75dbe14359
Following files may not be writable, so sudo is needed:
  /usr/bin
  /usr/lib64/ruby/gems/2.5.0
  /usr/lib64/ruby/gems/2.5.0/build_info
  /usr/lib64/ruby/gems/2.5.0/cache
  /usr/lib64/ruby/gems/2.5.0/doc
  /usr/lib64/ruby/gems/2.5.0/extensions
  /usr/lib64/ruby/gems/2.5.0/gems
  /usr/lib64/ruby/gems/2.5.0/specifications
Your Ruby version is 2.5.5, but your Gemfile specified 2.5.0
ERROR: Service 'production_web' failed to build: The command '/bin/sh -c export NOKOGIRI_USE_SYSTEM_LIBRARIES=1; bundle install --jobs=3 --retry=3 --without test development' returned a non-zero code: 18
make: *** [Makefile:3: build] Error 1

note that neither the "ruby version" or the "files may not be writable" messages seem to be the cause of the problem, as either setting an OSEM_RUBY_VERSION in .env.production or running bundle as sudo ... --system makes the respective warnings disappear, but the error stays the same.
I've not been able to interpret the error code.
I did find similar issue somewhere (exit code 18) that said this error was introduced by some update around ruby 2.5.3. I've been trying to downgrade the ruby version to 2.5.0 (replacing the zypper install with building rvm followed by installing a specific ruby version within it) in the Dockerfile.base image since midnight to no avail so far.

@AdamBark
Copy link

note that neither the "ruby version" or the "files may not be writable" messages seem to be the cause of the problem, as either setting an OSEM_RUBY_VERSION in .env.production or running bundle as sudo ... --system makes the respective warnings disappear, but the error stays the same.

I don't know why it doesn't get picked up from the environment but if you change line 5 of the Gemfile from:
ruby ENV['OSEM_RUBY_VERSION'] || '2.5.0'
to
ruby ENV['OSEM_RUBY_VERSION'] || '2.5.5'
it might work. It worked for me anyway.

@AndrewKvalheim
Copy link
Member

AndrewKvalheim commented Apr 11, 2020

To use the provided Docker Compose environment, I first had to resolve all of:

Now OSEM runs and the tests pass.

@rcfmc
Copy link

rcfmc commented May 31, 2020

Thank you for sharing this project. I just went through deploying the Docker version for production and I had to do several changes in a few files to make it work. I am sharing what I did in case it helps someone else.

./docker-compose.yml.production-example:

version: "2"

services:
  production_database:
    image: postgres
    environment:
      - PGDATA=/var/lib/postgresql/data/pgdata
      - POSTGRES_HOST_AUTH_METHOD=trust
    volumes:
      - osem_production_database:/var/lib/postgresql/data/pgdata
  production_web:
    build:
      context: .
      dockerfile: Dockerfile.production
    depends_on:
      - production_database
    ports:
      - 80:3000
    env_file: .env.production # see dotenv.example file
    environment:
     OSEM_DB_HOST: production_database
    command: /osem/bin/osem-init.sh
    volumes:
      - osem_production_web_data:/osem/public/system
      - osem_production_web_assets:/osem/public/assets
      - osem_production_web_logs:/osem/log

# named volumes to persist data
volumes:
  osem_production_database:
  osem_production_web_data:
  osem_production_web_assets:
  osem_production_web_logs:

I know that accessing the database with this POSTGRES_HOST_AUTH_METHOD=trust is not secure, but I was hitting a problem with the user and password and I wanted to get over with it quickly. I recommend to solve this in another way.

./Dockerfile.production:

FROM osem/base

RUN zypper -n install --no-recommends \
    # to solve issue with nikigori
    git-core \
    #to solve nokogiri dependency issues
    libxml2-devel libxslt-devel

# Add our files
COPY --chown=1000:1000 . /osem/


USER osem
WORKDIR /osem/


# Install our bundle
RUN bundle config build.nokogiri --use-system-libraries
RUN export NOKOGIRI_USE_SYSTEM_LIBRARIES=1; bundle install --jobs=3 --retry=3 --without test development

# Generate assets
RUN export RAILS_ENV=production; bundle exec rake assets:clobber assets:precompile

ENV RAILS_ENV=production

CMD ["foreman", "start"]

The most difficult part here was Nokogiri. I think that this is what made it work and probably is sufficient on its own: RUN bundle config build.nokogiri --use-system-libraries

I also had to change the ruby version in my Gemfile like this: ruby '2.5.8'. It was not taking it from the ENV file.

Lastly, I changed something in /config/environments/production.rb because the assets pipeline was not working well if I stopped and restart the service: config.assets.compile = true

With all of that, I have now a running version of OSEM and happy with it. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something is wrong and needs to be fixed
Projects
None yet
Development

No branches or pull requests

6 participants