Skip to content

Instantly share code, notes, and snippets.

@Beyarz
Last active March 1, 2022 22:00
Show Gist options
  • Select an option

  • Save Beyarz/e59fa64665f731c43367bb7135751b87 to your computer and use it in GitHub Desktop.

Select an option

Save Beyarz/e59fa64665f731c43367bb7135751b87 to your computer and use it in GitHub Desktop.
Rails (production) in Dockerfile with Node & Yarn included
FROM ruby:3.0.0
WORKDIR /your_project
COPY . /your_project
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN curl -sS 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 update
RUN apt install -y nodejs yarn
RUN bundle
RUN rails yarn:install
RUN rails assets:precompile
RUN rails webpacker:compile
RUN export SECRET_KEY_BASE=$(rails secret)
EXPOSE 3000
ENV SECRET_KEY_BASE=$(SECRET_KEY_BASE)
ENV RAILS_ENV=production
ENV RAILS_SERVE_STATIC_FILES=true
ENTRYPOINT [ "rails" ]
CMD [ "server", "-b", "0.0.0.0" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment