0

Trying to host my Django app on Azure however I received the following errors. I also have an sqlite database but I dont think that causes the error if I'm not mistaken. I have set the DOCKER_REGISTRY... within Azure config to match those of my Docker account, is that correct?

enter image description here enter image description here enter image description here enter image description here

Azure has confirmed the below is successful: enter image description here

I have tried the following from here, here, here and here. I thought the issue was to do with the exposed ports set within docker file or within the apps settings.py file.

settings.py snippets

ALLOWED_HOSTS = ['.herokuapp.com', 'localhost', '127.0.0.1', 'shawjournal.azurewebsites.net']

WEBSITES_PORT=80
PORT=9000

dockerfile

# Pull base image
FROM python:3.8

EXPOSE 80
EXPOSE 443
EXPOSE 9000

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set work directory
WORKDIR /code

# Install dependencies
COPY Pipfile Pipfile.lock /code/
RUN pip install pipenv && pipenv install --system

# Copy project
COPY . /code/

CMD ["python", "/code/manage.py", "runserver", "0.0.0.0:8000"]

docker-compose.yml

version: '3.8'
services:
  web:
    build: .
    command: python /code/manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - 8000:8000

Thanks!

Luca
  • 97
  • 7

1 Answers1

0

Following-up on this, I understand you have referred to multiple threads/solutions on this. If you haven't reviewed these already, please try these:

From the initial investigation, I see that you’re exposing multiple different ports. By default, App Service assumes your custom container is listening on port 80. If your container listens to a different port set it using this App Setting. E.g., 8000. || I see you have added port 9000 and 8000 in a few settings.

Just to highlight the difference: app settings/variable- PORT (default) vs WEBSITES_PORT (it’s for custom containers).

This doc shows supported and unsupported Docker Compose configuration options ( build (not allowed))

Checkout the App Service Django samples here and steps outlined in this doc Django Deployment on App Service Linux for more info.

AjayKumar
  • 2,812
  • 1
  • 9
  • 28