Public | Automated Build

Last pushed: 2 years ago
Short Description
Rails development and test environment
Full Description

Supported tags and respective Dockerfile links

The latest tag has a predefined set of gems, including the latest version of Rails.

Create a image/container for your Rails app

First create a Dockerfile and put it in the root of your app, next to the Gemfile. It should look like this:

FROM vhugo/rails:onbuild

# Install database adapter and other app dependencies
RUN apt-get update && apt-get install -y \
    sqlite3 \
    --no-install-recommends && rm -rf /var/lib/apt/lists/*

Don't forget to add all the dependencies required for your application.

Common options for database adapter dependencies are sqlite3, mysql-client, postgresql-client.

You can then build and run the Docker image:

$ docker build -t your_app_image_name .
$ docker run -d --name your_app_container_name \
    -v "$PWD":/app -p 3000:3000 your_app_image_name

Remember to run this inside your current project directory.

Generate a Gemfile.lock

The onbuild tag expects a Gemfile.lock in your app directory. This docker run will help you generate one. Run it in the root of your app, next to the Gemfile:

$ docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app ruby:2.3 bundle install

Just do this if your project doesn't have a Gemfile.lock.

Bootstrap a new Rails application

If you want to generate the scaffolding for a new Rails project, you can do the following:

$ docker run -it --rm --user "$(id -u):$(id -g)" -v "$PWD":/app \
    vhugo/rails rails new --skip-bundle your_new_webapp

This will create a sub-directory named your_new_webapp inside your current directory.

License

View license information for the software contained in this image.

Docker Pull Command
Owner
vhugo
Source Repository

Comments (0)