Skip to content

Instantly share code, notes, and snippets.

@mpan-wework
Created March 10, 2019 07:29
Show Gist options
  • Select an option

  • Save mpan-wework/55a2de5cb15e846f9607e4dd43e782cb to your computer and use it in GitHub Desktop.

Select an option

Save mpan-wework/55a2de5cb15e846f9607e4dd43e782cb to your computer and use it in GitHub Desktop.

Revisions

  1. mpan-wework created this gist Mar 10, 2019.
    1 change: 1 addition & 0 deletions RailsPgRedisDocker.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    # Config Rails to use Postgres and Redis in docker
    31 changes: 31 additions & 0 deletions database.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    default: &default
    adapter: postgresql
    encoding: unicode
    database: <%= Rails.application.credentials[:pg_database] %>
    username: <%= Rails.application.credentials[:pg_username] %>
    password: <%= Rails.application.credentials[:pg_password] %>
    host: <%= Rails.application.credentials[:pg_host] %>
    port: <%= Rails.application.credentials[:pg_port] %>
    pool: 5

    development:
    <<: *default
    database: my_dev
    username: pguser
    password: p@55w0rdpg
    host: localhost
    port: 55432

    test:
    <<: *default
    database: my_test
    username: pguser
    password: p@55w0rdpg
    host: localhost
    port: 55432

    staging:
    <<: *default

    production:
    <<: *default
    18 changes: 18 additions & 0 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    version: '3'

    services:
    pg:
    image: postgres:11.2-alpine
    ports:
    - '55432:5432'
    volumes:
    - ${HOME}/.docker-volumes/pg-data:/var/lib/postgresql/data
    environment:
    - POSTGRES_PASSWORD=p@55w0rdpg
    - POSTGRES_USER=pguser
    redis:
    image: redis:5.0.3-alpine
    ports:
    - '56379:6379'
    volumes:
    - ${HOME}/.docker-volumes/redis-data:/data