Cloud Deployment
Deploy your Ever Works directory website to various cloud providers.
AWS Deployment
Using AWS Amplify
-
Connect Repository
# Install Amplify CLI
npm install -g @aws-amplify/cli
# Initialize Amplify
amplify init -
Configure Build Settings
# amplify.yml
version: 1
frontend:
phases:
preBuild:
commands:
- cd website
- npm install
build:
commands:
- npm run build
artifacts:
baseDirectory: website/.next
files:
- '**/*'
Using EC2
Deploy on EC2 instances:
# Install Node.js and PM2
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm install -g pm2
# Clone and setup
git clone https://github.com/ever-works/directory-web-template.git
cd directory-web-template/website
npm install
npm run build
# Start with PM2
pm2 start npm --name "ever-works" -- start
pm2 startup
pm2 save
Google Cloud Platform
Using Cloud Run
-
Create Dockerfile
FROM node:18-alpine
WORKDIR /app
COPY website/package*.json ./
RUN npm install
COPY website/ ./
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"] -
Deploy to Cloud Run
# Build and push to Container Registry
gcloud builds submit --tag gcr.io/PROJECT_ID/ever-works
# Deploy to Cloud Run
gcloud run deploy ever-works \
--image gcr.io/PROJECT_ID/ever-works \
--platform managed \
--region us-central1 \
--allow-unauthenticated
Microsoft Azure
Using Azure Static Web Apps
-
GitHub Actions Workflow
# .github/workflows/azure-static-web-apps.yml
name: Azure Static Web Apps CI/CD
on:
push:
branches: [main]
jobs:
build_and_deploy_job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build And Deploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: 'upload'
app_location: '/website'
output_location: '.next'
DigitalOcean
Using App Platform
-
Create App Spec
# .do/app.yaml
name: ever-works
services:
- name: web
source_dir: /website
github:
repo: your-username/directory-web-template
branch: main
run_command: npm start
build_command: npm run build
environment_slug: node-js
instance_count: 1
instance_size_slug: basic-xxs
envs:
- key: NODE_ENV
value: production -
Deploy
# Using doctl CLI
doctl apps create --spec .do/app.yaml
Environment Configuration
Common Environment Variables
# Application
NODE_ENV=production
NEXT_PUBLIC_API_BASE_URL=https://your-api.com
# Database
DATABASE_URL=your-database-connection-string
# Authentication
NEXTAUTH_SECRET=your-secret-key
NEXTAUTH_URL=https://your-domain.com
# OAuth Providers
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
Security Considerations
-
Secrets Management
- Use cloud provider secret managers
- Never commit secrets to version control
- Rotate secrets regularly
-
Network Security
- Configure firewalls and security groups
- Use HTTPS/TLS certificates
- Enable DDoS protection
-
Access Control
- Implement proper IAM policies
- Use least privilege principle
- Enable audit logging
Monitoring and Scaling
Health Checks
Implement health check endpoints:
// pages/api/health.js
export default function handler(req, res) {
res.status(200).json({
status: 'healthy',
timestamp: new Date().toISOString()
});
}
Auto Scaling
Configure auto-scaling based on:
- CPU utilization
- Memory usage
- Request count
- Custom metrics
Next Steps
- Environment Variables - Configure your deployment
- Monitoring - Monitor your application
- Support - Get deployment help