version: "3.8" services: web: build: . ports: - "3000:3000" environment: - RAILS_MASTER_KEY=$RAILS_MASTER_KEY <% if using_redis? -%> - REDIS_URL=redis://redis-db:6379 <% end -%> <% if deploy_database == 'postgresql' -%> - DATABASE_URL=postgres://root:password@postgres-db/ <% elsif deploy_database == 'mysql' -%> - DATABASE_URL=mysql2://root:password@mysql-db/ <% end -%> <% if deploy_database == 'sqlite3' -%> volumes: - ./db:/rails/db <% end -%> <% if using_redis? or deploy_database != 'sqlite3' -%> depends_on: <% if using_redis? -%> redis-db: condition: service_started <% end -%> <% if deploy_database == 'postgresql' -%> postgres-db: condition: service_healthy <% elsif deploy_database == 'mysql' -%> mysql-db: condition: service_healthy <% end -%> <% if deploy_database == 'postgresql' -%> postgres-db: image: postgres environment: POSTGRES_USER: root POSTGRES_PASSWORD: password volumes: - ./tmp/db:/var/lib/postgresql/data ports: - "5432:5432" healthcheck: test: pg_isready interval: 2s timeout: 5s retries: 30 <% elsif deploy_database == 'mysql' -%> mysql-db: image: mysql command: - --default-authentication-plugin=mysql_native_password environment: MYSQL_ROOT_PASSWORD: password volumes: - ./tmp/db:/var/lib/mysql healthcheck: test: mysqladmin ping -h 127.0.0.1 -u root --password=password interval: 2s timeout: 5s retries: 30 <% end -%> <% end -%> <% if using_redis? -%> redis-db: image: redis <% end -%> <% if using_sidekiq? and deploy_database != 'sqlite3' -%> sidekiq: build: . environment: - RAILS_MASTER_KEY=$RAILS_MASTER_KEY - REDIS_URL=redis://redis-db:6379 <% if deploy_database == 'postgresql' -%> - DATABASE_URL=postgres://root:password@postgres-db/ <% elsif deploy_database == 'mysql' -%> - DATABASE_URL=mysql2://root:password@mysql-db/ <% end -%> depends_on: redis-db: condition: service_started <% if deploy_database == 'postgresql' -%> postgres-db: condition: service_healthy <% elsif deploy_database == 'mysql' -%> mysql-db: condition: service_healthy <% end -%> <% end -%>