Nginx not recognizing "app" service when using entrypoint

So I’m using docker, postgres, django, and nginx.

It works fine but when I try to create an entrypoint script or even just an entrypoint so that I can run migrate but runserver it doesn’t work.

When I just have CMD runserver in my Dockerfile it’s fine. But if I set the ENTRYPOINT to ./docker-entrypoint.sh (which only runs migrate and runserver) I start to see nginx throw an error.

The error is:

app_1    | standard_init_linux.go:190: exec user process caused "no such file or directory"
nginx_1  | 2018/09/16 18:58:02 [emerg] 1#1: host not found in upstream "app:8001" in /etc/nginx/conf.d/default.conf:2
nginx_1  | nginx: [emerg] host not found in upstream "app:8001" in /etc/nginx/conf.d/default.conf:2

My Dockerfile:

FROM python:3.6

ARG requirements=requirements/local.txt
ENV DJANGO_SETTINGS_MODULE=sasite.settings.local

WORKDIR /app

COPY manage.py /app/
COPY requirements/ /app/requirements/ 

RUN pip install -r $requirements

COPY sasite sasite
COPY templates templates
COPY logs logs
COPY scripts scripts

EXPOSE 8001

CMD ["python", "manage.py", "runserver", "0.0.0.0:8001"]

My compose:

version: "3.2"
services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        requirements: requirements/local.txt
    environment:
      - DJANGO_SETTINGS_MODULE=sasite.settings.local
      - PYTHONDONTWRITEBYTECODE=1
    volumes:
      - ./:/app
    networks:
      - main
    depends_on:
      - db
  db:
    image: postgres:10.1-alpine
    environment:
      POSTGRES_DB: sasite_db
      POSTGRES_USER: pguser
      POSTGRES_PASSWORD: pguser123
    ports:
      - "5432:5432"
    networks:
      - main
  nginx:
    image: nginx
    volumes:
      - ./config/nginx.conf:/etc/nginx/conf.d/default.conf:ro
      - ./static:/usr/share/nginx/sasite/static
    ports:
      - "80:80"
    networks:
      - main
    depends_on:
      - app

networks:
  main:

And my entrypoint script:

#!/bin/bash
echo "Applying database migrations"
python manage.py migrate

# Start server
echo "Starting server"
python manage.py runserver 0.0.0.0:8000

Also my nginx.conf:

upstream django_server {
    server app:8001 fail_timeout=0;
}

server {
    listen 80;
    client_max_body_size 4G;
    server_name localhost;
    charset utf-8;
    keepalive_timeout 5;
    location /static/ {
        root /usr/share/nginx/sasite/;
        expires 30d;
    }
    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        if (!-f $request_filename) {
            proxy_pass http://django_server;
            break;
        }
    }
}

Any help would be appreciated. When I move to production I need to be able to have it run migrations before running the server when I deploy so having it not work is a big inconvenience.

Thanks