mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 11:31:08 +00:00
commit
6fadf22a54
8 changed files with 124 additions and 12 deletions
22
.env.example
22
.env.example
|
@ -1,18 +1,26 @@
|
|||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
export SECRET_KEY="7(2w1sedok=aznpq)ta1mc4i%4h=xx@hxwx*o57ctsuml0x%fr"
|
||||
SECRET_KEY=7(2w1sedok=aznpq)ta1mc4i%4h=xx@hxwx*o57ctsuml0x%fr
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
export DEBUG=true
|
||||
DEBUG=true
|
||||
|
||||
export DOMAIN=your.domain.here
|
||||
DOMAIN=your.domain.here
|
||||
|
||||
## Leave unset to allow all hosts
|
||||
# export ALLOWED_HOSTS="localhost,127.0.0.1,[::1]"
|
||||
# ALLOWED_HOSTS="localhost,127.0.0.1,[::1]"
|
||||
|
||||
export OL_URL="https://openlibrary.org"
|
||||
OL_URL=https://openlibrary.org
|
||||
|
||||
## Database backend to use.
|
||||
## Default is postgres, sqlite is for dev quickstart only (NOT production!!!)
|
||||
export FEDIREADS_DATABASE_BACKEND=postgres
|
||||
FEDIREADS_DATABASE_BACKEND=postgres
|
||||
|
||||
export MEDIA_ROOT="images/"
|
||||
MEDIA_ROOT=images/
|
||||
|
||||
POSTGRES_PASSWORD=fedireads
|
||||
POSTGRES_USER=fedireads
|
||||
POSTGRES_DB=fedireads
|
||||
|
||||
RABBITMQ_DEFAULT_USER=rabbit
|
||||
RABBITMQ_DEFAULT_PASS=changeme
|
||||
CELERY_BROKER=amqp://rabbit:changeme@rabbitmq:5672
|
||||
|
|
7
Dockerfile
Normal file
7
Dockerfile
Normal file
|
@ -0,0 +1,7 @@
|
|||
FROM python:3
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
RUN mkdir /app
|
||||
WORKDIR /app
|
||||
COPY requirements.txt /app/
|
||||
RUN pip install -r requirements.txt
|
||||
COPY ./fedireads /app
|
11
README.md
11
README.md
|
@ -71,6 +71,17 @@ And go to the app at `localhost:8000`
|
|||
For most testing, you'll want to use ngrok. Remember to set the DOMAIN in `.env` to your ngrok domain.
|
||||
|
||||
|
||||
### Docker
|
||||
You can also run the application in a docker container. You'll have to install the Docker and docker-compose:
|
||||
|
||||
```bash
|
||||
docker-compose build
|
||||
docker-compose up
|
||||
docker-compose exec web python manage.py migrate
|
||||
docker-compose exec web python manage.py shell -c 'import init_db'
|
||||
```
|
||||
|
||||
|
||||
## Project structure
|
||||
All the url routing is in `fedireads/urls.py`. This includes the application views (your home page, user page, book page, etc), application endpoints (things that happen when you click buttons), and federation api endpoints (inboxes, outboxes, webfinger, etc).
|
||||
|
||||
|
|
46
docker-compose.yml
Normal file
46
docker-compose.yml
Normal file
|
@ -0,0 +1,46 @@
|
|||
version: '3'
|
||||
|
||||
services:
|
||||
db:
|
||||
image: postgres
|
||||
env_file: .env
|
||||
volumes:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
networks:
|
||||
- main
|
||||
web:
|
||||
build: .
|
||||
command: python manage.py runserver 0.0.0.0:8000
|
||||
volumes:
|
||||
- .:/app
|
||||
ports:
|
||||
- "8000:8000"
|
||||
depends_on:
|
||||
- db
|
||||
- celery_worker
|
||||
networks:
|
||||
- main
|
||||
rabbitmq:
|
||||
env_file: .env
|
||||
image: rabbitmq:latest
|
||||
networks:
|
||||
- main
|
||||
ports:
|
||||
- "5672:5672"
|
||||
restart: on-failure
|
||||
celery_worker:
|
||||
env_file: .env
|
||||
build: .
|
||||
networks:
|
||||
- main
|
||||
command: celery -A fedireads worker -l info
|
||||
volumes:
|
||||
- .:/app
|
||||
depends_on:
|
||||
- db
|
||||
- rabbitmq
|
||||
restart: on-failure
|
||||
volumes:
|
||||
pgdata:
|
||||
networks:
|
||||
main:
|
|
@ -0,0 +1,8 @@
|
|||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
# This will make sure the app is always imported when
|
||||
# Django starts so that shared_task will use this app.
|
||||
from .celery import app as celery_app
|
||||
|
||||
__all__ = ('celery_app',)
|
||||
|
24
fedireads/celery.py
Normal file
24
fedireads/celery.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
from celery import Celery
|
||||
|
||||
# set the default Django settings module for the 'celery' program.
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'fedireads.settings')
|
||||
|
||||
app = Celery('fedireads')
|
||||
|
||||
# Using a string here means the worker doesn't have to serialize
|
||||
# the configuration object to child processes.
|
||||
# - namespace='CELERY' means all celery-related configuration keys
|
||||
# should have a `CELERY_` prefix.
|
||||
app.config_from_object('django.conf:settings', namespace='CELERY')
|
||||
|
||||
# Load task modules from all registered Django app configs.
|
||||
app.autodiscover_tasks()
|
||||
|
||||
|
||||
@app.task(bind=True)
|
||||
def debug_task(self):
|
||||
print('Request: {0!r}'.format(self.request))
|
|
@ -17,11 +17,16 @@ SECRET_KEY = env('SECRET_KEY')
|
|||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = env.bool('DEBUG', True)
|
||||
|
||||
# TODO: annoying that I keep changing and re-commiting this
|
||||
DOMAIN = env('DOMAIN')
|
||||
ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', ['*'])
|
||||
OL_URL = env('OL_URL')
|
||||
|
||||
# celery/rebbitmq
|
||||
CELERY_BROKER_URL = env('CELERY_BROKER')
|
||||
CELERY_ACCEPT_CONTENT = ['json']
|
||||
CELERY_TASK_SERIALIZER = 'json'
|
||||
CELERY_RESULT_BACKEND = 'amqp'
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
|
@ -33,6 +38,7 @@ INSTALLED_APPS = [
|
|||
'django.contrib.staticfiles',
|
||||
'django.contrib.humanize',
|
||||
'fedireads',
|
||||
'celery',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
@ -75,10 +81,10 @@ FEDIREADS_DATABASE_BACKEND = env('FEDIREADS_DATABASE_BACKEND', 'postgres')
|
|||
FEDIREADS_DBS = {
|
||||
'postgres': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': 'fedireads',
|
||||
'USER': 'fedireads',
|
||||
'PASSWORD': 'fedireads',
|
||||
'HOST': '',
|
||||
'NAME': env('POSTGRES_DB', 'fedireads'),
|
||||
'USER': env('POSTGRES_USER', 'fedireads'),
|
||||
'PASSWORD': env('POSTGRES_PASSWORD', 'fedireads'),
|
||||
'HOST': 'db',
|
||||
'PORT': 5432
|
||||
},
|
||||
'sqlite': {
|
||||
|
@ -91,6 +97,7 @@ DATABASES = {
|
|||
'default': FEDIREADS_DBS[FEDIREADS_DATABASE_BACKEND]
|
||||
}
|
||||
|
||||
|
||||
LOGIN_URL = '/login/'
|
||||
AUTH_USER_MODEL = 'fedireads.User'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
celery==4.4.2
|
||||
Django==3.0.3
|
||||
django-model-utils==4.0.0
|
||||
environs==7.2.0
|
||||
|
|
Loading…
Reference in a new issue