Function Words in Philippine Languages. Stack: Django, PostgreSQL. Now production ready with Gunicorn and Nginx.
- Make sure you have Docker and Make installed.
- Run the following commands:
# Build and start the application
make build
make up
# Or start in detached mode (e.g., in production)
make up-d
Then http://localhost
should now work, but without any "design" because static files like CSS are not loaded yet.
- Have another terminal tab/window, then run the following commands:
make makemigrations-fwapp # run this once only. afterwards, run 'make makemigrations' instead.
make migrate
make static
# replace "funcwords" with the name of directory where this is located
docker exec -i funcwords-db-1 psql -U user0 -d Function_Words < ./other/fwphl_triggers.sql
docker exec -i funcwords-db-1 psql -U user0 -d Function_Words < ./other/tagalog_personal_pronouns.sql # initial data
Note that the "funcwords" in funcwords-db-1
is the name of the directory of this repo, thus change this appropriately if the directory name is different.
- Grind to have some money (😫) to buy a VPS (ideally Ubuntu with Docker installed) and a domain. Then follow the steps provided by the VPS provider to connect the two.
- Modify
.env
with secure values. SetDEBUG
to False andDJANGO_ALLOWED_HOSTS
to your domain with dot in the beginning, like.example.com
. Replace every instance ofexample.com
in this repo with your domain. - Uncomment the
.env
in.gitignore
. Do NOT upload prod environment variables anywhere! - (Update: I now prefer pulling from Github.) Copy files from local to VPS using rsync:
rsync -avz . root@<VPS IP address>:~/the-app --exclude .git/
This assumes that the current directory of terminal is this repo. Note that the-app
directory will be created in the home directory (~) of the user (root in the case of the command above) in VPS, and the files will be copied to that directory.
- SSH to your VPS:
ssh root@<VPS IP address>
. After login, you'll be in home directory. Go tothe-app
directory and do the Docker setup above. Website should now be up! But it's in HTTP. - HTTP Secure (HTTPS) configuration in
docker-compose.yml
,settings.py
, andnginx.conf
are commented. Follow this to create SSL certificate except do
sudo certbot certonly --webroot -w /var/www/certbot/ -d example.com
for getting the certificate. Through webroot, certbot can automatically renew without needing to stop containers.
Update: I now prefer this setup, with changes before and during Step 5.
- We provide a Makefile for common commands for development.
- Docker shell:
make shell
- Django shell:
make django-shell
- PostgreSQL command line:
docker exec -it funcwords-db-1 psql -d Function_Words -U user0
- Want to run Python scripts "from outside" (e.g., to insert data)? Here is a tutorial.
Distributed under the MIT software license. See the accompanying file LICENSE or https://opensource.org/license/mit/.