The image above shows the setup that was used for HackTJ 7.5
HackTJ Live 1.0.0 was deployed for HackTJ 7.5 in a VM using Docker Compose V2 and a system-wide (inside the VM) NGINX server. The VM had 8GB RAM and 50GB storage.
Thanks for using HackTJ Live for your event! Here's a quick guide to running Live on your server. This guide assumes you're using Ubuntu (which the initial Live production instance was run on); feel free to substitute the appropriate commands if you're on a different operating system (Debian, RHEL, SLES, et cetera).
- Nginx (
apt install nginx) - Docker (
apt install docker.io) - Docker Compose (https://docs.docker.com/compose/cli-command/#install-on-linux)
- Git (
apt install git)
- Clone the Live repository and enter the directory:
git clone https://github.com/HackTJ/live ~/live && cd ~/live - Prepare the secrets files. (two options)
docker compose exec django poetry run python manage.py createsecrets- manually create the files
- copy the template:
cp ./compose/secrets/development/*.txt ./compose/secrets/production - update the secrets. All files in the
./compose/secretsdirectory are configurable. You can generate secrets using something likecat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1
- copy the template:
- Spin up the instance:
./start_live prodand grab a cup of coffee or something as the system initializes. Once that's all started, the next step is to set up the webserver.
- Create a file at
/etc/nginx/sites-available/hacktj-live.conf. The server configuration is similar to a standard HTTPS webserver config, but with one crucial difference. Add the below snippet to ensure Nginx can talk with Django:
location / {
try_files $uri @proxy_to_app;
}
location @proxy_to_app {
proxy_pass http://hacktj_live;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
}-
If you already had a default
locationblock in your Nginx config, get rid of that so it doesn't get confused. -
Set up HTTPS as needed (certs, etc.) in the Nginx configuration.
-
Symlink this config to the
sites-enabledfolder:ln -s hacktj-live.conf ../sites-enabled -
Delete the default Nginx page:
rm ../sites-enabled/default. -
Refresh the webserver:
systemctl reload nginx
If everything is configured correctly, you should be able to access Live!
This step is optional and only applies if you would like to populate your database with initial data.
- If you have a data file in the appropriate format that you'd like to add to Live, upload it to
~/live/judge/fixtures. You can create a JSON fixture file from a Devpost CSV export using thepoetry run python manage.py preparedevpostcommand. - Populate the database:
docker compose exec django poetry run python manage.py loaddata 'my-data', replacingmy-datawith the name of your data file (sans the file extension).