Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. FROM ruby:2.4.1
  2.  
  3. ARG UID=9999
  4. ARG GID=9998
  5.  
  6. ENV TZ=Europe/Moscow
  7. RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
  8.  
  9. RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - \
  10. && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
  11. && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
  12. && apt-get update -qq \
  13. && apt-get install -y build-essential libpq-dev nodejs yarn
  14.  
  15. RUN apt-get remove -y autoconf automake \
  16. && apt-get autoremove -y \
  17. && apt-get clean \
  18. && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
  19.  
  20. # user & group init
  21. RUN addgroup --gid $GID app
  22. RUN adduser --uid $UID --gid $GID --disabled-password --gecos "Application" app
  23. RUN usermod -L app
  24. RUN mkdir -p /app
  25. RUN chmod 700 /app
  26. RUN chown app:app /app
  27.  
  28. USER app
  29. WORKDIR /app
  30.  
  31. # bundle install
  32. COPY --chown=app:app Gemfile /app
  33. COPY --chown=app:app Gemfile.lock /app
  34. RUN bundle install
  35.  
  36. # yarn install
  37. COPY --chown=app:app bin /app/bin
  38. #COPY --chown=app:app yarn.lock /app/yarn.lock
  39. COPY --chown=app:app package.json /app/package.json
  40. RUN /app/bin/yarn install
  41.  
  42. # Rails Build Evironment
  43. RUN mkdir config\
  44. && mkdir /app/config/environments\
  45. && echo "require_relative 'config/application'\nRails.application.load_tasks" > Rakefile \
  46. && echo "require_relative 'boot'\nrequire 'rails/all'\nBundler.require(*Rails.groups)\nmodule App\n class Application < Rails::Application\n end\nend" > config/application.rb\
  47. && echo "ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)\nrequire 'bundler/setup'" > config/boot.rb\
  48. && echo "require_relative 'application'\nRails.application.initialize!" > config/environment.rb\
  49. && echo "default: &default\n adapter: postgresql\n database: ''\n username: ''\n password: ''\n host: ''\n port: ''\ndevelopment:\n <<: *default\ntest:\n <<: *default\nproduction:\n <<: *default" > config/database.yml\
  50. && touch config/environments/development.rb config/environments/production.rb
  51.  
  52. RUN bin/rails secrets:setup
  53.  
  54. # Build Assets
  55. COPY --chown=app:app config/webpacker.yml /app/config/webpacker.yml
  56. COPY --chown=app:app config/webpack /app/config/webpack
  57. #RUN mkdir app
  58. COPY --chown=app:app app/javascript /app/app/javascript
  59. COPY --chown=app:app app/assets /app/app/assets
  60. RUN bundle exec rails assets:precompile RAILS_ENV=production
  61.  
  62. # Install Webpacker (workaround)
  63. # TODO: fix compiling bug with webpacker
  64. # USER root
  65. # RUN rm -rf config/webpacker.yml config/webpack app
  66. # USER app
  67. # RUN bundle exec rails webpacker:install
  68. # RUN bundle exec rails webpacker:install:vue
  69.  
  70. COPY --chown=app:app . /app
  71.  
  72. CMD ["/app/bin/bundle", "exec", "passenger start -p 3000 --log-file /dev/stdout"]
  73.  
  74. EXPOSE 3000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement