简体   繁体   中英

Deploy Django api rest in heroku using docker

I'm trying to access to my Api rest that I released in Heroku with docker and see that Dynos is running the gunicorn command that I put in the Dockerfile. The Dockerfile that I used is:

FROM ubuntu:18.04

RUN apt update
RUN apt install -y python3 python3-pip
RUN mkdir /opt/app

ENV PYTHONUNBUFFERED 1
ENV LANG C.UTF-8
ENV DEBIAN_FRONTEND=noninteractive 

COPY Ski4All/ /opt/app/
COPY requirements.txt /opt/app/
RUN pip3 install -r /opt/app/requirements.txt
ENV PORT=8000

CMD exec gunicorn Ski4All.wsgi:application — bind 0.0.0.0:$PORT

When I release I go into the container via heroku run bash -a "name app" and executing ps aux I don't see the api running. But if execute the command of my Dockerfile when I'm in the container.

Any idea?

@jhaos mentioned gunicorn was running in the root path

Change the following in Dockerfile

RUN mkdir /opt/app to WORKDIR /opt/app
COPY Ski4All/ /opt/app/ to COPY Ski4All .

The problem was that the gunicorn command was running in the / root path and not in the correct workdir. In the comments @HariHaraSuhan solved the error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM