fork download
  1. # .env
  2. DEBUG=False
  3. SECRET_KEY=foo
  4. ALLOWED_HOSTS=*
  5.  
  6.  
  7. # settings.py
  8. import environ
  9.  
  10. BASE_DIR = Path(__file__).resolve().parent.parent
  11. env = environ.Env(
  12. DEBUG=(bool, False),
  13. ALLOWED_HOSTS=(list, []),
  14. )
  15. environ.Env.read_env(BASE_DIR.joinpath('.env'))
  16.  
  17. SECRET_KEY = env('SECRET_KEY')
  18. DEBUG = env('DEBUG')
  19. ALLOWED_HOSTS = env.list('ALLOWED_HOSTS')
  20.  
  21.  
  22. # Dockerfile
  23. FROM python:3
  24.  
  25. WORKDIR /usr/src/app
  26.  
  27. ENV PYTHONDONTWRITEBYTECODE 1
  28. ENV PYTHONUNBUFFERED 1
  29.  
  30. RUN pip install --upgrade pip
  31. COPY requirements.txt .
  32. RUN pip install --no-cache-dir -r requirements.txt
  33.  
  34. COPY . .
  35.  
  36. RUN chmod +x entrypoint.sh
  37. ENTRYPOINT ["/usr/src/app/entrypoint.sh"]
  38.  
  39.  
  40. # entrypoint.sh
  41. #! /bin/bash
  42. python manage.py makemigrations --noinput
  43. python manage.py migrate --noinput
  44. python manage.py collectstatic --noinput
  45. python manage.py runserver 9000
  46.  
  47.  
  48. # docker-compose.yml
  49. version: '3'
  50. services:
  51. web:
  52. build:
  53. context: ./
  54. dockerfile: Dockerfile
  55. volumes:
  56. - ./:/usr/src/app
  57. ports:
  58. - "9000:9000"
  59. env_file:
  60. - ./.env
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Traceback (most recent call last):
  File "/usr/lib/python3.7/py_compile.py", line 143, in compile
    _optimize=optimize)
  File "<frozen importlib._bootstrap_external>", line 791, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "./prog.py", line 4
    ALLOWED_HOSTS=*
                  ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.7/py_compile.py", line 147, in compile
    raise py_exc
py_compile.PyCompileError:   File "./prog.py", line 4
    ALLOWED_HOSTS=*
                  ^
SyntaxError: invalid syntax

stdout
Standard output is empty