Skip to content

Just a simple way to setup a Docker container with the latest from Ruby & Rails in 2021 - early 2022

Notifications You must be signed in to change notification settings

djigoio/Rails7-Ruby3-Docker-Setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intro

This is a repository made following the guidelines on the following Dockerfile website: https://docs.docker.com/samples/rails/

It contains the following:

  • Ruby latest image (3.0.3 as of today (21/12/2021))
  • Rails 7 ~> 7.0.0
  • PostgreSQL ~> 1.1

Run the following line to generate the project. For following steps (database, build) check the link above.

docker-compose run --no-deps web rails new . --force --database=postgresql

Docker files examples

Dockerfile

# syntax=docker/dockerfile:1
FROM ruby:latest
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle install

# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000

# Configure the main process to run when running the image
CMD ["rails", "server", "-b", "0.0.0.0"]

docker-compose.yml

version: "3.9"
services:
  db:
    image: postgres
    volumes:
      - ./tmp/db:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: password
  web:
    build: .
    command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
    volumes:
      - .:/myapp
    ports:
      - "3000:3000"
    depends_on:
      - db

About

Just a simple way to setup a Docker container with the latest from Ruby & Rails in 2021 - early 2022

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published