d6d23e74e1
continuous-integration/drone/push Build is passing
Update Dockerfile and build process to compile shared/schema.ts using esbuild and copy the resulting schema.js to the production image. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ceced2fc-aa46-458d-ba87-ddd4b7bb1518 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/659922a9-0087-461c-90dd-6d9a58b81d4d/ceced2fc-aa46-458d-ba87-ddd4b7bb1518/SBF5OKZ
162 lines
4.0 KiB
Markdown
162 lines
4.0 KiB
Markdown
# Docker Deployment - Ready for Production! 🚀
|
|
|
|
Your TaskFlow application is now **fully fixed** and ready for Docker deployment via Drone CI.
|
|
|
|
## What Was Fixed
|
|
|
|
### Issue 1: Vite Module Not Found ❌
|
|
```
|
|
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'vite' imported from /app/dist/index.js
|
|
```
|
|
|
|
**Cause**: esbuild was bundling all server code including vite references into production.
|
|
|
|
**Fix**:
|
|
- ✅ Created `server/static.ts` - production-only module (no vite)
|
|
- ✅ Split server compilation into separate files
|
|
- ✅ Conditional module loading based on NODE_ENV
|
|
|
|
### Issue 2: ESM Module Resolution ❌
|
|
```
|
|
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/dist/routes' imported from /app/dist/index.js
|
|
```
|
|
|
|
**Cause**: Node.js ESM requires explicit `.js` extensions in imports.
|
|
|
|
**Fix**:
|
|
- ✅ Added `.js` extensions to all relative imports:
|
|
- `server/index.ts`
|
|
- `server/routes.ts`
|
|
- `server/storage.ts`
|
|
- `server/db.ts`
|
|
- ✅ Changed `@shared/schema` imports to `../shared/schema.js`
|
|
|
|
### Issue 3: Shared Schema Not Compiled ❌
|
|
```
|
|
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/shared/schema.js' imported from /app/dist/routes.js
|
|
```
|
|
|
|
**Cause**: The `shared/schema.ts` TypeScript file wasn't being compiled to JavaScript.
|
|
|
|
**Fix**:
|
|
- ✅ Added esbuild compilation for `shared/schema.ts`
|
|
- ✅ Copy only the compiled `schema.js` file to production
|
|
- ✅ All TypeScript files are now properly compiled
|
|
|
|
## Deployment Steps
|
|
|
|
### 1. Commit and Push Your Code
|
|
|
|
```bash
|
|
git add .
|
|
git commit -m "Fix Docker ESM module resolution"
|
|
git push
|
|
```
|
|
|
|
### 2. Drone CI Builds Your Image
|
|
|
|
Drone will automatically:
|
|
- Build your Docker image
|
|
- Push it to `registry.local.nothaft.cloud/taskflow:latest`
|
|
|
|
### 3. Deploy on Your Server
|
|
|
|
```bash
|
|
# Pull the latest image
|
|
docker pull registry.local.nothaft.cloud/taskflow:latest
|
|
|
|
# Create .env file (if you haven't already)
|
|
cat > .env << EOF
|
|
POSTGRES_PASSWORD=your_secure_password_here
|
|
EOF
|
|
|
|
# Start the application
|
|
docker-compose up -d
|
|
|
|
# Check logs
|
|
docker-compose logs -f app
|
|
```
|
|
|
|
## Expected Output
|
|
|
|
When the container starts successfully, you should see:
|
|
|
|
```
|
|
serving on port 5000
|
|
Checking database schema...
|
|
Database schema is up to date
|
|
✓ Database initialized successfully
|
|
```
|
|
|
|
## What Works Now
|
|
|
|
✅ **Development Mode** (local)
|
|
- Vite dev server with HMR
|
|
- Fast refresh and debugging
|
|
- All features work
|
|
|
|
✅ **Production Mode** (Docker)
|
|
- No vite dependencies
|
|
- Serves pre-built static files
|
|
- PostgreSQL database
|
|
- Automatic schema creation
|
|
- Health checks
|
|
|
|
## Architecture
|
|
|
|
### Development
|
|
```
|
|
NODE_ENV=development → imports vite.js → Vite dev server
|
|
```
|
|
|
|
### Production (Docker)
|
|
```
|
|
NODE_ENV=production → imports static.js → Static file serving
|
|
```
|
|
|
|
## Files Changed
|
|
|
|
- ✅ `server/static.ts` - New production module
|
|
- ✅ `server/index.ts` - ESM imports with `.js`
|
|
- ✅ `server/routes.ts` - ESM imports with `.js`
|
|
- ✅ `server/storage.ts` - ESM imports with `.js`
|
|
- ✅ `server/db.ts` - ESM imports with `.js`
|
|
- ✅ `Dockerfile` - Separate file compilation
|
|
- ✅ `DOCKER-FIX.md` - Technical documentation
|
|
- ✅ `DOCKER-COMPOSE.md` - Updated with troubleshooting
|
|
|
|
## No Configuration Changes Needed
|
|
|
|
Your existing configuration files work perfectly:
|
|
- ✅ `.drone.yml` - No changes needed
|
|
- ✅ `docker-compose.yml` - No changes needed
|
|
- ✅ `package.json` - No changes needed
|
|
|
|
## Verification
|
|
|
|
After deployment, test your application:
|
|
|
|
```bash
|
|
# Check health endpoint
|
|
curl http://your-server:5000/api/health
|
|
|
|
# Expected response:
|
|
{"status":"ok","timestamp":"2025-10-23T..."}
|
|
```
|
|
|
|
## Support Documentation
|
|
|
|
- **DOCKER-FIX.md** - Detailed technical explanation
|
|
- **DOCKER-COMPOSE.md** - Complete deployment guide
|
|
- **docker-compose.yml** - Docker compose configuration
|
|
- **.drone.yml** - CI/CD pipeline configuration
|
|
|
|
## What's Next?
|
|
|
|
1. Push your code to trigger Drone CI build
|
|
2. Wait for the image to build (~2-5 minutes)
|
|
3. Pull and deploy on your server
|
|
4. Access your application at `http://your-server:5000`
|
|
|
|
Your TaskFlow application is production-ready! 🎉
|