Game Crisis (gamecrisis
) is a web application that helps gamers find their next favorite game! There are so many amazing video games, tabletop games, RPG rule sets, etc. being released and updated every day that it's nearly impossible to keep up. You can read as many reviews as you like, but you won't be able to tell whether part or all of it will truly click with you.
The application is written in Python and Django, with a more advanced React UI coming soon.
- Create a Digital Ocean droplet using the
Django
template and SSH asroot
(or if you find it easier, you can use their web console to emulate an SSH terminal, it works fairly well).- Configure your domain through your registrar, adding an A record pointing to your Digital Ocean Droplet's public IP.
- Go through the Django template's instructions, including setting up SSL with certbot.
nano /etc/nginx/sites-available/default
, update:- Set
server_name
toyourdomain.tld www.yourdomain.tld
- Change the alias under
location /static
toalias /home/django/django_project/django_project/staticfiles;
. This is due to the usage ofcollectstatic
(documented under "Deploying to Production") - Change the alias under
location /static/admin
to/home/django/django_project/django_project/staticfiles/admin;
- Set
nano /root/.digitalocean_passwords
, update the values of:DJANGO_POSTGRES_PASS
: Set this to the same as theDB_PASSWORD
you will set up in/home/django/.profile
later in the document, under Deploying to Production.SECRET_KEY
andDJANGO_SECRET_KEY
: Generate a secure string, 32 characters or longer.
nano ~/.bashrc
. Add the aliasesalias restartgu='PID=$(systemctl show --value -p MainPID gunicorn.service) && kill -HUP $PID'
andalias restartng='systemctl restart nginx.service'
, which allow you to conveniently restart gunicorn and nginx, respectively.
- Copy
docker-compose.yml.example
todocker-compose.yml
and setPOSTGRES_PASSWORD
- Copy
.env.example
to.env
and fill in your values - In the root dir:
docker compose up -d
: starts Postgres (you must have Docker Desktop installed)pip install -r requirements.txt
: Installs required librariespython manage.py migrate
: Runs DB Migrationspython manage.py createsuperuser
: Make sure to fill out and record the infopython manage.py runserver
: Starts the Dev server.
- Go to the app at http://localhost:8000 and the admin at http://localhost:8000/admin, where you can log in with the admin user from
createsuperuser
- Whenever you change dependencies in
requirements.txt
, runpip install -r requirements.txt
- Edit
/home/django/.profile
if needed and set production values for the same environment variables as found in.env
, but withexport
in front of it e.g.export DB_NAME=django
python manage.py collectstatic
. This gathers up static files from the project, including those from packages like the Django Admin, for deployment to production. Seesettings.py
and referenceSTATICFILES_DIRS
andSTATIC_ROOT
to see how this is configured.chown -R django:django /home/django/django_project/
andchmod -R 755 /home/django/django_project/
- If you're having issues uploading or changing files via SFTP, re-run this.
- SFTP to
/home/django/django_project
on your Digital Ocean Droplet and upload relevant files. - Whenever you change dependencies in
requirements.txt
, runpip install -r requirements.txt
- Restart gunicorn whenever you change code:
restartgu
orPID=$(systemctl show --value -p MainPID gunicorn.service) && kill -HUP $PID
- Restart nginx whenever you change its config:
restartng
orsystemctl restart nginx.service