Skip to content

Mashpy/rails-7-docker-template-with-postgresql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ruby on Rails 7 docker template with postgresql

  1. Download the project first or git clone.
 git clone https://github.com/Mashpy/rails-7-docker-template-with-postgresql.git

If you clone you have to change your repo name later from .git/config file

  1. Rename the project name as your wish
 mv rails-7-docker-template-with-postgresql your_project_name
  1. Change directory -
 cd your_project_name
  1. Update your rails version on the Gemfile -
source 'https://rubygems.org'
gem 'rails', '7.0.3'
  1. Update Ruby version on Dockerfile -
FROM  ruby:3.1.2-slim
  1. Now install new rails app -
 docker-compose run app rails new . --force --database=postgresql --skip-bundle
  1. Build the docker image -
 docker-compose build
  1. Update database details on config/database.yml file.
default: &default
  adapter: postgresql
  encoding: unicode
  host: postgres
  username: postgres
  password: password
  pool: 5

development:
  <<: *default
  database: dev


test:
  <<: *default
  database: dev
  1. Run -
 docker-compose up
  1. wait little bit see your eyes on the console, it should show -
Puma Listening on http://0.0.0.0:3000
Pg admin Listening at: http://[::]:80 (1)

It will take time to load. Keep patient. After then then open another terminal and create a database -

docker-compose exec app rake db:create
  1. Browse http://localhost:3000. Ruby on rails 7.0.3 docker with mysql

  2. Browse http://localhost:5050/ . You can login on pgadmin. username: admin@admin.com password: password

  3. Add database connection on pgadmin. You need your postgres_container IP address.

docker ps

copy hash code of postgres_container.

docker inspect fcc97e066cc8 | grep IPAddress
  1. after login on pgadmin add connection. Write host IP address. username: postgres password: password

  2. now you can start work on your project.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published