LoginSignup
0
1

More than 3 years have passed since last update.

Ruby 2.6, MySQL, Webpacker, alpine 構成の Dockerfileの作成

Last updated at Posted at 2019-09-29

ブログから移動したものです。

開発環境は下記のDockerfile

FROM ruby:2.6.0-alpine3.8

ENV APP_ROOT /usr/src/app

WORKDIR $APP_ROOT

RUN apk add --no-cache alpine-sdk \
    nodejs-current \
    nodejs-npm \
    yarn \
    mysql-client \
    mysql-dev \
    python2 \
    tzdata

本番環境は下記のDockerfile
Rails 5.2 + Docker, RAILS_MASTER_KEYをイメージ作成時に動的に入れる方法で記載した形でbuild時に外部からRAILS_MASTER_KEYを入れられるようにしている。)

FROM ruby:2.6.0-alpine3.8

ENV RAILS_ENV=production
ENV APP_ROOT /usr/src/app
ARG RAILS_MASTER_KEY
ENV RAILS_MASTER_KEY ${RAILS_MASTER_KEY}

WORKDIR $APP_ROOT

RUN apk add --no-cache alpine-sdk \
    nodejs-current \
    nodejs-npm \
    yarn \
    mysql-client \
    mysql-dev \
    python2 \
    tzdata

COPY Gemfile $APP_ROOT
COPY Gemfile.lock $APP_ROOT

RUN bundle install --jobs=4

COPY . $APP_ROOT

RUN bin/yarn install
RUN bin/rails webpacker:compile

VOLUME $APP_ROOT/public
VOLUME $APP_ROOT/tmp
0
1
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
1