Friday, November 16, 2018

Simple Dockerfile and docker-compose.yml for Rails 5 App

Dockerfile contents:

FROM ruby:2.5

RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs

RUN mkdir /budget
WORKDIR /budget

COPY Gemfile /budget/Gemfile
COPY Gemfile.lock /budget/Gemfile.lock

RUN bundle install
COPY . /budget

LABEL maintainer="Bala Paranj "

CMD puma -C config/puma.rb

docker-compose.yml:

version: '3'
services:
  web:
    build: .
    command: bundle exec rails s -p 3000 -b '0.0.0.0'
    ports:
      - "3000:3000"

Run:

docker-compose build
docker-compose up