Failed to deploy multi-container app to Heroku via Travis CI

Viewed 259

For the past 2 days, I have been consistently trying out different methods of deploying my multi-container app to Heroku via Travis CI. Heroku shows a weird error when I deploy my application from Travis CI.

Here's my

docker-compose.yml:

version: '3'

services:
  db:
    image: mysql:5.7
    ports:
      - '3306:3306'
    environment:
       MYSQL_DATABASE: 'mysql'
       MYSQL_USER: 'root'
       MYSQL_PASSWORD: 'root'
       MYSQL_ROOT_PASSWORD: 'root'
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/covid_analysis
    ports:
      - "8000:8000"
    depends_on:
      - db

After deploying with this configuration, my Travis CI build shows a weird error: build error

After some Google search, I found a GitHub issue about this problem, which suggests deploying with entrypoint rather than cmd/command.

Therefore, I did change my command: python manage.py runserver 0.0.0.0:8000 to entrypoint: python manage.py runserver 0.0.0.0:8000.

This time, Travis build errored like this: build error

Here is my latest docker-compose.yml and Dockerfile I have Googled a lot of things, and I was not able to find anything that could solve my problem (or even explain why it's not working). All the builds work fine locally. The code is available on GitHub.

1 Answers

Your error comes from the way you are calling docker-compose run on Travis CI.

In your .travis.yml, the following can be found:

script:
- docker-compose run web python manage.py test

What your docker-compose tries to do here, is to run the following services:

  • web
  • python
  • manage.py
  • test

The only service that exists in your docker-compose however is web, so the command fails.

UPDATE

My original answer was wrong, I thought docker-compose run had similar behavior to docker-compose up.

The reason the error occurs after refactoring the web service from command: to entrypoint: in the docker-compose.yml is because of the following script in the .travis.yml:

script:
- docker-compose run web python manage.py test

The default behavior of docker-compose run is that it passes all the arguments after the specified service (in this case python manage.py test comes after web), as an override to command.

Because it is now refactored to entrypoint, this does not work anymore. This can be fixed by writing the script like this:

script:
- docker-compose run --entrypoint="python manage.py test" web
Related