Docker - Django + postgres

Не очень понимаю, почему не работает.

Dockerfile

FROM python:3.9-alpine

WORKDIR /usr/src/app/
COPY . /usr/src/app/

EXPOSE 8088

ENV DEBUG=1
ENV SECRET_KEY=1
ENV DB_NAME=postgres
ENV DB_USER=postgres
ENV DB_PASSWORD=1
ENV DB_HOST=0.0.0.0

RUN apk add gcc musl-dev python3-dev libffi-dev openssl-dev cargo
RUN apk add freetype-dev libjpeg-turbo-dev libpng-dev
RUN apk add postgresql-dev
RUN pip install --upgrade pip
RUN apk add python3-dev
RUN apk add gcc
RUN pip install -r requirements.txt

ENTRYPOINT ["sh", "initial.sh"]

Docker-compose

version: '3.9'

services:

  db:
    image: postgres:latest
    environment:
      POSTGRES_PASSWORD: 1
    expose:
      - "5432"
    ports:
      - "5432:5432"

  web:
    build: .
#    command: gunicorn config.wsgi:application --bind 0.0.0.0:8088
    entrypoint: ["sh", "startup.sh"]
    expose:
      - "5432"
      - "8088"
    ports:
      - "8888:8088"
    depends_on:
      - db

И итоговый лог веб-сервиса

  Applying friendship.0003_block_unique_together... OK
2021-08-19T12:25:57.503527839Z   Applying friendship.0004_auto_20200408_1844... OK
2021-08-19T12:25:57.503530298Z   Applying sessions.0001_initial... OK
2021-08-19T12:25:57.902563756Z System check identified some issues:
2021-08-19T12:25:57.902612839Z 
2021-08-19T12:25:57.902615964Z WARNINGS:
2021-08-19T12:25:57.902617923Z account.Technology.user: (fields.W340) null has no effect on ManyToManyField.
2021-08-19T12:25:57.947482006Z Operations to perform:
2021-08-19T12:25:57.947507214Z   Apply all migrations: account
2021-08-19T12:25:57.947510131Z Running migrations:
2021-08-19T12:25:57.947515048Z   No migrations to apply.
2021-08-19T12:25:58.119016590Z [2021-08-19 12:25:58 +0000] [9] [INFO] Starting gunicorn 20.1.0
2021-08-19T12:25:58.119171798Z [2021-08-19 12:25:58 +0000] [9] [INFO] Listening at: http://0.0.0.0:8888 (9)
2021-08-19T12:25:58.119183298Z [2021-08-19 12:25:58 +0000] [9] [INFO] Using worker: sync
2021-08-19T12:25:58.121077548Z [2021-08-19 12:25:58 +0000] [10] [INFO] Booting worker with pid: 10

Вроде бы порты прокинуты, expose тоже есть не понимаю почему тогда не работает

startup

python manage.py migrate
python manage.py migrate account

gunicorn config.wsgi:application --bind 0.0.0.0:8888

initial

psql postgres -h 0.0.0.0 -d postgres -f db.sql

python manage.py migrate
python manage.py migrate account
python manage.py migrate friendship 0001

Django db

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': 'postgres',
    'USER': 'postgres',
    'PASSWORD': '1',
    'HOST': 'db',
    'PORT': 5432
}}
Вернуться на верх