This directory contains all the client code.
The main website made using create-react-app
.
Redirect to https uri.
Redirect to palettehub.net.
Serve static react app build.
Reverse proxy to Spring Boot REST API.
Setting up the SSL certificates using the certbot for Let's Encrypt proved to be difficult due to the memory issues with docker. Additionally there were issues with the running the script scripts/init_letsencrypt.sh
so this tutorial will show the manual way while stop containers to save memory.
sudo bash scripts/start_prod.sh
sudo docker stop palette_hub_mysql && sudo docker stop palette_hub_rest_api && sudo docker stop palette_hub_client
sudo curl -o /var/lib/docker/volumes/palette_hub_certbot_conf_volume/_data/options-ssl-nginx.conf https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/certbot_nginx/_internal/tls_configs/options-ssl-nginx.conf
sudo curl -o /var/lib/docker/volumes/palette_hub_certbot_conf_volume/_data/ssl-dhparams.pem https://raw.githubusercontent.com/certbot/certbot/master/certbot/certbot/ssl-dhparams.pem
Check that the files are in the volume:
sudo ls /var/lib/docker/volumes/palette_hub_certbot_conf_volume/_data
You should see these two files:
options-ssl-nginx.conf
ssl-dhparams.pem
sudo docker exec -it palette_hub_certbot sh
mkdir -p /etc/letsencrypt/live/palettehub.net
openssl req -x509 -nodes -newkey rsa:4096 -days 1 -keyout /etc/letsencrypt/live/palettehub.net/privkey.pem -out /etc/letsencrypt/live/palettehub.net/fullchain.pem -subj '/CN=localhost'
exit
sudo ls /var/lib/docker/volumes/palette_hub_certbot_conf_volume/_data/live/palettehub.net
You should see these files:
fullchain.pem
privkey.pem
Now the nginx server should be able to run fine with the self signed cert
sudo docker restart palette_hub_mysql && sudo docker restart palette_hub_rest_api && sudo docker restart palette_hub_client
sudo docker ps
Look for palette_hub_client
The rest api is required for the nginx server to start but after it's stable you can stop it to save resources.
sudo docker stop palette_hub_mysql && sudo docker stop palette_hub_rest_api
sudo docker exec -it palette_hub_certbot sh
rm /etc/letsencrypt/live/palettehub.net/*
While still in the credbot shell:
certbot certonly --webroot -w /var/www/palettehub --email palettehub.net@gmail.com -d palettehub.net -d www.palettehub.net -d api.palettehub.net --rsa-key-size 4096 --agree-tos
sudo docker compose -f docker-compose.yaml -f docker-compose.prod.yaml down
sudo bash scripts/start_prod.sh