ManiCandles/docs/STATIC-DEPLOYMENT.md

4.1 KiB

SSH deployment to server1

Drone validates the application and Nginx snippet, uploads dist and the release script, and activates the release through SSH. The sole deployment secret is manicandles_deploy_key. SSH uses mihir@server1.midastix.com:22.

One-time server setup

Server inspection on 19 November 2026 found an HTTP-only site at /etc/nginx/sites-enabled/ManiCandles.midastix.com.conf, with its old root at /var/www/ManiCandles.midastix.com. Certbot is installed. The setup script is specific to that configuration and refuses to overwrite a site with TLS settings.

Obtain this branch's files on server1 using your existing repository access. From the repository directory, run the following as mihir.

sudo sh scripts/setup-static-host.sh
sudo certbot --nginx -d manicandles.midastix.com --redirect
sudo nginx -t
curl --fail --show-error https://manicandles.midastix.com/

Alternatively, copy scripts/setup-static-host.sh and deploy/nginx-locations.conf together to /tmp/ on server1, and run sudo sh /tmp/setup-static-host.sh, followed by the Certbot and verification commands above. The snippet must be beside the setup script for this layout.

Setup backs up the original site under /var/backups, prepares writable release directories, installs the snippet, validates Nginx, and reloads it. Validation or reload failure restores the saved site file. If the old root contains an index, setup retains it as the initial current release and a rollback target. If no old index exists, the frontend awaits its first deployment. DNS must point to server1 and public port 80 must be reachable for certificate issuance. Complete Certbot's email and agreement prompts yourself. Verify HTTPS before merging.

Save the complete matching private key in Drone's manicandles_deploy_key secret. Its public key must be authorized for mihir on server1. Keep the private key outside the repository and logs.

Release and acceptance

After server setup, merge the change into main. Main-branch push builds perform an SSH access check before the quality gates. Feature branches validate the configuration, test rollback, and build the frontend without publishing a release.

Uploads first enter incoming/BUILD-COMMIT. A completed build moves to releases/BUILD-COMMIT/dist under the deployment lock. Retried uploads cannot overwrite a published release. A file lock serializes activation. An older build cannot replace a newer active build. The current symlink changes atomically. HTTPS checks use the real hostname resolved to loopback and verify the certificate, release marker, homepage, /workspace, /cart, and /api/v1/health/ready. Readiness must return the backend's {"status":"ok"} response. An HTML fallback fails verification. Failure restores the previous current symlink, or removes the first activation if no release existed before it. The last successful release is also retained at previous. Its assets can serve requests from browser tabs opened before the update. Failed first deployments leave the site awaiting a successful release.

After the main build succeeds, test externally from a trusted terminal.

curl --fail --show-error https://manicandles.midastix.com/release.txt
curl --fail --show-error https://manicandles.midastix.com/api/v1/health/ready

Then exercise authenticated UAT journeys. The frontend release does not provision an organization or user accounts.

Manual rollback

As mihir on server1, restore the preceding successful release under the same lock used by CI. Verify the marker and API after switching. Coordinate this with active pipelines because a later successful deployment can activate a new release.

(
  set -eu
  cd /var/www/manicandles
  flock -x 9
  test -s previous/index.html
  ln -s "$(readlink previous)" .rollback-current
  mv -Tf .rollback-current current
) 9>/var/www/manicandles/.deploy.lock
curl --fail --show-error https://manicandles.midastix.com/release.txt
curl --fail --show-error https://manicandles.midastix.com/api/v1/health/ready

Retain release directories until rollback has been verified. Disk retention is manual in this initial deployment flow.