New database should be created with WIN1252 encoding. Migrating to a new server should clone latest stored data from the previous server.
Clone locally the repository and install all dependencies (described in frontend/README.md).
Run npm run build
and move build directory to a server e.g. using
scp -r frontend/build/* SERVER_USERNAME@SERVER_ADDRESS:SERVER_PATH_TO_FRONTEND
psql -U DB_USER -d DB_NAME
\i backend/db/create_script.txt
\i backend/db/gen_script.txt
Add nginx configuration to /etc/nginx/sites-available and link the file into /etc/nginx/sites-enabled.
# Nginx configuration server { # SSL configuration listen PORT_NUMBER ssl; listen [::]:PORT_NUMBER ssl; ssl_certificate PATH/fullchain.pem; ssl_certificate_key PATH/privkey.pem; root PATH_TO_FRONTEND_BUILD; index index.html index.htm index.nginx-debian.html; server_name HTTP_ADDRESS_OR_IP; # Frontend routing location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri /index.html $uri/ =404; } # API (backend) routing location /api/ { proxy_pass http://localhost:API_PORT_NUMBER; } }
gunicorn3 -b 0.0.0.0:API_PORT_NUMBER app:app
to safely start the backend code.Ideally, run the gunicorn3 WSGI server automatically in the background e.g. using sh script:
#!/bin/bash APP_PATH=PATH_TO_BACKEND_DIR export DB_HOST=... export DB_NAME=... export DB_USER=... export DB_PASS=... exec PATH_TO_GUNICORN --chdir ${APP_PATH} app:app -b 0.0.0.0:API_PORT_NUMBER
Reload the nginx service nginx reload
and test if the web app is publicly available.
certbot --nginx
util.This repository is continuation of a project that has been developed during winter semester of 2021/22 as school project.
Original repository can be found here.