mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-09-08 03:07:14 +02:00
feat(bookwyrm): production-ready runtime + Redis wiring
- Dockerfile: build & install gunicorn wheels - compose: run initdb before start; use `python -m gunicorn` - env: add POSTGRES_* and BookWyrm Redis aliases (BROKER/ACTIVITY/CACHE) + CACHE_URL - vars: add cache URL, DB indices, and URL aliases for Redis Ref: https://chatgpt.com/share/68b7492b-3200-800f-80c4-295bc3233d68
This commit is contained in:
@@ -12,7 +12,8 @@ RUN git clone --depth=1 --branch "{{ BOOKWYRM_VERSION }}" https://github.com/boo
|
||||
|
||||
# Pre-install Python deps to a wheelhouse for faster final image
|
||||
RUN pip install --upgrade pip \
|
||||
&& pip wheel --wheel-dir /wheels -r requirements.txt
|
||||
&& pip wheel --wheel-dir /wheels -r requirements.txt \
|
||||
&& pip wheel --wheel-dir /wheels gunicorn
|
||||
|
||||
FROM python:3.11-bookworm
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
@@ -28,6 +29,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libjpeg62-turbo zlib1g libxml2 libxslt1.1 libffi8 libmagic1 \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& pip install --no-cache-dir --no-index --find-links=/wheels -r /app/requirements.txt \
|
||||
&& pip install --no-cache-dir --no-index --find-links=/wheels gunicorn \
|
||||
&& adduser --disabled-password --gecos '' bookwyrm \
|
||||
&& mkdir -p /app/data /app/media \
|
||||
&& chown -R bookwyrm:bookwyrm /app
|
||||
|
@@ -6,7 +6,8 @@
|
||||
bash -lc '
|
||||
python manage.py migrate --noinput &&
|
||||
python manage.py collectstatic --noinput &&
|
||||
gunicorn bookwyrm.wsgi:application --bind 0.0.0.0:{{ container_port }}
|
||||
(python manage.py initdb || true) &&
|
||||
python -m gunicorn bookwyrm.wsgi:application --bind 0.0.0.0:{{ container_port }}
|
||||
'
|
||||
build:
|
||||
context: .
|
||||
|
@@ -22,17 +22,39 @@ EMAIL_HOST_PASSWORD="{{ EMAIL_HOST_PASSWORD }}"
|
||||
DEFAULT_FROM_EMAIL="{{ EMAIL_DEFAULT_FROM }}"
|
||||
|
||||
# Database
|
||||
POSTGRES_DB="{{ database_name }}"
|
||||
POSTGRES_USER="{{ database_username }}"
|
||||
POSTGRES_PASSWORD="{{ database_password }}"
|
||||
POSTGRES_HOST="{{ database_host }}"
|
||||
POSTGRES_PORT="{{ database_port }}"
|
||||
DATABASE_URL="postgres://{{ database_username }}:{{ database_password }}@{{ database_host }}:{{ database_port }}/{{ database_name }}"
|
||||
|
||||
# Redis / Celery
|
||||
REDIS_HOST="{{ BOOKWYRM_REDIS_HOST }}"
|
||||
REDIS_PORT="{{ BOOKWYRM_REDIS_PORT }}"
|
||||
REDIS_URL="{{ BOOKWYRM_REDIS_CACHE_URL }}"
|
||||
REDIS_CACHE_URL="{{ BOOKWYRM_REDIS_CACHE_URL }}"
|
||||
CACHE_URL="{{ BOOKWYRM_REDIS_CACHE_URL }}"
|
||||
DJANGO_REDIS_URL="{{ BOOKWYRM_REDIS_CACHE_URL }}"
|
||||
|
||||
## Broker
|
||||
BROKER_URL="{{ BOOKWYRM_BROKER_URL }}"
|
||||
REDIS_BROKER_URL="{{ BOOKWYRM_REDIS_BROKER_URL }}"
|
||||
REDIS_CACHE_URL="{{ BOOKWYRM_REDIS_BASE_URL }}/1"
|
||||
REDIS_BROKER_HOST="{{ BOOKWYRM_REDIS_HOST }}"
|
||||
REDIS_BROKER_PORT="{{ BOOKWYRM_REDIS_PORT }}"
|
||||
REDIS_BROKER_DB_INDEX="{{ BOOKWYRM_REDIS_BROKER_DB }}"
|
||||
CELERY_BROKER_URL="{{ BOOKWYRM_REDIS_BROKER_URL }}"
|
||||
|
||||
## Activity
|
||||
REDIS_ACTIVITY_HOST="{{ BOOKWYRM_REDIS_HOST }}"
|
||||
REDIS_ACTIVITY_PORT="{{ BOOKWYRM_REDIS_PORT }}"
|
||||
REDIS_ACTIVITY_DB_INDEX="{{ BOOKWYRM_REDIS_ACTIVITY_DB }}"
|
||||
REDIS_ACTIVITY_URL="{{ BOOKWYRM_REDIS_ACTIVITY_URL }}"
|
||||
|
||||
# Proxy (if BookWyrm sits behind reverse proxy)
|
||||
FORWARDED_ALLOW_IPS="*"
|
||||
USE_X_FORWARDED_HOST="true"
|
||||
SECURE_PROXY_SSL_HEADER="HTTP_X_FORWARDED_PROTO,{{ WEB_PROTOCOL }}"
|
||||
SECURE_PROXY_SSL_HEADER="{{ (WEB_PORT == 443) | string | lower }}"
|
||||
|
||||
# OIDC (optional – only if BOOKWYRM_OIDC_ENABLED)
|
||||
{% if BOOKWYRM_OIDC_ENABLED %}
|
||||
|
@@ -45,6 +45,12 @@ BOOKWYRM_REDIS_HOST: "redis"
|
||||
BOOKWYRM_REDIS_PORT: 6379
|
||||
BOOKWYRM_REDIS_BASE_URL: "redis://{{ BOOKWYRM_REDIS_HOST }}:{{ BOOKWYRM_REDIS_PORT }}"
|
||||
BOOKWYRM_REDIS_BROKER_URL: "{{ BOOKWYRM_REDIS_BASE_URL }}/0"
|
||||
BOOKWYRM_REDIS_CACHE_URL: "{{ BOOKWYRM_REDIS_BASE_URL }}/1"
|
||||
BOOKWYRM_REDIS_BROKER_DB: 0
|
||||
BOOKWYRM_REDIS_ACTIVITY_DB: 1
|
||||
BOOKWYRM_BROKER_URL: "{{ BOOKWYRM_REDIS_BROKER_URL }}"
|
||||
BOOKWYRM_REDIS_ACTIVITY_URL: "{{ BOOKWYRM_REDIS_CACHE_URL }}"
|
||||
#BOOKWYRM_CACHE_URL: "{{ BOOKWYRM_REDIS_CACHE_URL }}"
|
||||
|
||||
# Email
|
||||
EMAIL_HOST: "{{ SYSTEM_EMAIL.HOST }}"
|
||||
|
Reference in New Issue
Block a user