- Create a deploy user
sudo useradd -m -s /bin/bash deploy
# copy ssh keys
rsync --archive --chown=deploy:deploy ~/.ssh /home/deploy/.ssh- Install docker
- Install nginx
- Run
deploy-setup.sh <domain>on the server to setup the deploy user and nginx
What the script does:
- Creates app directory (/opt/paddle-game)
- Sets up database
- Creates docker-compose.yml
- Starts postgres
- Creates systemd services
- paddle-game.server.service for the go server
- paddle-game.client.service for the client
- Creates nginx config (/etc/nginx/sites-available/)
- Enables services
- Creates sudoers file (/etc/sudoers.d/deploy) to allow restarting services
What needs to be done manually:
-
Create an origin server certificate on cloudflare and create these files:
- /etc/ssl/cloudflare/paddle.crt - contains the certificate
- /etc/ssl/cloudflare/paddle.key - contains the private key
-
Place env variables in:
- /opt/paddle-game/shared/server.env
- /opt/paddle-game/shared/client.env
- Run
deploy.sh <project_dir> <server_ip>locally to deploy the project
What the script does:
- Builds the server and client locally
- Copies the server binary to the deploy user
- Copies the client build to the deploy user
- Swaps the current release with the new one
- Migrates the database using the src/db/migrator.bin
- Cleans up old releases (keeps the last 6)