Django.fun

Docker ignores middleware.py in Django Rest Project?

I have made a project where it uses blockchain service from a folder within the root of the project and middleware.py file uses the service.

I have dockerized the application but when I run docker-compose it completely ignores the middleware file and just runs the Django rest framework app, but when I run the app using manage.py it uses the middleware?

This is what happens when I run Docker-compose

Starting ssa2_webrun_1 ... done
Attaching to ssa2_webrun_1
webrun_1  | Watching for file changes with StatReloader
webrun_1  | Performing system checks...
webrun_1  | 
webrun_1  | System check identified no issues (0 silenced).
webrun_1  | May 19, 2022 - 11:47:58
webrun_1  | Django version 4.0.2, using settings 'ssfa.settings'
webrun_1  | Starting development server at http://0.0.0.0:8000/
webrun_1  | Quit the server with CONTROL-C.
webrun_1  | RBV1sF8ExF9UhpLHZKaf27JC1Ee87pg3hL
webrun_1  | [19/May/2022 11:48:03] "GET / HTTP/1.1" 200 5264
webrun_1  | RBV1sF8ExF9UhpLHZKaf27JC1Ee87pg3hL
webrun_1  | Not Found: /favicon.ico
webrun_1  | [19/May/2022 11:48:04] "GET /favicon.ico HTTP/1.1" 404 3295

This is what happens when I run from manage.py runserver (Correct)

Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
May 19, 2022 - 11:49:19
Django version 4.0.2, using settings 'ssfa.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Connecting to: 172.29.0.2:31678
Validating node wallet with RXfr8P7ws298FYjd1nLpfKNpE2FJEoDn4b
(7, 'Failed to connect to 172.29.0.2 port 31678: No route to host')
## CHECK NODE WALLET ERROR ##
# Things that could be wrong:
# Wallet is not imported on this node or wallet mismatch to env
# Node is not available. Check debug.log for details
# If node is rescanning, will take a short while
# If changing wallet & env, rescan will occur
# Exiting.
##

As you can see it exits the server and the server doesn't run if certain checks aren't made from middleware.py file

My docker compose is really simple and clear

version: "3.7"
services:
  webrun:
    build: ./
    command: python3 manage.py runserver 0.0.0.0:8000
    ports:
      - "8000:8000"


Dockerfile

FROM python:3.8
ENV PYTHONUNBUFFERED 1
COPY ./ /app
ARG ENV
WORKDIR /app
RUN if [ "$ENV" = "dev" ] ; then pip install -r requirements-dev.txt ; fi
RUN pip install -r requirements.txt

Tutorials

Современный Python: начинаем проект с pyenv и poetry

Настройка проекта Python — виртуальные среды и управление пакетами

Использование requests в Python — тайм-ауты, повторы, хуки

Понимание декораторов в Python

ProcessPoolExecutor в Python: полное руководство

map() против submit() с ProcessPoolExecutor в Python

Понимание атрибутов, словарей и слотов в Python

Полное руководство по slice в Python

Выпуск Django 4.0

Безопасное развертывание приложения Django с помощью Gunicorn, Nginx и HTTPS

Автоматический повтор невыполненных задач Celery

Django REST Framework и Elasticsearch

Докеризация Django с помощью Postgres, Gunicorn и Nginx

Асинхронные задачи с Django и Celery

Релизы безопасности Django: 3.2.4, 3.1.12 и 2.2.24

Выпуски исправлений ошибок Django: 3.2.3, 3.1.11 и 2.2.23

Эффективное использование сериализаторов Django REST Framework

Выпуски безопасности Django: 3.2.2, 3.1.10 и 2.2.22

Выпущенные релизы безопасности Django: 3.2.1, 3.1.9 и 2.2.21

Обработка периодических задач в Django с помощью Celery и Docker

View all tutorials →