aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-09-12 19:51:06 +0100
committerMatthew Lemon <y@yulqen.org>2024-09-12 19:51:06 +0100
commitfc8383c528c47e6914557767be5723670c74008f (patch)
treeb6bc60348f58ad5b35657f1ecf50fe0826c24796
parentae414c59441bc985e3f8801f03e810443bc36253 (diff)
Fixes Docker files
-rw-r--r--Dockerfile4
-rw-r--r--docker-compose.yaml29
-rw-r--r--docker-entrypoint.sh2
-rw-r--r--production.yml73
-rw-r--r--pyproject.toml1
-rw-r--r--requirements.txt207
-rw-r--r--requirements/local.txt23
-rw-r--r--uv.lock14
8 files changed, 266 insertions, 87 deletions
diff --git a/Dockerfile b/Dockerfile
index e81a03c..35a1ffd 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -5,7 +5,7 @@ FROM docker.io/python:3.12.3-slim-bookworm as python
# Python build stage
FROM python as python-build-stage
-ARG BUILD_ENVIRONMENT=production
+ARG BUILD_ENVIRONMENT=requirements
# Install apt packages
RUN apt-get update && apt-get install --no-install-recommends -y \
@@ -15,7 +15,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
libpq-dev
# Requirements are installed here to ensure they will be cached.
-COPY ./requirements .
+COPY ./requirements.txt .
# Create Python Dependency and Sub-Dependency Wheels.
RUN pip wheel --wheel-dir /usr/src/app/wheels \
diff --git a/docker-compose.yaml b/docker-compose.yaml
index 7bcb207..ea05037 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -1,22 +1,31 @@
services:
+ db:
+ image: postgres:14
+ volumes:
+ - postgres_data:/var/lib/postgresql/data/
+ environment:
+ POSTGRES_DB: ${POSTGRES_DB}
+ POSTGRES_USER: ${POSTGRES_USER}
+ POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
+ networks:
+ - app-network
+
web:
build: .
command: gunicorn config.wsgi:application --bind 0.0.0.0:8000
volumes:
- - .:/app
+ - .:/code
ports:
- "3000:3000"
- env_file:
- - .env
depends_on:
- db
-
- db:
- image: postgres:14
- volumes:
- - postgres_data:/var/lib/postgresql/data/
- environment:
- - POSTGRES_PASSWORD=postgres
+ # env_file:
+ # - .env
+ networks:
+ - app-network
volumes:
postgres_data:
+
+networks:
+ app-network:
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
index 5e8164c..63bacb2 100644
--- a/docker-entrypoint.sh
+++ b/docker-entrypoint.sh
@@ -2,4 +2,4 @@
cd /app
python manage.py migrate
python manage.py collectstatic --noinput
-exec gunicorn --bind ':8080' --worker-tmp-dir /dev/shm --workers 3 config.wsgi:application
+exec gunicorn --bind ':3000' --worker-tmp-dir /dev/shm --workers 3 config.wsgi:application
diff --git a/production.yml b/production.yml
deleted file mode 100644
index 79e2636..0000000
--- a/production.yml
+++ /dev/null
@@ -1,73 +0,0 @@
-version: '3'
-
-volumes:
- production_postgres_data: {}
- production_postgres_data_backups: {}
- production_traefik: {}
-
-services:
- django: &django
- build:
- context: .
- dockerfile: ./compose/production/django/Dockerfile
-
- image: pyblackbird_cc_production_django
- depends_on:
- - postgres
- - redis
- env_file:
- - ./.envs/.production/.django
- - ./.envs/.production/.postgres
- command: /start
-
- postgres:
- build:
- context: .
- dockerfile: ./compose/production/postgres/Dockerfile
- image: pyblackbird_cc_production_postgres
- volumes:
- - production_postgres_data:/var/lib/postgresql/data
- - production_postgres_data_backups:/backups
- env_file:
- - ./.envs/.production/.postgres
-
- # traefik:
- # build:
- # context: .
- # dockerfile: ./compose/production/traefik/Dockerfile
- # image: pyblackbird_cc_production_traefik
- # depends_on:
- # - django
- # volumes:
- # - production_traefik:/etc/traefik/acme
- # ports:
- # - '0.0.0.0:80:80'
- # - '0.0.0.0:443:443'
- # - '0.0.0.0:5555:5555'
-
- redis:
- image: docker.io/redis:6
-
- celeryworker:
- <<: *django
- image: pyblackbird_cc_production_celeryworker
- command: /start-celeryworker
-
- celerybeat:
- <<: *django
- image: pyblackbird_cc_production_celerybeat
- command: /start-celerybeat
-
- flower:
- <<: *django
- image: pyblackbird_cc_production_flower
- command: /start-flower
-
- # awscli:
- # build:
- # context: .
- # dockerfile: ./compose/production/aws/Dockerfile
- # env_file:
- # - ./.envs/.production/.django
- # volumes:
- # - production_postgres_data_backups:/backups:z
diff --git a/pyproject.toml b/pyproject.toml
index b14017f..c35374b 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -24,6 +24,7 @@ dependencies = [
# Django
# ------------------------------------------------------------------------------
"django-storages==1.14.3",
+ "gunicorn==22.0.0",
"Django==5.0.4",
# pyup: < 5.0 # https://www.djangoproject.com/
"django-environ==0.11.2",
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..e69f1e6
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,207 @@
+# This file was autogenerated by uv via the following command:
+# uv pip compile pyproject.toml -o requirements.txt
+amqp==5.2.0
+ # via kombu
+anyio==4.4.0
+ # via watchfiles
+argon2-cffi==23.1.0
+ # via pyblackbird-cc (pyproject.toml)
+argon2-cffi-bindings==21.2.0
+ # via argon2-cffi
+asgiref==3.8.1
+ # via
+ # django
+ # django-stubs
+async-timeout==4.0.3
+ # via redis
+billiard==4.2.0
+ # via celery
+boto3==1.34.89
+ # via pyblackbird-cc (pyproject.toml)
+botocore==1.34.162
+ # via
+ # pyblackbird-cc (pyproject.toml)
+ # boto3
+ # s3transfer
+celery==5.4.0
+ # via
+ # pyblackbird-cc (pyproject.toml)
+ # django-celery-beat
+ # flower
+certifi==2024.8.30
+ # via requests
+cffi==1.17.1
+ # via argon2-cffi-bindings
+charset-normalizer==3.3.2
+ # via requests
+click==8.1.7
+ # via
+ # celery
+ # click-didyoumean
+ # click-plugins
+ # click-repl
+click-didyoumean==0.3.1
+ # via celery
+click-plugins==1.1.1
+ # via celery
+click-repl==0.3.0
+ # via celery
+crispy-bootstrap5==2024.2
+ # via pyblackbird-cc (pyproject.toml)
+cron-descriptor==1.4.5
+ # via django-celery-beat
+django==5.0.4
+ # via
+ # pyblackbird-cc (pyproject.toml)
+ # crispy-bootstrap5
+ # django-allauth
+ # django-celery-beat
+ # django-crispy-forms
+ # django-model-utils
+ # django-redis
+ # django-storages
+ # django-stubs
+ # django-stubs-ext
+ # django-timezone-field
+django-allauth==0.62.1
+ # via pyblackbird-cc (pyproject.toml)
+django-celery-beat==2.6.0
+ # via pyblackbird-cc (pyproject.toml)
+django-crispy-forms==2.1
+ # via
+ # pyblackbird-cc (pyproject.toml)
+ # crispy-bootstrap5
+django-environ==0.11.2
+ # via pyblackbird-cc (pyproject.toml)
+django-model-utils==4.5.1
+ # via pyblackbird-cc (pyproject.toml)
+django-redis==5.4.0
+ # via pyblackbird-cc (pyproject.toml)
+django-storages==1.14.3
+ # via pyblackbird-cc (pyproject.toml)
+django-stubs==5.0.4
+ # via pyblackbird-cc (pyproject.toml)
+django-stubs-ext==5.0.4
+ # via django-stubs
+django-timezone-field==7.0
+ # via django-celery-beat
+flower==2.0.1
+ # via pyblackbird-cc (pyproject.toml)
+gunicorn==22.0.0
+ # via pyblackbird-cc (pyproject.toml)
+hiredis==2.3.2
+ # via pyblackbird-cc (pyproject.toml)
+humanize==4.10.0
+ # via flower
+idna==3.8
+ # via
+ # anyio
+ # requests
+jmespath==1.0.1
+ # via
+ # boto3
+ # botocore
+kombu==5.4.1
+ # via celery
+markdown==3.6
+ # via pyblackbird-cc (pyproject.toml)
+markupsafe==2.1.5
+ # via werkzeug
+mypy==1.11.2
+ # via django-stubs
+mypy-extensions==1.0.0
+ # via mypy
+packaging==24.1
+ # via gunicorn
+pdf2image==1.17.0
+ # via pyblackbird-cc (pyproject.toml)
+pillow==10.3.0
+ # via
+ # pyblackbird-cc (pyproject.toml)
+ # pdf2image
+prometheus-client==0.20.0
+ # via flower
+prompt-toolkit==3.0.47
+ # via click-repl
+psycopg==3.1.19
+ # via pyblackbird-cc (pyproject.toml)
+psycopg-c==3.1.19
+ # via psycopg
+pycparser==2.22
+ # via cffi
+pypdf2==3.0.1
+ # via pyblackbird-cc (pyproject.toml)
+pypng==0.20220715.0
+ # via qrcode
+python-crontab==3.2.0
+ # via django-celery-beat
+python-dateutil==2.9.0.post0
+ # via
+ # botocore
+ # celery
+ # python-crontab
+python-dotenv==1.0.1
+ # via pyblackbird-cc (pyproject.toml)
+python-magic==0.4.27
+ # via pyblackbird-cc (pyproject.toml)
+python-slugify==8.0.4
+ # via pyblackbird-cc (pyproject.toml)
+pytz==2024.2
+ # via flower
+qrcode==7.4.2
+ # via django-allauth
+redis==5.0.4
+ # via
+ # pyblackbird-cc (pyproject.toml)
+ # django-redis
+requests==2.32.3
+ # via stripe
+s3transfer==0.10.2
+ # via boto3
+six==1.16.0
+ # via python-dateutil
+sniffio==1.3.1
+ # via anyio
+sqlparse==0.5.0
+ # via
+ # pyblackbird-cc (pyproject.toml)
+ # django
+stripe==10.10.0
+ # via pyblackbird-cc (pyproject.toml)
+text-unidecode==1.3
+ # via python-slugify
+tornado==6.4.1
+ # via flower
+types-pyyaml==6.0.12.20240808
+ # via django-stubs
+typing-extensions==4.12.2
+ # via
+ # django-stubs
+ # django-stubs-ext
+ # mypy
+ # psycopg
+ # qrcode
+ # stripe
+tzdata==2024.1
+ # via
+ # celery
+ # django-celery-beat
+urllib3==2.2.3
+ # via
+ # botocore
+ # requests
+vine==5.1.0
+ # via
+ # amqp
+ # celery
+ # kombu
+watchdog==5.0.2
+ # via werkzeug
+watchfiles==0.21.0
+ # via pyblackbird-cc (pyproject.toml)
+wcwidth==0.2.13
+ # via prompt-toolkit
+werkzeug==3.0.2
+ # via pyblackbird-cc (pyproject.toml)
+whitenoise==6.6.0
+ # via pyblackbird-cc (pyproject.toml)
diff --git a/requirements/local.txt b/requirements/local.txt
index a4557d6..d6a27d9 100644
--- a/requirements/local.txt
+++ b/requirements/local.txt
@@ -9,7 +9,9 @@ argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
# via argon2-cffi
asgiref==3.8.1
- # via django
+ # via
+ # django
+ # django-stubs
async-timeout==4.0.3
# via redis
billiard==4.2.0
@@ -58,6 +60,8 @@ django==5.0.4
# django-model-utils
# django-redis
# django-storages
+ # django-stubs
+ # django-stubs-ext
# django-timezone-field
django-allauth==0.62.1
# via pyblackbird-cc (pyproject.toml)
@@ -75,10 +79,16 @@ django-redis==5.4.0
# via pyblackbird-cc (pyproject.toml)
django-storages==1.14.3
# via pyblackbird-cc (pyproject.toml)
+django-stubs==5.0.4
+ # via pyblackbird-cc (pyproject.toml)
+django-stubs-ext==5.0.4
+ # via django-stubs
django-timezone-field==7.0
# via django-celery-beat
flower==2.0.1
# via pyblackbird-cc (pyproject.toml)
+gunicorn==22.0.0
+ # via pyblackbird-cc (pyproject.toml)
hiredis==2.3.2
# via pyblackbird-cc (pyproject.toml)
humanize==4.10.0
@@ -97,6 +107,12 @@ markdown==3.6
# via pyblackbird-cc (pyproject.toml)
markupsafe==2.1.5
# via werkzeug
+mypy==1.11.2
+ # via django-stubs
+mypy-extensions==1.0.0
+ # via mypy
+packaging==24.1
+ # via gunicorn
pdf2image==1.17.0
# via pyblackbird-cc (pyproject.toml)
pillow==10.3.0
@@ -156,8 +172,13 @@ text-unidecode==1.3
# via python-slugify
tornado==6.4.1
# via flower
+types-pyyaml==6.0.12.20240808
+ # via django-stubs
typing-extensions==4.12.2
# via
+ # django-stubs
+ # django-stubs-ext
+ # mypy
# psycopg
# qrcode
# stripe
diff --git a/uv.lock b/uv.lock
index c956107..54326ab 100644
--- a/uv.lock
+++ b/uv.lock
@@ -556,6 +556,18 @@ wheels = [
]
[[package]]
+name = "gunicorn"
+version = "22.0.0"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "packaging" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/1e/88/e2f93c5738a4c1f56a458fc7a5b1676fc31dcdbb182bef6b40a141c17d66/gunicorn-22.0.0.tar.gz", hash = "sha256:4a0b436239ff76fb33f11c07a16482c521a7e09c1ce3cc293c2330afe01bec63", size = 3639760 }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/29/97/6d610ae77b5633d24b69c2ff1ac3044e0e565ecbd1ec188f02c45073054c/gunicorn-22.0.0-py3-none-any.whl", hash = "sha256:350679f91b24062c86e386e198a15438d53a7a8207235a78ba1b53df4c4378d9", size = 84443 },
+]
+
+[[package]]
name = "hiredis"
version = "2.3.2"
source = { registry = "https://pypi.org/simple" }
@@ -850,6 +862,7 @@ dependencies = [
{ name = "django-storages" },
{ name = "django-stubs", extra = ["compatible-mypy"] },
{ name = "flower" },
+ { name = "gunicorn" },
{ name = "hiredis" },
{ name = "markdown" },
{ name = "pdf2image" },
@@ -896,6 +909,7 @@ requires-dist = [
{ name = "django-storages", specifier = "==1.14.3" },
{ name = "django-stubs", extras = ["compatible-mypy"], specifier = ">=5.0.4" },
{ name = "flower", specifier = "==2.0.1" },
+ { name = "gunicorn", specifier = "==22.0.0" },
{ name = "hiredis", specifier = "==2.3.2" },
{ name = "markdown", specifier = "==3.6.0" },
{ name = "pdf2image", specifier = "==1.17.0" },