Skip to content

Latest commit

 

History

History
57 lines (48 loc) · 1.34 KB

README.md

File metadata and controls

57 lines (48 loc) · 1.34 KB

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