Is it even possible to convert my docker-compose.yml to heroku.yml?

Viewed 2653

So I'm trying to deploy my app to Heroku. Here is my docker-compose.yml

version: '3'

#Define services
services:

  #Back-end Spring Boot Application
  entaurais:
    #The docker file in scrum-app build the jar and provides the docker image with the following name.
    build: ./entauraIS
    container_name: backend
    #Environment variables for Spring Boot Application.
    ports:
     - 8080:8080 # Forward the exposed port 8080 on the container to port 8080 on the host machine
    depends_on:
    - postgresql

  postgresql:
    image: postgres:13
    environment:
      - POSTGRES_PASSWORD=root
      - POSTGRES_USER=postgres
      - POSTGRES_DB=entauracars
    ports:
      - "5433:5433"
    expose:
      - "5433"

  entaura-front:
    build: ./entaura-front
    container_name: frontend
    ports:
      - "4200:4200"
    volumes:
      - /usr/src/app/node_modules

My frontend Dockerfile:

FROM node:14.15.0
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
COPY package*.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
EXPOSE 4200
CMD [ "npm", "start" ]

My backend Dockerfile:

FROM maven:3.6.0-jdk-11-slim AS build
COPY src /usr/src/app/src  
COPY pom.xml /usr/src/app  
RUN mvn -f /usr/src/app/pom.xml clean package

FROM openjdk:11-jre-slim
COPY --from=build /usr/src/app/target/entauraIS.jar /usr/app/entauraIS.jar
ENTRYPOINT ["java","-jar","/usr/app/entauraIS.jar"]

As far as I'm aware heroku needs it's own heroku.yml file, but with the examples I've seen I have no idea how to convert it to my sitaution. Any help is appreaciated, I am completely lost with Heroku.

One of the examples of heroku.yml that I looked at:

build:
  docker:
    web: Dockerfile
run:
  web: npm run start
release:
  image: web
  command:
    -npm run migrate up
1 Answers

docker-compose.yml to heroku.yml

docker-compose has some similar fields that heroku.yml. You could create manually.

It will be awesome the creation of some npm module to convert the docker-compose to heroku.yml. You just need to read the docker-compose.yml and pick some values to create a heroku.yml. Check this to know how read and write yml files.

docker is not required in heroku

If you are looking for a platform to deploy your apps and avoid infrastructure nightmares, heroku is an option for you.

Even more, if your application are standard (java & nodejs), does not need crazy configurations to build and is self-contained (no private libraries), you don't need docker :D

If your nodejs package.json has the standard scripts: start and build, it will run in heroku just perform git push to heroku without Dockerfile. Heroku will detect the nodejs, version and your app will start.

If your java has the spring-boot standard configurations, is the same, just push your code to heroku. In this case, previously to the push, add the postgress add-on manually and use environment variables in your application.properties jdbc url.

one process by app in heroku

If you have api + frontend you will need two apps in heroku. Also your api will need the postgress add-on

Heroku does not work like docker-compose, I mean : one host with all of your apps: front + api + db

Docker

If you want to use Docker, just put the Dockerfile and git push. Heroku will detect that docker is required and will perform the standard commands : docker build ... docker run... so, no extra configuration is required

heroku.yml

If you Docker is mandatory for your apps, and the standard docker build ... and docker run... is not enough for your apps, you wil need heroku.yml

You will need one heroku.yml by each app in heroku.

One advantage of this could be that the manually addition of postgress add-on will not required because is defined in heroku.yml

Related