Quantcast
Channel: Active questions tagged redis+ruby-on-rails - Stack Overflow
Viewing all articles
Browse latest Browse all 873

Docker compose for rails application

$
0
0

I have below docker compose file, and i have few questions regarding it,

version: '3.8'services:  web:    build:      context: ./      dockerfile: Dockerfile    platform: linux/amd64    command: bash -c "rm -f tmp/pids/server.pid && bin/rails s -p 3000 -b '0.0.0.0'"    env_file:      - .env.development    volumes:      - .:/usr/src/app      - bundle:/usr/local/bundle    ports:      - "3000:3000"    environment:      REDIS_HOST: redis      REDIS_URL: redis://redis-server:6379/0      REDIS_PORT: 6379    depends_on:      db:        condition: service_healthy      redis:        condition: service_started  db:    image: postgres:16    ports:      - "5432:5432"    environment:      - POSTGRES_PASSWORD=postgres    volumes:      - pg_data:/var/lib/postgresql/data    healthcheck:      test: pg_isready -U postgres      interval: 2s      timeout: 5s      retries: 30  redis:    image: redis:7.0-alpine    restart: always    volumes:      - redis_data:/data    ports:      - 6379  sidekiq:    build: .    command: bundle exec sidekiq    depends_on:      - redis  rabbitmq:    image: "rabbitmq:latest"    ports:      - "5672:5672"  # sneakers:  #   build: .  #   command: "bundle exec rails sneakers:run"  #   depends_on:  #     - web  #     - rabbitmq  #     - redisvolumes:  pg_data:  redis_data:  bundle:

this is the database.yml file

default: &default  adapter: postgresql  encoding: unicode  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>development:<<: *default  database: <%= ENV['DB_NAME'] %>  username: <%= ENV['DB_USERNAME'] %>  password: <%= ENV['DB_PASSWORD'] %>  host: <%= ENV['DB_HOST'] %>  port: <%= ENV['DB_PORT'] %>test:<<: *default  database: <%= ENV['DB_NAME'] %>  username: <%= ENV['DB_USERNAME'] %>  password: <%= ENV['DB_PASSWORD'] %>  host: <%= ENV['DB_HOST'] %>  port: <%= ENV['DB_PORT'] %>cd_dev:<<: *default  database: <%= ENV['dbClusterIdentifier'] %>  username: <%= ENV['username'] %>  password: <%= ENV['password'] %>  host: <%= ENV['host'] %>  port: <%= ENV['port'] %>cd_qa:<<: *default  database: <%= ENV['dbClusterIdentifier'] %>  username: <%= ENV['username'] %>  password: <%= ENV['password'] %>  host: <%= ENV['host'] %>  port: <%= ENV['port'] %>cd_staging:<<: *default  database: <%= ENV['dbClusterIdentifier'] %>  username: <%= ENV['username'] %>  password: <%= ENV['password'] %>  host: <%= ENV['host'] %>  port: <%= ENV['port'] %>cd_production:<<: *default  database: <%= ENV['dbClusterIdentifier'] %>  username: <%= ENV['username'] %>  password: <%= ENV['password'] %>  host: <%= ENV['host'] %>  port: <%= ENV['port'] %>

I am getting below error in logs

cd-notification-common-service-redis-1     | 1:M 13 Feb 2024 21:29:46.265 # Can't handle RDB format version 11cd-notification-common-service-redis-1     | 1:M 13 Feb 2024 21:29:46.266 # Fatal error loading the DB: Invalid argument. Exiting.cd-notification-common-service-redis-1     | 1:C 13 Feb 2024 21:29:48.167 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oocd-notification-common-service-redis-1     | 1:C 13 Feb 2024 21:29:48.167 # Redis version=7.0.15, bits=64, commit=00000000, modified=0, pid=1, just startedcd-notification-common-service-redis-1     | 1:C 13 Feb 2024 21:29:48.167 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.confcd-notification-common-service-redis-1     | 1:M 13 Feb 2024 21:29:48.168 * monotonic clock: POSIX clock_gettimecd-notification-common-service-redis-1     | 1:M 13 Feb 2024 21:29:48.174 * Running mode=standalone, port=6379.cd-notification-common-service-redis-1     | 1:M 13 Feb 2024 21:29:48.174 # Server initializedcd-notification-common-service-redis-1     | 1:M 13 Feb 2024 21:29:48.176 # Can't handle RDB format version 11cd-notification-common-service-redis-1     | 1:M 13 Feb 2024 21:29:48.176 # Fatal error loading the DB: Invalid argument. Exiting.cd-notification-common-service-redis-1 exited with code 1

I have a few questions

  1. I am using aws secret store which is working fine when I was using a single docker file, do I need to define the secrets again in docker-compose? Suppose i have lots of env in database yml. it is loading from the secret manager, do I again need to define it in docker-compose?

  2. The Redis is in a different container and the Rails app is in a different container, I kept getting the error Cannot assign requested address - connect(2) for [::1]:6379 (Errno::EADDRNOTAVAIL) , how to use redis container in a rails app?

  3. I am using rabbitmq and for workers, I am using sneakers gem locally, how can I add it in docker-compose?

  4. I am gonna use this in the dev environment. do I need to specify anything related to env?


Viewing all articles
Browse latest Browse all 873

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>