Aquí muestro cómo configurar Ruby on Rails y PosgreSQL para que trabajen de manera conjunta en Podman, empleando para ellos las imágenes para contenedores oficiales y alojadas en Docker Hub de Ruby, PostreSQL y PGADMIN4.
# Comandos:
sudo zypper install podman podman-docker podman-remote podmansh distrobox
podman pod create --name rails-postgres -p 3000:3000 -p 9999:9999 -p 5432:5432 --userns=keep-id --userns=keep-id:uid=5050,gid=5050
podman run -d --name postgres-rails-sgbd -e POSTGRES_PASSWORD=medina -e POSTGRES_USER=eduardo -e POSTGRES_ROLE=postgres -v /home/edu/Projects/ruby/postgres-db:/var/lib/postgresql/data:z --pod rails-postgres docker.io/postgres:15
podman run -d --pod=rails-postgres -e 'PGADMIN_DEFAULT_EMAIL=edu@localhost.com' -e 'PGADMIN_DEFAULT_PASSWORD=medina' -e 'PGADMIN_LISTEN_PORT=9999' -v /home/edu/Projects/ruby/postgres-bak:/var/lib/pgadmin/storage:z --name pgadmin-rails docker.io/dpage/pgadmin4
podman run -it --name rails-contenedor -v /home/edu/Projects/ruby:/mnt:z -w /mnt --pod rails-postgres docker.io/library/ruby:latest /bin/bash
# Acceder al contenedor si no se ha accedido y está en ejecución
podman exec -ti rails-contenedor /bin/bash
gem install bundler
gem update
gem install rails -v 8.1.3.1 # https://rubygems.org/gems/rails/versions
rails new prueba --database=postgresql # Proyecto de prueba
cd prueba # Acceder al proyecto de prueba
rails s -b 0.0.0.0
# En el fichero: config/database.yml
host: localhost
username: eduardo
password: medina
rails db:create
rails db:migrate
rails generate scaffold Producto codigo:string:uniq marca:string modelo:string
rails db:migrate
rails s -b 0.0.0.0
Cómo configurar Ruby on Rails con PostgreSQL empleando Podman
Submitted 10 hours ago by
eduardo_medina@video.hardlimit.com to edlinks@video.hardlimit.com