0

I am trying to deploy on Heroku my project in Docker with Angular 4 frontend, Django backend and postgresql database. At this moment my files look as shown below. I am note sure if this is done properly? I pushed it using heroku container:push web --app myproject but it doesn't work (Logs). When I'm running docker-compose up without Heroku everything seems to be working properly.

I noticed that in logs there is Process exited with status 127. I have found here 127 Return code from $? that

Value 127 is returned by /bin/sh when the given command is not found within your PATH system variable and it is not a built-in shell command. In other words, the system doesn't understand your command, because it doesn't know where to find the binary you're trying to call.

Besides, when I was trying different commands I very often were getting error like /bin/sh: 1 not found what I described in this post. Maybe it is a root of the problem? Or eventually there is a problem with ports like in this case?

Any other ideas? It seems to me that I was trying everything. I have no idea what is wrong.

I will be grateful if you could tell me if I am doing everything properly.

1.`heroku login`
2.`heroku container:login`
3.`heroku create nameofmyapp`
4.`heroku container:push web --app nameofmyapp`
5.`heroku open --app nameofmyapp`

Logs:

2017-07-08T13:19:48.882112+00:00 heroku[web.1]: Process exited with status 0
2017-07-08T13:20:40.336825+00:00 heroku[run.9745]: Awaiting client
2017-07-08T13:20:40.395900+00:00 heroku[run.9745]: Starting process with command `docker-compose up`
2017-07-08T13:20:40.542168+00:00 heroku[run.9745]: State changed from starting to up
2017-07-08T13:20:45.727667+00:00 heroku[run.9745]: State changed from up to complete
2017-07-08T13:20:45.715556+00:00 heroku[run.9745]: Process exited with status 127
2017-07-08T13:21:39.171330+00:00 heroku[run.8300]: Awaiting client
2017-07-08T13:21:39.198870+00:00 heroku[run.8300]: Starting process with command `docker-compose up`
2017-07-08T13:21:39.470489+00:00 heroku[run.8300]: State changed from starting to up
2017-07-08T13:21:43.381827+00:00 heroku[run.8300]: State changed from up to complete
2017-07-08T13:21:43.369201+00:00 heroku[run.8300]: Process exited with status 127
2017-07-08T13:25:26.780464+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=myapp.herokuapp.com request_id=cb876e32-ca19-467e-85a6-5babab50beab fwd="109.153.174.199" dyno= connect= service= status=503 bytes= protocol=https
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2017-07-08T13:20:40.336825+00:00 heroku[run.9745]: Awaiting client
2017-07-08T13:20:40.395900+00:00 heroku[run.9745]: Starting process with command `docker-compose up`
2017-07-08T13:20:40.542168+00:00 heroku[run.9745]: State changed from starting to up
2017-07-08T13:20:45.727667+00:00 heroku[run.9745]: State changed from up to complete
2017-07-08T13:20:45.715556+00:00 heroku[run.9745]: Process exited with status 127
2017-07-08T13:21:39.171330+00:00 heroku[run.8300]: Awaiting client
2017-07-08T13:21:39.198870+00:00 heroku[run.8300]: Starting process with command `docker-compose up`
2017-07-08T13:21:39.470489+00:00 heroku[run.8300]: State changed from starting to up
2017-07-08T13:21:43.381827+00:00 heroku[run.8300]: State changed from up to complete
2017-07-08T13:21:43.369201+00:00 heroku[run.8300]: Process exited with status 127
2017-07-08T13:25:26.780464+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=myapp.herokuapp.com request_id=cb876e32-ca19-467e-85a6-5babab50beab fwd="109.153.174.199" dyno= connect= service= status=503 bytes= protocol=https

Project tree:

├── Backend
│   ├── AI
│   │   ├── __init__.py
│   │   ├── __pycache__
│   │   │   ├── __init__.cpython-36.pyc
│   │   │   ├── settings.cpython-36.pyc
│   │   │   ├── urls.cpython-36.pyc
│   │   │   └── wsgi.cpython-36.pyc
│   │   ├── settings.py
│   │   ├── urls.py
│   │   └── wsgi.py
│   └── manage.py
├── Dockerfile
├── init.sql
├── Frontend
│   └── angularProject
        ├── Dockerfile
