How to mount a host directory with docker-compose?

I’m wondering how you can mount a host directory using docker-compose.

At the moment I’m just using a regular Dockerfile and it’s working fine. When I run the container I just specify the path on my host and the path on the container.

docker run -d -p 3000:3000 -v ~/path/on/host:/path/on/container my-container

I’d like to to achieve this using docker-compose but I’m not sure how this works.My docker compose is below.

version: '3'

      context: .
      dockerfile: ./path/to/Dockerfile

Source: StackOverflow