GithubHelp home page GithubHelp logo

jmscholen / docker-rails Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nullstone-io/docker-rails

0.0 0.0 0.0 32 KB

Base docker image for Rails

Shell 23.23% Makefile 33.20% Dockerfile 43.57%

docker-rails's Introduction

nullstone/rails

Rails Base Image that is optimized for production and configured to operate locally the same way. This image is very opinionated; however, not restrictive.

Quick Reference

Supported Tags and respective Dockerfile links

Production vs Local

This repository builds an image for local use and production use.

The local image configures:

  • Sets the environment variable RAILS_ENV=development
  • On boot, the image runs bundle install (means you only need to restart the docker container when updating Gemfile)

Base image vs webapp image

This repository builds 2 variants of images: a base image and a webapp image.

The base image configures:

  • Server optimized for puma.
  • When making code changes locally, there is no need to rebuild/restart your container.
  • Logs are emitted to stdout.
  • Sets PORT env var to 80
  • On boot, POSTGRES_URL sets DB_ADAPTER=postgresql, DATABASE_URL=$POSTGRES_URL
  • On boot, MYSQL_URL sets DB_ADAPTER=mysql, DATABASE_URL=$MYSQL_URL

The webapp image additionally configures:

  • Preconfigures the image to attach nginx sidecar container. See below.
  • Changes PORT env var to 9000 to allow nginx to use port 80

Nginx sidecar

The webapp image is configured to optionally connect sidecar container running nginx. This pattern allows you to use nginx to serve static assets while the rails server serves dynamic requests.

docker-compose

See examples/webapp/prod.docker-compose.yml for a docker compose that mimics a production environment.

Nullstone

The following Nullstones modules provide one-click addition of an nginx sidecar:

Static Assets

Make sure to place all static content into /app/public inside the container. With a typical rails setup, this is done with the following in Dockerfile.

...
COPY . . # copies all rails code including `./public` into `/app`
RUN bundle exec rake assets:precompile
RUN bundle exec rake assets:clean

docker-rails's People

Contributors

bsick7 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.