2

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.

Mihir Joshi
  • 426
  • 5
  • 14

1 Answers1

1

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
octagon_octopus
  • 1,194
  • 7
  • 10
  • 1
    You may notice that the command `docker-compose run web python manage.py test` runs fine in the first build (with `command` used in docker-compose.yml). But it fails in this case. What do you think can be done here? Maybe creating a build_script.sh and adding `docker-compose run web python manage.py test` ? – Mihir Joshi Jul 20 '20 at 14:20
  • 1
    I've added an update to my answer. Seems like I was wrong in my original statement. Please let me know if my updated proposal works. – octagon_octopus Jul 20 '20 at 15:05
  • The command now works, but it produces the same error as the first build: (https://travis-ci.com/github/mformihir/COVID-19-Predictive-Analysis/jobs/362934849) I'll try updating heroku CLI in Travis now. Also, if you think the question was useful, please, upvote. – Mihir Joshi Jul 20 '20 at 16:13