Skip to content

Add docker image #3

@maxmeyer

Description

@maxmeyer

Would you mind to add an Docker Image? Maybe something based on the given Dockerfile. This example uses the multistage build feature of docker which should be available on hub.docker.com since June 2017.

FROM ruby:2.4
MAINTAINER xxx

ENV RAILS_ENV=production

RUN apt-get update \
  && apt-get install -y libc-dev gcc g++ binutils build-essential

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

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

ADD src/Gemfile* /tmp/app/
WORKDIR /tmp/app

RUN gem install bundler \
  && bundle install --without development test \
  && bundle update \
  && rm -r /tmp/app/

ADD src/ /srv/app/
ADD files/latest/config/*.rb /srv/app/config/initializers/
WORKDIR /srv/app/

RUN yarn install

RUN sed -i "s/:debug/:info/" config/environments/production.rb

RUN gem install bundler \
  && bundle install --without development test

RUN rake assets:precompile

ENTRYPOINT ["/usr/local/bundle/bin/rails"]
CMD ["server"]

######

FROM ruby:2.4
MAINTAINER xxx

ENV RAILS_ENV=production
ENV RAILS_LOG_TO_STDOUT=true

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

RUN rm -fr /usr/local/bundle/

COPY --from=0 /usr/local/bundle/ /usr/local/bundle/
COPY --from=0 /srv/app/ /srv/app/

WORKDIR /srv/app/

ENTRYPOINT ["/usr/local/bundle/bin/rails"]
CMD ["server"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions