upload 2 2
This commit is contained in:
parent
9131588936
commit
0df60ac516
29
.env.dokploy
Normal file
29
.env.dokploy
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# Dokploy Environment Variables
|
||||||
|
# Use these values in your Dokploy environment variables section
|
||||||
|
|
||||||
|
NODE_ENV=production
|
||||||
|
APP_PORT=3000
|
||||||
|
|
||||||
|
# Database (uses Docker volume)
|
||||||
|
DATABASE_URL=file:/app/data/production.db
|
||||||
|
|
||||||
|
# Security - CHANGE THESE VALUES!
|
||||||
|
SESSION_SECRET=your-super-secure-session-secret-change-this-in-production-min-32-chars
|
||||||
|
SUPER_ADMIN=superadmin
|
||||||
|
SUPER_ADMIN_EMAIL=admin@yourcompany.com
|
||||||
|
SUPER_ADMIN_PASSWORD=YourSecurePassword123!
|
||||||
|
|
||||||
|
# Domain (set to your actual domain)
|
||||||
|
DOMAIN=your-domain.com
|
||||||
|
|
||||||
|
# Mail Settings (optional - for password reset features)
|
||||||
|
MAIL_HOST=
|
||||||
|
MAIL_PORT=587
|
||||||
|
MAIL_SECURE=false
|
||||||
|
MAIL_USERNAME=
|
||||||
|
MAIL_PASSWORD=
|
||||||
|
MAIL_FROM_NAME=Phosphat Report System
|
||||||
|
MAIL_FROM_EMAIL=
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
LOG_LEVEL=info
|
||||||
174
DOKPLOY-DEPLOYMENT.md
Normal file
174
DOKPLOY-DEPLOYMENT.md
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
# Dokploy Deployment Guide
|
||||||
|
|
||||||
|
This guide will help you deploy the Phosphat Report application on Dokploy.
|
||||||
|
|
||||||
|
## Step 1: Prepare Your Repository
|
||||||
|
|
||||||
|
1. **Fix Git Issues** (if you encountered them):
|
||||||
|
```bash
|
||||||
|
# Remove temporary Excel files
|
||||||
|
git rm --cached "public/~$16-6 Petra.xlsx"
|
||||||
|
|
||||||
|
# Configure Git line endings for Windows
|
||||||
|
git config core.autocrlf true
|
||||||
|
|
||||||
|
# Add and commit files
|
||||||
|
git add .
|
||||||
|
git commit -m "Initial commit for Dokploy deployment"
|
||||||
|
git push origin main
|
||||||
|
```
|
||||||
|
|
||||||
|
## Step 2: Create Application in Dokploy
|
||||||
|
|
||||||
|
1. **Login to your Dokploy dashboard**
|
||||||
|
2. **Click "Create Application"**
|
||||||
|
3. **Choose "Docker Compose"**
|
||||||
|
4. **Fill in the details**:
|
||||||
|
- **Name**: `phosphat-report` (or your preferred name)
|
||||||
|
- **Repository URL**: Your Git repository URL
|
||||||
|
- **Branch**: `main`
|
||||||
|
- **Build Path**: `/` (root directory)
|
||||||
|
|
||||||
|
## Step 3: Configure Environment Variables
|
||||||
|
|
||||||
|
In the Dokploy environment variables section, add these variables:
|
||||||
|
|
||||||
|
### Required Variables
|
||||||
|
```
|
||||||
|
NODE_ENV=production
|
||||||
|
SESSION_SECRET=your-super-secure-session-secret-change-this-min-32-chars
|
||||||
|
SUPER_ADMIN=superadmin
|
||||||
|
SUPER_ADMIN_EMAIL=admin@yourcompany.com
|
||||||
|
SUPER_ADMIN_PASSWORD=YourSecurePassword123!
|
||||||
|
```
|
||||||
|
|
||||||
|
### Optional Variables
|
||||||
|
```
|
||||||
|
APP_PORT=3000
|
||||||
|
DOMAIN=your-domain.com
|
||||||
|
MAIL_HOST=smtp.gmail.com
|
||||||
|
MAIL_PORT=587
|
||||||
|
MAIL_SECURE=false
|
||||||
|
MAIL_USERNAME=your-email@gmail.com
|
||||||
|
MAIL_PASSWORD=your-app-password
|
||||||
|
MAIL_FROM_NAME=Phosphat Report System
|
||||||
|
MAIL_FROM_EMAIL=noreply@yourcompany.com
|
||||||
|
LOG_LEVEL=info
|
||||||
|
```
|
||||||
|
|
||||||
|
## Step 4: Deploy
|
||||||
|
|
||||||
|
1. **Click "Deploy"** in Dokploy
|
||||||
|
2. **Monitor the build logs** for any errors
|
||||||
|
3. **Wait for deployment to complete**
|
||||||
|
|
||||||
|
## Step 5: Access Your Application
|
||||||
|
|
||||||
|
Once deployed, your application will be available at:
|
||||||
|
- **HTTP**: `http://your-server-ip:3000`
|
||||||
|
- **HTTPS**: `https://your-domain.com` (if domain is configured)
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Common Issues
|
||||||
|
|
||||||
|
1. **Volume Mount Errors**:
|
||||||
|
- The updated docker-compose.yml uses Docker volumes instead of bind mounts
|
||||||
|
- This should resolve the "no such file or directory" error
|
||||||
|
|
||||||
|
2. **Build Failures**:
|
||||||
|
- Check the build logs in Dokploy
|
||||||
|
- Ensure all environment variables are set correctly
|
||||||
|
- Verify your repository is accessible
|
||||||
|
|
||||||
|
3. **Database Issues**:
|
||||||
|
- The database will be created automatically on first run
|
||||||
|
- Check container logs if the application fails to start
|
||||||
|
|
||||||
|
### Checking Logs
|
||||||
|
|
||||||
|
In Dokploy:
|
||||||
|
1. Go to your application
|
||||||
|
2. Click on "Logs" tab
|
||||||
|
3. Select the container (app or backup)
|
||||||
|
4. View real-time logs
|
||||||
|
|
||||||
|
### Health Check
|
||||||
|
|
||||||
|
Once deployed, check if the application is healthy:
|
||||||
|
```bash
|
||||||
|
curl http://your-server-ip:3000/health
|
||||||
|
```
|
||||||
|
|
||||||
|
Should return:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"status": "ok",
|
||||||
|
"timestamp": "2025-07-24T10:30:00.000Z",
|
||||||
|
"uptime": 123.45,
|
||||||
|
"environment": "production",
|
||||||
|
"database": "connected"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Database Management
|
||||||
|
|
||||||
|
### Backup
|
||||||
|
The backup service runs automatically daily at 2 AM. To manually backup:
|
||||||
|
|
||||||
|
1. **Access the container**:
|
||||||
|
```bash
|
||||||
|
docker exec -it phosphat-report-app sh
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Create backup**:
|
||||||
|
```bash
|
||||||
|
cp /app/data/production.db /app/data/backup_$(date +%Y%m%d_%H%M%S).db
|
||||||
|
```
|
||||||
|
|
||||||
|
### Restore
|
||||||
|
1. **Stop the application** in Dokploy
|
||||||
|
2. **Access the server** and restore the database file
|
||||||
|
3. **Restart the application**
|
||||||
|
|
||||||
|
## Updates
|
||||||
|
|
||||||
|
To update your application:
|
||||||
|
|
||||||
|
1. **Push changes** to your Git repository
|
||||||
|
2. **Click "Redeploy"** in Dokploy
|
||||||
|
3. **Monitor the deployment** logs
|
||||||
|
|
||||||
|
## Security Notes
|
||||||
|
|
||||||
|
1. **Change default passwords** in environment variables
|
||||||
|
2. **Use strong session secret** (minimum 32 characters)
|
||||||
|
3. **Configure proper domain** and SSL
|
||||||
|
4. **Regular backups** are handled automatically
|
||||||
|
5. **Monitor application logs** regularly
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
If you encounter issues:
|
||||||
|
|
||||||
|
1. **Check Dokploy logs** for build/runtime errors
|
||||||
|
2. **Verify environment variables** are set correctly
|
||||||
|
3. **Test health endpoint**: `/health`
|
||||||
|
4. **Check database connectivity** in logs
|
||||||
|
5. **Review Docker Compose configuration**
|
||||||
|
|
||||||
|
## File Structure for Dokploy
|
||||||
|
|
||||||
|
Your repository should have these key files:
|
||||||
|
```
|
||||||
|
├── docker-compose.yml # Main compose file (Dokploy compatible)
|
||||||
|
├── docker-compose.dokploy.yml # Alternative compose file
|
||||||
|
├── Dockerfile # Application container
|
||||||
|
├── .dockerignore # Docker build exclusions
|
||||||
|
├── .env.dokploy # Environment template
|
||||||
|
├── app/ # Application code
|
||||||
|
├── prisma/ # Database schema
|
||||||
|
└── public/ # Static assets
|
||||||
|
```
|
||||||
|
|
||||||
|
The deployment is now optimized for Dokploy and should work without volume mounting issues.
|
||||||
76
docker-compose.dokploy.yml
Normal file
76
docker-compose.dokploy.yml
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
- NODE_ENV=production
|
||||||
|
image: phosphat-report:latest
|
||||||
|
container_name: phosphat-report-app
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "${APP_PORT:-3000}:3000"
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=production
|
||||||
|
- PORT=3000
|
||||||
|
- DATABASE_URL=file:/app/data/production.db
|
||||||
|
- SESSION_SECRET=${SESSION_SECRET}
|
||||||
|
- SUPER_ADMIN=${SUPER_ADMIN}
|
||||||
|
- SUPER_ADMIN_EMAIL=${SUPER_ADMIN_EMAIL}
|
||||||
|
- SUPER_ADMIN_PASSWORD=${SUPER_ADMIN_PASSWORD}
|
||||||
|
- MAIL_HOST=${MAIL_HOST:-}
|
||||||
|
- MAIL_PORT=${MAIL_PORT:-587}
|
||||||
|
- MAIL_SECURE=${MAIL_SECURE:-false}
|
||||||
|
- MAIL_USERNAME=${MAIL_USERNAME:-}
|
||||||
|
- MAIL_PASSWORD=${MAIL_PASSWORD:-}
|
||||||
|
- MAIL_FROM_NAME=${MAIL_FROM_NAME:-Phosphat Report System}
|
||||||
|
- MAIL_FROM_EMAIL=${MAIL_FROM_EMAIL:-}
|
||||||
|
volumes:
|
||||||
|
- app_data:/app/data
|
||||||
|
- app_logs:/app/logs
|
||||||
|
networks:
|
||||||
|
- app_network
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/health", "||", "exit", "1"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 40s
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: 512M
|
||||||
|
cpus: '0.5'
|
||||||
|
reservations:
|
||||||
|
memory: 256M
|
||||||
|
cpus: '0.25'
|
||||||
|
|
||||||
|
backup:
|
||||||
|
image: alpine:latest
|
||||||
|
container_name: phosphat-report-backup
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- app_data:/data:ro
|
||||||
|
- backup_data:/backup
|
||||||
|
command: >
|
||||||
|
sh -c "
|
||||||
|
apk add --no-cache dcron sqlite &&
|
||||||
|
echo '0 2 * * * cp /data/production.db /backup/production_$(date +%Y%m%d_%H%M%S).db && find /backup -name \"production_*.db\" -mtime +7 -delete' | crontab - &&
|
||||||
|
crond -f
|
||||||
|
"
|
||||||
|
networks:
|
||||||
|
- app_network
|
||||||
|
depends_on:
|
||||||
|
- app
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
app_data:
|
||||||
|
driver: local
|
||||||
|
app_logs:
|
||||||
|
driver: local
|
||||||
|
backup_data:
|
||||||
|
driver: local
|
||||||
|
|
||||||
|
networks:
|
||||||
|
app_network:
|
||||||
|
driver: bridge
|
||||||
@ -1,5 +1,3 @@
|
|||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
build:
|
build:
|
||||||
@ -20,7 +18,6 @@ services:
|
|||||||
- SUPER_ADMIN=${SUPER_ADMIN}
|
- SUPER_ADMIN=${SUPER_ADMIN}
|
||||||
- SUPER_ADMIN_EMAIL=${SUPER_ADMIN_EMAIL}
|
- SUPER_ADMIN_EMAIL=${SUPER_ADMIN_EMAIL}
|
||||||
- SUPER_ADMIN_PASSWORD=${SUPER_ADMIN_PASSWORD}
|
- SUPER_ADMIN_PASSWORD=${SUPER_ADMIN_PASSWORD}
|
||||||
# Mail settings (optional)
|
|
||||||
- MAIL_HOST=${MAIL_HOST:-}
|
- MAIL_HOST=${MAIL_HOST:-}
|
||||||
- MAIL_PORT=${MAIL_PORT:-587}
|
- MAIL_PORT=${MAIL_PORT:-587}
|
||||||
- MAIL_SECURE=${MAIL_SECURE:-false}
|
- MAIL_SECURE=${MAIL_SECURE:-false}
|
||||||
@ -47,16 +44,7 @@ services:
|
|||||||
reservations:
|
reservations:
|
||||||
memory: 256M
|
memory: 256M
|
||||||
cpus: '0.25'
|
cpus: '0.25'
|
||||||
labels:
|
|
||||||
- "com.docker.compose.service=phosphat-report"
|
|
||||||
- "com.docker.compose.project=phosphat-report"
|
|
||||||
- "traefik.enable=true"
|
|
||||||
- "traefik.http.routers.phosphat-report.rule=Host(`${DOMAIN:-localhost}`)"
|
|
||||||
- "traefik.http.routers.phosphat-report.tls=true"
|
|
||||||
- "traefik.http.routers.phosphat-report.tls.certresolver=letsencrypt"
|
|
||||||
- "traefik.http.services.phosphat-report.loadbalancer.server.port=3000"
|
|
||||||
|
|
||||||
# Database backup service (optional but recommended)
|
|
||||||
backup:
|
backup:
|
||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
container_name: phosphat-report-backup
|
container_name: phosphat-report-backup
|
||||||
@ -64,12 +52,10 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- app_data:/data:ro
|
- app_data:/data:ro
|
||||||
- backup_data:/backup
|
- backup_data:/backup
|
||||||
environment:
|
|
||||||
- BACKUP_SCHEDULE=${BACKUP_SCHEDULE:-0 2 * * *}
|
|
||||||
command: >
|
command: >
|
||||||
sh -c "
|
sh -c "
|
||||||
apk add --no-cache dcron sqlite &&
|
apk add --no-cache dcron sqlite &&
|
||||||
echo '${BACKUP_SCHEDULE:-0 2 * * *} cp /data/production.db /backup/production_$(date +%Y%m%d_%H%M%S).db && find /backup -name \"production_*.db\" -mtime +7 -delete' | crontab - &&
|
echo '0 2 * * * cp /data/production.db /backup/production_$(date +%Y%m%d_%H%M%S).db && find /backup -name \"production_*.db\" -mtime +7 -delete' | crontab - &&
|
||||||
crond -f
|
crond -f
|
||||||
"
|
"
|
||||||
networks:
|
networks:
|
||||||
@ -80,18 +66,10 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
app_data:
|
app_data:
|
||||||
driver: local
|
driver: local
|
||||||
driver_opts:
|
|
||||||
type: none
|
|
||||||
o: bind
|
|
||||||
device: ${DATA_PATH:-./data}
|
|
||||||
app_logs:
|
app_logs:
|
||||||
driver: local
|
driver: local
|
||||||
backup_data:
|
backup_data:
|
||||||
driver: local
|
driver: local
|
||||||
driver_opts:
|
|
||||||
type: none
|
|
||||||
o: bind
|
|
||||||
device: ${BACKUP_PATH:-./backups}
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
app_network:
|
app_network:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user