This folder is used by .github/workflows/node-api-cicd.yml.
Install:
- Docker Engine + Docker Compose plugin (
docker compose) - AWS CLI v2
Create deploy directory (default used by workflow):
sudo mkdir -p /opt/node-express-api
sudo chown -R $USER:$USER /opt/node-express-apiRequired:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_REGIONECR_REPOSITORY(example:node-express-api)VPS_HOSTVPS_USERVPS_SSH_KEY(private key content for SSH)APP_ENV_B64(base64-encoded full.envfile content used by the API/DB containers)
Optional:
VPS_PORT(default:22)VPS_DEPLOY_PATH(default:/opt/node-express-api)
Build APP_ENV_B64 from deploy/.env.vps.example (or your own .env):
Linux/macOS:
base64 -w 0 .envPowerShell:
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes((Get-Content -Raw .env)))On push to main (or manual run):
- Install dependencies and build TypeScript.
- Build Docker image and push to ECR (
<sha7>+latesttags). - SSH into VPS.
- Create/update
.envon VPS fromAPP_ENV_B64. - Login to ECR from VPS.
- Pull the new image, run Prisma migrations, and restart API container.