Rails Base Image that is optimized for production and configured to operate locally the same way. This image is very opinionated; however, not restrictive.
- Maintained by Nullstone
- Where to get help Nullstone Slack
- ruby3.3, ruby3, latest
- ruby3.3-local, ruby3-local, local
- ruby3.3-webapp, ruby3-webapp, webapp
- ruby3.3-webapp-local, ruby3-webapp-local, webapp-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 updatingGemfile
)
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 to80
- On boot,
POSTGRES_URL
setsDB_ADAPTER=postgresql
,DATABASE_URL=$POSTGRES_URL
- On boot,
MYSQL_URL
setsDB_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 to9000
to allow nginx to use port80
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.
See examples/webapp/prod.docker-compose.yml for a docker compose that mimics a production environment.
The following Nullstones modules provide one-click addition of an nginx sidecar:
- Fargate Service (via Nullstone): nullstone/aws-fargate-nginx-sidecar
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