Sign inSign up

ytakagi/ruby

By ytakagi

Updated almost 10 years ago

This docker image is used to create and develop ruby programs.

Image
0

1.2K

ytakagi/ruby repository overview

Ruby docker image

This docker image is used to create and develop ruby programs. It will install gems under project directory, so you can edit gems outside of container.

This image depends on official ruby image, so image tag also correspond to it.

Setup

You can just use this image, but if you are using gems that depends on some packages, you have to create another Dockerfile. Below is just a sample.

FROM ytakagi/ruby:latest

RUN apt-get update \
 && apt-get install -y --no-install-recommends \
                    build-essential \
                    libpq-dev \
                    nodejs \
 && rm -rf /var/lib/apt/lists/* \
 && ln -s /usr/bin/nodejs /usr/bin/node

Example

Create Rails project
  1. Create Gemfile

    cd /path/to/project/
    touch Gemfile
    

    Edit Gemfile to be below.

    source 'https://rubygems.org'
    gem 'rails'
    
  2. Create Dockerfile and build

    Create the same Dockerfile shown at Setup section.

    docker build -t sample-image .
    
  3. Bundle install and Rails new

    docker run --rm -v $(pwd):/workdir sample-image bundle install
    docker run --rm -v $(pwd):/workdir sample-image bundle exec rails new . --force --database=postgresql --skip-bundle
    

It's done!!

Run Rails server

Note: you need to prepare other container such as database separately.

cd /path/to/project/
docker run -v $(pwd):/workdir sample-image bundle exec rails server

Now you can edit Rails program (also gem) from host machine, while running Rails server at container.

Sweet!!

Tag summary

Content type

Image

Digest

Size

265.3 MB

Last updated

almost 10 years ago

docker pull ytakagi/ruby