Dockerization, whitenoise serving static, refactor
This commit is contained in:
@@ -2,18 +2,9 @@
|
||||
```
|
||||
conda create -n matitos_urls python=3.12
|
||||
conda activate matitos_urls
|
||||
# Core
|
||||
pip install django==5.1 psycopg[binary] django-redis django-tasks-scheduler
|
||||
# Fetcher
|
||||
pip install feedparser python-dateutil newspaper4k[all] lxml[html_clean] googlenewsdecoder gnews duckduckgo_search GoogleNews langdetect
|
||||
# News visualization
|
||||
pip install ollama
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
* Database
|
||||
* Database initialization -> 1-DB.ipynb
|
||||
|
||||
|
||||
* From automated inspectdb
|
||||
```
|
||||
# 1) Inspect DB, generate models.py
|
||||
@@ -74,60 +65,19 @@ class Meta:
|
||||
db_table = 'urls' # db_table = '{}_urls'.format(project_name)
|
||||
```
|
||||
|
||||
* Database & initialization
|
||||
* Check initialize.sh on Dockerfile
|
||||
|
||||
* Environment variables
|
||||
```
|
||||
# Database
|
||||
DB_NAME=${DB_NAME:-matitos}
|
||||
DB_USER=${DB_NAME:-supermatitos}
|
||||
DB_PASSWORD=${DB_NAME:-supermatitos}
|
||||
DB_HOST=${DB_NAME:-localhost}
|
||||
DB_PORT=${DB_NAME:-5432}
|
||||
REDIS_HOST=${REDIS_HOST:-localhost}
|
||||
REDIS_PORT=${REDIS_PORT:-6379}
|
||||
|
||||
# Job timeout: 30 min
|
||||
JOB_DEFAULT_TIMEOUT=${RQ_DEFAULT_TIMEOUT:-1800}
|
||||
|
||||
# Logs path
|
||||
PATH_LOGS_PARAMETERIZATION="logs/log_app_fetcher_{}.log"
|
||||
|
||||
# Fetcher
|
||||
FETCHER_GNEWS_DECODE_SLEEP=2
|
||||
FETCHER_GOOGLE_GENERAL_PAGE_ITER_SLEEP=4
|
||||
FETCHER_BETWEEN_SEARCHES_SLEEP=5
|
||||
FETCHER_URL_HOST_SLEEP=5
|
||||
FETCHER_LANGUAGE_DETECTION_MIN_CHAR=100
|
||||
|
||||
SELENIUM_ENDPOINT="http://selenium_app:80"
|
||||
```
|
||||
* In docker-compose.yml
|
||||
|
||||
* Deploy
|
||||
```
|
||||
# Migrations
|
||||
python manage.py makemigrations api; python manage.py migrate --fake-initial
|
||||
# Create user
|
||||
python manage.py createsuperuser
|
||||
# Check environments variables on docker-compose.yml
|
||||
|
||||
# 1) Server
|
||||
python manage.py runserver
|
||||
# Remove previous instances
|
||||
docker compose down -v
|
||||
|
||||
# 2) Workers
|
||||
python manage.py rqworker high default low
|
||||
|
||||
# Visualize DB
|
||||
http://localhost:8080/?pgsql=matitos_db&username=supermatitos&db=matitos&ns=public&select=urls&order%5B0%5D=id
|
||||
# Build & up
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
* Scheduled tasks
|
||||
```
|
||||
# Import tasks
|
||||
python manage.py import --filename scheduled_tasks.json
|
||||
|
||||
# Modify using the admin panel, then save
|
||||
# python manage.py export > scheduled_tasks.json
|
||||
```
|
||||
|
||||
* Utils. TODO: To endpoint...
|
||||
```
|
||||
python manage.py rqstats
|
||||
```
|
||||
Reference in New Issue
Block a user