How to deploy multi-container app to Heroku?

Viewed 756

I have the following docker-compose.yml. It has multiple services which talk to each other.

version: "3.9"

services:
  model:
    build:
      context: ./services/model
      dockerfile: Dockerfile.dev
    container_name: model
    volumes:
      - ./services/model/:/usr/app

  server:
    build:
      context: ./services/server
      dockerfile: Dockerfile.dev
    container_name: server
    env_file: ./services/server/.env
    depends_on:
      - db
      - model
    volumes:
      - ./services/server/:/usr/app
      - node_modules:/usr/app/node_modules
    ports:
      - "${SERVER_PORT}:${SERVER_PORT}"

volumes:
  dbdata:
  node_modules:

I want to deploy the same to Heroku. I found this article about how to deploy multi-container apps to Heroku using heroku.yml. But there does not seem to be any explanation about how to create a network between these containers and let them talk to one another.

I would like to know how to accomplish the same using Heroku.

Thank you !

EDITED:

I have removed db service because heroku's postgres addon could be used. Also, neglect the volume mounting part. It was just for local development.

But, I need server to comminucate with model service. So, I need them to be on the same network like in docker-compose which creates a virtual network for containers to talk to each other. I also saw this answer which says Docker swarm could be used. But I found out that it is no longer actively maintained. Kubernetes could also be an option but I need some way to deploy this kind of app on Heroku. I am a newbie to Docker. So any advice is going to be hugely appreciated !

Thanks !

0 Answers
Related