Skip to content

Commit

Permalink
Merge pull request #9 from CentreForDigitalHumanities/feature/deploy
Browse files Browse the repository at this point in the history
Add changes for deployment
  • Loading branch information
ar-jan authored Nov 30, 2023
2 parents 7357f5b + 3396c4e commit 63f6699
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 10 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ jobs:
ruff --output-format=github --target-version=py38 .
- name: Test with pytest
run: |
cp lidiabrowser/lidiabrowser/.env.dist lidiabrowser/lidiabrowser/.env
cp .env.dist .env
pytest lidiabrowser
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
*.sqlite3
__pycache__/
.python-version
htdocs/
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Install the dependencies:

pip install -r requirements.txt

Create a file `lidiabrowser/lidiabrowser/.env` with your Zotero library and authentication details:
Create a file `.env` in the repository root with your Zotero library and authentication details:

```sh
ZOTERO_LIBRARY_ID=12345
Expand All @@ -29,5 +29,7 @@ To run on a local machine, use:
cd lidiabrowser
python manage.py migrate
python manage.py runserver
python manage.py sync
python manage.py populate
```

20 changes: 15 additions & 5 deletions lidiabrowser/lidiabrowser/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,37 @@
https://docs.djangoproject.com/en/4.2/ref/settings/
"""

import os
from pathlib import Path
import environ

root = environ.Path(__file__)
env = environ.Env()
environ.Env.read_env()
env = environ.Env(
# Set casting, default value
# Defaults are for local development; set server config in .env
SECRET_KEY=(str, 'BmM7FkllTHs_5Q0nsdalUDUlV0Q-B5Pl5uVxwRQSr_E'),
DEBUG=(bool, True),
ALLOWED_HOSTS=(list, []),
STATIC_ROOT=(str, '../htdocs')
)

SITE_ROOT = root()

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

environ.Env.read_env(os.path.join(BASE_DIR.parent, '.env'))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-m8_b*$)+y4!o3%-=$xf2kpiu6cqd16&0bekmw94^hfucpjzja&"
SECRET_KEY = env.str('SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = env.bool('DEBUG')

ALLOWED_HOSTS = []
ALLOWED_HOSTS = env.list('ALLOWED_HOSTS')


# Application definition
Expand Down Expand Up @@ -143,6 +151,8 @@

STATIC_URL = "static/"

STATIC_ROOT = env.str('STATIC_ROOT')

# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

Expand Down
20 changes: 20 additions & 0 deletions lidiabrowser/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
RSLab Django WSGI config for the lidiabrowser application.
It exposes the WSGI callable as a module-level variable named ``application``.
Since this Django-only setup does not use our default Cookiecutter workflow,
this root-level wsgi file is included to facilitate our deployment script.
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lidiabrowser.settings")

try:
application = get_wsgi_application()
except Exception as e:
# Ends up in Apache logs
print(e)
8 changes: 5 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile requirements.in
# pip-compile
#
asgiref==3.7.2
# via django
Expand All @@ -18,7 +18,7 @@ django-environ==0.11.2
# via -r requirements.in
feedparser==6.0.10
# via pyzotero
idna==3.4
idna==3.6
# via requests
iso639-lang==2.2.1
# via -r requirements.in
Expand All @@ -38,5 +38,7 @@ sgmllib3k==1.0.0
# via feedparser
sqlparse==0.4.4
# via django
typing-extensions==4.8.0
# via asgiref
urllib3==2.1.0
# via requests

0 comments on commit 63f6699

Please sign in to comment.