Publication management system for your lab.
- docker
- docker-compose
- (poetry)
Here, let's install PubZ app for development environemnt. For production use, see ./deploy.
Make PubZ/.env
and PubZ/deploy/.env
.
Example:
MYSQL_ROOT_PASSWORD=mJKB26xRuY
MYSQL_DATABASE=docker
MYSQL_USER=docker
MYSQL_PASSWORD=ipTVFzI5Hx
DJANGO_SECRET_KEY="a10^j@6^2q$y*c&ks29$gnb7*3eodvqp!4!$7h31mlsq0ad3+s"
VIRTUAL_HOST="pubz.example.com"
WARNING: Please change secret key by yorself for production mode. To generate own key, check here.
# Generate Secret Key
from django.core.management.utils import get_random_secret_key
secret_key = get_random_secret_key()
text = 'SECRET_KEY = \'{0}\''.format(secret_key)
print(text)
Move to the directory which docker-compose.yml
exists and issue these commands
# Create Storage Directory
mkdir -p ./storage/db/data
# Create docker image with make command
cd docker/django
make build
# Start containers
cd ../../
docker-compose up
Then, you get 3 containers db, phpmyadmin, django, (storage)
and each containers are connected each others.
For starting django App, you need to initalize database (this system use mysql
). Issue these commands,
# Enter into the django container
docker-compose exec django bash
# == In django container ==
# Migrate database
python manage.py migrate
# Create Super User
python manage.py createsuperuser
# Migrate Bibtex models
python manage.py makemigrations core
python manage.py migrate
# Collect static files (e.g., js, css)
python manage.py collectstatic
For development, use Username=root, email=test@test.com, pw=password (pwBman88)
After these commands, please restart all the conatiners.
Django application:
# == In django container ==
cd /code
bash run
PubZ docs (dev server):
# == In django container ==
$ cd /root/docs/mkdocs
$ mkdocs serve
With this setup, we launched 3 containers. You can access to 3 of them with your browser.
App | URL |
---|---|
Django | http://localhost:7000 |
phpmyadmin | http://localhost:7070 |
docs | http://localhost:7777 |
# Create Image with make command
cd docker/django-uwsgi-nginx/
make build
# Start containers
cd ../../
docker-compose -f docker-compose-prd.yaml up -d
App | Container Name | Port (External) |
---|---|---|
Django | pubz-web-prd | 8000 |
MarinaDB | pubz-db-prd | 3306 |