0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Docker で Rails プロジェクトを作成

Last updated at Posted at 2020-11-19

5系

コマンド一発。

docker run --rm -it --workdir /app/ --volume $PWD:/app/ ruby:2.6.3 bash -c "gem install rails -v 5.2.4 && rails new sample_project"

6系

6系から webpack に依存するので node, yarn を含んだイメージを自分で作る必要があります。

Dockerfile

ruby の image に node, yarn を突っ込みます。

Dockerfile
FROM ruby:2.7

RUN mkdir /app
WORKDIR /app

RUN curl https://deb.nodesource.com/setup_12.x | bash
RUN curl https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

RUN apt-get update -qq && \
    apt-get install -y nodejs yarn

RUN gem install rails -v 6.0.3

docker build, run を実行してプロジェクトを作成します。

docker build -t rails-gen . && \
    docker run --rm -it --volume $PWD:/app/ rails-gen:latest \
    bash -c "rails new sample"

以上です。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?