version: '2'
services:
  db:
    image: postgres
    ports:
      - "5432:5432"
  web:
    build: .
    ports:
      - "4000:4000"
    env_file: .env
    environment:
      - RACK_ENV=production
      - RAILS_ENV=production
      - PORT=4000
    restart: always
    container_name: prep-manager
    depends_on:
      - db

version: '2'
services:
  db:
    image: postgres
    ports:
      - "5432:5432"
  web:
    build: .
    ports:
      - "4000:4000"
    env_file: .env
    environment:
      - RACK_ENV=production
      - RAILS_ENV=production
      - PORT=4000
      - POSTGRES_PORT_5432_TCP_ADDR=db
      - POSTGRES_PORT_5432_TCP_PORT=5432
      - POSTGRES_USER=postgres
    restart: always
    container_name: prep-manager
    depends_on:
      - db
    links:
      - db
~           

Add environment variables of database
Add environment variables of database