How to restore postgres dump while using docker-compose?

Hi! So far I got following Dockerfile and docker-compose.yml files:

FROM python:3.6
ADD requirements.txt /app/requirements.txt
WORKDIR /app/
RUN pip install -r requirements.txt
RUN adduser --disabled-password --gecos '' user
COPY code/ /app/

FROM postgres:latest
COPY db_dump.sql.gz /docker-entrypoint-initdb.d/
version: '3'

services:
  db:
    build:
      context: .
      dockerfile: Dockerfile
    image: postgres:latest
    hostname: db
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=postgres

  web:
    build:
      context: .
      dockerfile: Dockerfile
    hostname: web
    command: ./run_web.sh
    volumes:
      - .:/app
    ports:
      - "8000:8000"
    links:
      - db
    depends_on:
      - db

But in this configuration my web image exits and postgres doesn’t restore dump file. What am I doing wrong?

Problem is solved by adding volume parameter linking sql dump to /docker-entrypoint-initdb.d/

Can you share the dockerfile on how you solved the problem??