LoginSignup
10
4

More than 5 years have passed since last update.

RAILS_ENV=production rails assets:precompile を Docker でやるための Dockerfile

Last updated at Posted at 2017-04-30

Docker で rails の環境をつくりました。

それで、挙動確認のため

$ RAILS_ENV=production rails assets:precompile

をしようとしたら、yarn と node いれとかないとだめ、その過程で、apt-transport-https もいれないとだめと言われたので、rails 環境用の Dockerfile は以下のようになりました。

Dockerfile
FROM ruby:2.4
RUN apt-get update -qq && apt-get install -y \
    build-essential libpq-dev apt-transport-https

# node
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \
    && apt-get install -y nodejs

# yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
    && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
    && apt-get update && apt-get install -y yarn

RUN mkdir /myapp
WORKDIR /myapp
ADD Gemfile /myapp/Gemfile
ADD Gemfile.lock /myapp/Gemfile.lock
ADD . /myapp

全体はこちら
https://github.com/mochizukikotaro/docker-rails-mysql/blob/master/Dockerfile

10
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
4