Create Rails5 and postgresql environment with Docker and make pgadmin available

I've only used mysql with docker and it took a long time, so I wrote it so that I can see it later. I also included pgadmin because it is convenient.

docoker-docker so you don't have to rails s after compose up-compose.I wrote in yml so that it will be done automatically with command.



 I don't usually need to recreate the container, so I'm assuming that I will do it with `` `docker-compose start / stop```.


#### **`Dockerfile`**
```dockerfile

FROM ruby:2.6

RUN apt-get update -y && \
    apt-get install  -y nodejs

COPY Gemfile /Gemfile
COPY Gemfile.lock /Gemfile.lock
RUN gem install bundler
RUN bundle install

docker-compose.yml


version: "3"
services:
  db:
    image: postgres
    ports:
      - 5432:5432
    environment:
      POSTGRES_USER: root
      POSTGRES_PASSWORD: root
    volumes:
      - "./postgres-data:/var/lib/postgresql/data"
  pgadmin4:
    image: dpage/pgadmin4:4.2
    ports:
      - 80:80
    volumes:
      - ./docker/pgadmin4:/var/lib/pgadmin
    environment:
      PGADMIN_DEFAULT_EMAIL: root
      PGADMIN_DEFAULT_PASSWORD: root
    depends_on:
      - db
  web:
    build: .
    volumes:
      - ".:/app"
    ports:
      - "3000:3000"
    tty: true
    depends_on:
      - db
    working_dir: "/app"
    command: "rails s -b 0.0.0.0"

mysql and database.yml are different, and I was addicted to writing something like develop here. I had to write it properly in default.

config/database.yml


default: &default
  adapter: postgresql
  encoding: unicode
  # For details on connection pooling, see Rails configuration guide
  # http://guides.rubyonrails.org/configuring.html#database-pooling
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  #Here and there
  username: root
  password: root
  host: db

Reference site Persistence of connection server settings of pgadmin4 / docker -Qiita

Write the Dockerfile and docker \ -compose \ .yml for rails5 -Qiita

Recommended Posts

Create Rails5 and postgresql environment with Docker and make pgadmin available
Building Rails 6 and PostgreSQL environment with Docker
Create Rails 6 + MySQL environment with Docker compose
[Docker] Rails 5.2 environment construction with docker
Rails + MySQL environment construction with Docker
Create a Vue3 environment with Docker!
Build environment with vue.js + rails + docker
Build Rails environment with Docker Compose
Create Laravel environment with Docker (docker-compose)
[Environment construction with Docker] Rails 6 & MySQL 8
Super beginner builds Rails6 + Postgresql environment with Docker to the end
Create a MySQL environment with Docker from 0-> 1
Create Spring Boot-gradle-mysql development environment with Docker
[Docker] Create Node.js + express + webpack environment with Docker
Install Docker and create Java runtime environment
Environment construction summary with rvm and postgresql
How to build Rails 6 environment with Docker
I built a rails environment with docker and mysql, but I got stuck
Build a local development environment for Rails tutorials with Docker (Rails 6 + PostgreSQL + Webpack)
Launching the production environment with docker + rails (ver5.2) and errors that occurred
Build a development environment for Docker + Rails6 + Postgresql
[Memo] Create a CentOS 8 environment easily with Docker
Make SpringBoot1.5 + Gradle4.4 + Java8 + Docker environment compatible with Java11
[Rails] rails new to create a database with PostgreSQL
(Basic authentication) environment variables in rails and Docker
Rails6 [API mode] + MySQL5.7 environment construction with Docker
Notes on building Rails6 / PostgreSQL with Docker Compose
Create jupyter notebook with Docker and run ruby
Rails development environment created with VSCode and devcontainer
Prepare a scraping environment with Docker and Java
[Rails] How to build an environment with Docker
Create a Spring Boot development environment with docker
Rails Docker environment construction
Rails deploy with Docker
Create an EC site with Rails5 ④ ~ Header and footer ~
Create an E2E test environment with Docker x Cypress
[Note] Create a java environment from scratch with docker
Build Rails (API) x MySQL x Nuxt.js environment with Docker
Build WordPress environment with Docker (Local) and AWS (Production)
Comfortable Docker environment created with WSL2 CentOS7 and Docker Desktop
Create Chisel development environment with Windows10 + WSL2 + VScode + Docker
[Rails] [Docker] Copy and paste is OK! How to build a Rails development environment with Docker
Docker command to create Rails project with a single blow in environment without Ruby
Pytorch execution environment with Docker
Maybe it works! Create an image with Docker and share it!
Beginners write! Until you install postgreSQL on macOS catalina and make it available in rails 6.0.3.2
[Docker] Create Elasticsearch, Kibana environment!
Make Docker confusing with Pokemon and make it easier to attach
Easy environment construction of MySQL and Redis with Docker and Alfred
Run Rails whenever with docker
[Rails 6.0, Docker] I tried to summarize the Docker environment construction and commands necessary to create a portfolio
Build docker environment with WSL
Build a Node-RED environment with Docker to move and understand
[Docker] postgres, pgadmin4 environment construction
React environment construction with Docker
I tried to create a padrino development environment with Docker
[Docker] Use whenever with Docker + Rails
Building an environment for creating apps with Rails and Vue
Build Metabase with Docker on Lightsail and make it https with nginx
Ruby on Rails development environment construction with Docker + VSCode (Remote Container)
Procedure for building a Rails application development environment with Docker [Rails, MySQL, Docker]