│       └── all files in my angular project 
├── docker-compose.yml
└── requirements.txt

Frontend's Dockerfile:

# Create image based on the official Node 6 image from dockerhub
FROM node:6

# Create a directory where our app will be placed
RUN mkdir -p /usr/src/app

# Change directory so that our commands run inside this new directory
WORKDIR /usr/src/app

# Copy dependency definitions
COPY package.json /usr/src/app

# Install dependecies
RUN npm install

# Get all the code needed to run the app
COPY . /usr/src/app

# Expose the port the app runs in
EXPOSE 4200

# Serve the app
CMD ["npm", "start"]

Main directory's Dockerfile:

FROM python:3.6.1
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip3 install -r requirements.txt
ADD . /code/

docker-compose.yml:

version: '3'

services:
  db:
    image: postgres
    environment:
      POSTGRES_USER: aso
      POSTGRES_PASSWORD: somepass
  django:
    build: .
    command: python3 MainDirectory/backend/myProject/manage.py runserver 0.0.0.0:8001
    volumes:
      - .:/code
    ports:
      - "8001:8001"
    depends_on:
      - db
  angular:
    build: MainDirectory/frontend
    ports:
      - "4200:4200"
    depends_on:
      - django

init.sql:

CREATE USER myUser;
CREATE DATABASE myProject;
GRANT ALL PRIVILEGES ON DATABASE myProject TO myUser;
  • I have been reading your re-posted question again and again all day. Seriously, stop deleting and adding the same question. – Robert Jul 10 '17 at 00:06
  • I added new information to my post. I am trying everything to solve my problem. –  Jul 10 '17 at 00:11
  • That is totally legal. What is not legal is re post the same question to gain attention. – Robert Jul 10 '17 at 00:14
  • Is there a period after which I can re-post legally? –  Jul 10 '17 at 00:16
  • It looks like docker is not found in the environment path. Can you both post the PATH variable and the output of the command `which docker`? – aash Jul 10 '17 at 06:09
  • `echo $PATH` returns `/usr/local/opt/libiconv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/local/opt/libiconv/bin:/Applications/Muse` command `which docker` returns `/usr/local/bin/docker`. –  Jul 10 '17 at 08:28
  • @geeky_sh When I'm running `docker-compose up` without Heroku everything seems to be working properly. Thank you for your interest in the topic. –  Jul 10 '17 at 08:36
  • It seems then that docker is not installed on heroku. Can you check? – aash Jul 10 '17 at 12:00
  • How can I check it? I was running `heroku plugins:install heroku-docker` and I am getting `Installing plugin heroku-docker... ! ▸ Plugin heroku-docker is already installed` It should be done in this way? –  Jul 10 '17 at 12:03
  • I updated my first post and described all steps that I am doing to deploy my app. Can you take a look and tell me if I am doing it properly? –  Jul 10 '17 at 12:46
  • Similar to this: https://stackoverflow.com/questions/46225801/docker-django-postgres-add-on-heroku/46229012#46229012 – Giovanni Klein Campigoto Sep 14 '17 at 22:19

1 Answers1

0

I guess i'm running through the same issue, maybe you should only use docker-compose for running your application locally, and configure it to run on heroku using postgres add-on: https://devcenter.heroku.com/articles/heroku-postgresql.

But i'm unsure how to actually fire the application up after that. I can do the migrations using the django commands: python manage.py migrate, however cannot start the server on heroku using heroku run python manage.py runserver, because I'm uploading a Docker Image. So I'm unsure how to boot the application up. Maybe the add-on can help...

EDIT 1: Solved it for django apps, checkout my issue: Docker + Django + Postgres Add-on + Heroku

  • Just posted another question, let's see if someone can help...heroku docs seems rather confusing on building docker related stuff...As soon as I solve it, I will post it here as well... – Giovanni Klein Campigoto Sep 14 '17 at 18:15