From 2caf98ad0fc9c6ce0e47d2c2d91e0958692a4c79 Mon Sep 17 00:00:00 2001 From: yznahmad Date: Tue, 19 Aug 2025 01:03:47 +0300 Subject: [PATCH] feat: Add new user authentication for v2.0 --- .dockerignore | 3 + DEPLOYMENT_GUIDE.md | 147 ++++++++++++++++++++++ Dockerfile | 35 +----- docker-compose.dokploy.yml => compose.yml | 28 ++--- docker-compose.yml | 76 ----------- prisma/dev.db | Bin 102400 -> 102400 bytes prisma/seed.js | 109 +--------------- prisma/seed.ts | 124 +----------------- start.sh | 27 ++++ 9 files changed, 195 insertions(+), 354 deletions(-) create mode 100644 DEPLOYMENT_GUIDE.md rename docker-compose.dokploy.yml => compose.yml (70%) delete mode 100644 docker-compose.yml create mode 100644 start.sh diff --git a/.dockerignore b/.dockerignore index c1a0279..9d0845b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -49,6 +49,9 @@ coverage ehthumbs.db Thumbs.db +# Explicitly include start.sh +!start.sh + # Git .git .gitignore diff --git a/DEPLOYMENT_GUIDE.md b/DEPLOYMENT_GUIDE.md new file mode 100644 index 0000000..8f5da3f --- /dev/null +++ b/DEPLOYMENT_GUIDE.md @@ -0,0 +1,147 @@ +# Deployment Guide for Phosphat Report App + +This guide will help you deploy the Phosphat Report application on your VPS using the provided `compose.yml` file. + +## Prerequisites + +- Docker and Docker Compose installed on your VPS +- Git (to clone the repository) +- At least 1GB RAM and 10GB disk space + +## Quick Deployment + +1. **Clone the repository** to your VPS: + ```bash + git clone + cd phosphat-report-app + ``` + +2. **Deploy the application**: + ```bash + docker-compose -f compose.yml up -d --build + ``` + +3. **Check the status**: + ```bash + docker-compose -f compose.yml ps + ``` + +4. **Access your application**: + - URL: `http://your-vps-ip:3000` + - Default login: `superadmin` / `P@ssw0rd123!` + +## Environment Variables (Hardcoded in compose.yml) + +The following environment variables are already configured in the `compose.yml` file: + +- **NODE_ENV**: `production` +- **DATABASE_URL**: `file:/app/data/production.db` +- **SESSION_SECRET**: `your-super-secure-session-secret-change-this-min-32-chars` +- **SUPER_ADMIN**: `superadmin` +- **SUPER_ADMIN_EMAIL**: `admin@yourcompany.com` +- **SUPER_ADMIN_PASSWORD**: `P@ssw0rd123!` +- **MAIL_HOST**: `smtp.gmail.com` +- **MAIL_PORT**: `587` +- **MAIL_USERNAME**: `your-email@gmail.com` +- **MAIL_PASSWORD**: `your-app-password` + +## Services Included + +### Main Application (`app`) +- **Port**: 3000 +- **Database**: SQLite with persistent storage +- **Health Check**: Available at `/health` endpoint +- **Resource Limits**: 512MB RAM, 0.5 CPU + +### Backup Service (`backup`) +- **Purpose**: Automatic daily database backups at 2 AM +- **Retention**: Keeps backups for 7 days +- **Location**: `/backup` volume + +## Useful Commands + +### View logs: +```bash +docker-compose -f compose.yml logs -f app +``` + +### Stop services: +```bash +docker-compose -f compose.yml down +``` + +### Restart services: +```bash +docker-compose -f compose.yml restart +``` + +### Manual backup: +```bash +docker-compose -f compose.yml exec app cp /app/data/production.db /app/data/backup_$(date +%Y%m%d_%H%M%S).db +``` + +### Check health: +```bash +curl http://localhost:3000/health +``` + +## Volumes + +- **app_data**: Stores the SQLite database +- **app_logs**: Application logs +- **backup_data**: Database backups + +## Security Notes + +1. **Change default passwords** after first login +2. **Update email settings** in the application +3. **Configure firewall** to only allow necessary ports +4. **Use HTTPS** with a reverse proxy (nginx/traefik) for production + +## Troubleshooting + +### Application won't start: +```bash +# Check logs +docker-compose -f compose.yml logs app + +# Rebuild without cache +docker-compose -f compose.yml build --no-cache app +``` + +### Database issues: +```bash +# Reset database (WARNING: This will delete all data) +docker-compose -f compose.yml down +docker volume rm $(docker volume ls -q | grep app_data) +docker-compose -f compose.yml up -d +``` + +### Port conflicts: +If port 3000 is already in use, edit the `compose.yml` file and change: +```yaml +ports: + - "3001:3000" # Change 3000 to any available port +``` + +## Updating the Application + +1. **Pull latest changes**: + ```bash + git pull origin main + ``` + +2. **Rebuild and restart**: + ```bash + docker-compose -f compose.yml up -d --build + ``` + +## Support + +For issues and support: +1. Check the application logs +2. Verify all services are running +3. Test the health endpoint +4. Check database connectivity + +The application should be accessible at `http://your-vps-ip:3000` after successful deployment. \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ccf4332..64cb4ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,39 +54,6 @@ COPY --from=deps --chown=remix:nodejs /app/node_modules ./node_modules RUN mkdir -p /app/data /app/logs && \ chown -R remix:nodejs /app/data /app/logs -# Create startup script -COPY --chown=remix:nodejs < - 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 \ No newline at end of file diff --git a/prisma/dev.db b/prisma/dev.db index 2623aac148f9be50c76e9c135a581212ba03edb1..91c8b2b90bfcf6c54ebe9c68674435320991041c 100644 GIT binary patch delta 304 zcmZozz}B#UZGtr8-H9^Jtalmo(q3&$nP)HYnSql(o1MRd{~rHQ{z?2h_*d~~^Dp2p z+bkI1%3sgFfI*x;D77HJsKkJigISUT!sh28gMZPFfj0c z;=jv(7wFvc{FCqYi?RS^`8I#+=L>+yKI7lZzZWRGo`3S*_nIJCsm-t6OBFz5oA@^I ZZQ87;u!L{=raZ7G7pW&duNY`2v8l&lvch@$co|3zS{YKY8zaO%_RJOU})&-b)n# jWt$lIoA@^IZQ87;u!L{=raZ