Last active
March 1, 2022 22:00
-
-
Save Beyarz/e59fa64665f731c43367bb7135751b87 to your computer and use it in GitHub Desktop.
Rails (production) in Dockerfile with Node & Yarn included
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| node_modules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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