diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..41301dc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.12-slim + +WORKDIR /app + +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc libpq-dev \ + && rm -rf /var/lib/apt/lists/* + +COPY requirements.txt . +RUN pip install uv && uv pip install --system -r requirements.txt + +COPY . . + +RUN mkdir -p /app/media /app/static + +EXPOSE 8000 + +CMD ["sh", "-c", "python manage.py makemigrations chat && python manage.py migrate --noinput && python manage.py init_admin && python manage.py collectstatic --noinput && daphne -b 0.0.0.0 -p 8000 core.asgi:application"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..bb76d0b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,37 @@ + +services: + db: + image: postgres:15-alpine + environment: + POSTGRES_DB: discord_db + POSTGRES_USER: discord_user + POSTGRES_PASSWORD: discord_pass + volumes: + - pgdata:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U discord_user -d discord_db"] + interval: 5s + timeout: 5s + retries: 5 + + web: + build: . + ports: + - "8000:8000" + environment: + SECRET_KEY: "poc-secret-key-not-for-production" + DEBUG: "True" + DB_NAME: discord_db + DB_USER: discord_user + DB_PASSWORD: discord_pass + DB_HOST: db + DB_PORT: "5432" + volumes: + - ./media:/app/media + - ./static:/app/static + depends_on: + db: + condition: service_healthy + +volumes: + pgdata: diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f93f992 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,8 @@ +Django==4.2.16 +channels==4.1.0 +channels-postgres>=1.1.4 +daphne==4.1.2 +djangorestframework==3.15.2 +psycopg2-binary==2.9.9 +Pillow==10.4.0 +python-decouple==3.8