6
3

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 5 years have passed since last update.

rails のDockerfile書き方メモ

Posted at

rails環境用のDockerfileを作った時のメモです

Dockerfile

FROM ruby:2.4.2
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
RUN mkdir /
WORKDIR /app-name
ADD Gemfile /app-name/Gemfile
ADD Gemfile.lock /app-name/Gemfile.lock
RUN bundle install
ADD . /app-name

各コマンドの意味

コマンド 意味
From ベースイメージを指定
RUN imageの中で実行するshellコマンド
ENV 環境変数の指定
COPY ローカルファイルのコンテナへのコピー
WORKDIR コンテナ起動時の作業ディレクトリの指定
CMD コンテナ起動時に実行するコマンドの定義
EXPOSE ホストのPORTの割り当て

参考

  • 公式リファレンス

https://docs.docker.com/compose/rails/#define-the-project
http://docs.docker.jp/engine/reference/builder.html

6
3
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
6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?