I
I
Ismail2020-04-26 19:37:01
Software Deployment
Ismail, 2020-04-26 19:37:01

How to deploy docker-compose on heroku?

Good time of the day. I have a question about deploying an application that is hosted on docker-compose.
Docker-compose consists of several containers:

  1. client (React app)
  2. API (Rails)
  3. nginx
  4. redis
  5. sidekiq
  6. postgresql

I want to deploy the entire application itself. The essence of the question is how to deploy a docker-compose application on heroku, and not just docker? Because the doc says that PostgreSQL and Redis should be removed from docker: " The python application depends on Postgres and Redis , which you do not push to Heroku . Instead, use Heroku add-ons in production. ".

Below is the docker-compose file:
docker-compose

version: "3.7"
x-api-volumes: &api-volumes
  - .:/app:cached
  - ~/.ssh:/root/.ssh
  - ~/.bash_history:/root/.bash_history
  - bundle_cache:/bundle_cache
x-api-environment: &api-environment
  - RAILS_PORT=8080
  - RAILS_SECRET_KEY_BASE=secret_key_base
  - DATABASE_HOST=db
  - REDIS_URL=redis://redis:6379/0
  - REDIS_PORT=6379
  - DATABASE_USERNAME=postgres
  - BUNDLE_PATH=/bundle_cache
  - GEM_HOME=/bundle_cache
  - GEM_PATH=/bundle_cache:/usr/local/bundle
networks:
  api:
services:
  api:
    build:
      context: .
      dockerfile: Dockerfile.api
    depends_on:
      - db
      - redis
    volumes: *api-volumes
    ports:
      - 8080:8080
    networks:
      - api
    environment: *api-environment
    command: bash -c "bundle install && bundle exec rake db:create db:migrate && bundle exec puma -C config/puma.rb -e development"
  redis:
    image: redis:alpine
    ports:
      - "6379:6379"
    networks:
      - api
  sidekiq:
    depends_on:
      - 'db'
      - 'redis'
    build: .
    networks:
      - api
    command: bundle exec sidekiq
    volumes:
      - '.:/app'
    env_file:
      - '.env'
  db:
    image: postgres:10.3-alpine
    networks:
      - api
  bundle_cache:
    networks:
      - api
    image: busybox
    volumes:
      - bundle_cache:/bundle_cache
  client:
    networks:
      - api
    build:
      context: client
      dockerfile: Dockerfile.client
    ports:
      - "3000:3000"
    depends_on:
      - api
    environment:
      - NODE_ENV=development
      - API_HOST=api
      - API_PORT=8080
      - CI=true
      - CHOKIDAR_USEPOLLING=true
    command: sh -c "yarn && yarn start"
    volumes:
      - ./client:/app:cached
      - client:/app/build
  nginx:
    build: ./infrastructure/nginx
    volumes:
      - client:/app/dist
      - ./public:/app/public
      - ./infrastructure/nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./infrastructure/nginx/conf.d:/etc/nginx/conf.d
    ports:
      - "80:80"
    networks:
      - api
    links:
      - api
volumes:
  bundle_cache:
  client:



It seems to me ( perhaps not correctly ) that it would be easiest to just pull from the repository, install docker and docker-compose on the server, raise docker-compose up. What to do in this case?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ismail, 2020-04-27
@gosugod

I solved the problem by simply buying a server on www.vultr.com Using
ssh, I went to the server console, cloned my turnip and raised docker-compose. Everything works, and many times easier than heroku. I took the simplest configuration for $5. :)

V
Vitaly Karasik, 2020-04-27
@vitaly_il1

I have not worked with heroku, but as far as I understand, they only support docker containers.
Actually, you only need api (Rails). And maybe sidekiq.

Y
YMakeev, 2020-04-27
@YMakeev

If you do not need to deploy to heroku , then you should try:
https://www.hetzner.com/cloud
For complex systems, the free heroku plan may not be enough;)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question