#!/usr/bin/env bash # PNA Assistant — EC2 deploy script # Run once on a fresh Ubuntu 22.04 t3.small in eu-west-2 # Usage: bash deploy-ec2.sh set -euo pipefail DOMAIN="pna.nursingcitizendevelopment.com" REPO="https://github.com/Clinical-Quality-Artifical-Intelligence/Professional-Nurse-Advocate-Assistant" EMAIL="lincoln@clinyqai.com" echo "=== 1. System packages ===" sudo apt-get update -y sudo apt-get install -y docker.io docker-compose-plugin curl certbot git unzip sudo systemctl enable docker --now sudo usermod -aG docker "$USER" echo "=== 2. Clone repo ===" cd /home/"$USER" git clone "$REPO" pna-assistant cd pna-assistant echo "=== 3. Create .env ===" cat > .env <<'ENV' STRIPE_PRO_LINK=https://buy.stripe.com/14A28t0P99Qmdph8v68og00 STRIPE_INSTITUTION=https://buy.stripe.com/9B63cxfK3d2y3OHbHi8og01 STRIPE_WEBHOOK_SECRET=whsec_REPLACE_AFTER_STRIPE_WEBHOOK_SETUP AWS_REGION=eu-west-2 SES_FROM_EMAIL=lincoln@clinyqai.com ENV chmod 600 .env echo "=== 4. Copy A-EQUIP guide ===" mkdir -p assets # Paste your guide file here, or scp it separately: # scp "Professional nurse advocate A-EQUIP model Guide.md" ubuntu@:/home/ubuntu/pna-assistant/assets/aequip_guide.md echo " >> Remember to copy aequip_guide.md into assets/ before starting!" echo "=== 5. Get SSL cert (stop port 80 first if running) ===" sudo certbot certonly --standalone \ -d "$DOMAIN" \ --email "$EMAIL" \ --agree-tos \ --non-interactive echo "=== 6. Start services ===" # Run as current user (already in docker group after re-login) # If first run, you may need: newgrp docker && docker compose up -d docker compose up -d echo "" echo "======================================" echo " PNA Assistant deployed!" echo " App: https://$DOMAIN" echo " Webhook: https://$DOMAIN/webhook" echo "======================================" echo "" echo "Next: set up Stripe webhook endpoint:" echo " URL: https://$DOMAIN/webhook" echo " Event: checkout.session.completed" echo " Copy the signing secret → update .env → docker compose restart pna-webhook"