Docker Deployment
Deploy NetPad using Docker containers for consistent, scalable deployments.
Prerequisitesโ
- Docker installed
- Docker Compose (optional, for multi-container setup)
- MongoDB connection
Quick Startโ
Using Docker Composeโ
- Create docker-compose.yml:
version: '3.8'
services:
netpad:
build: .
ports:
- "3000:3000"
environment:
- MONGODB_URI=mongodb+srv://...
- SESSION_SECRET=...
- VAULT_ENCRYPTION_KEY=...
- NEXT_PUBLIC_APP_URL=http://localhost:3000
restart: unless-stopped
- Start Services:
docker-compose up -d
Using Docker Directlyโ
- Build Image:
docker build -t netpad .
- Run Container:
docker run -d \
-p 3000:3000 \
-e MONGODB_URI=mongodb+srv://... \
-e SESSION_SECRET=... \
-e VAULT_ENCRYPTION_KEY=... \
-e NEXT_PUBLIC_APP_URL=http://localhost:3000 \
--name netpad \
netpad
Dockerfileโ
Example Dockerfile:
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]
Environment Variablesโ
Set via:
- docker-compose.yml: In
environmentsection - docker run: Using
-eflags - .env file: Using
--env-fileflag
Volumesโ
Persist data:
volumes:
- ./data:/app/data
Networkingโ
Connect to MongoDB:
- External MongoDB: Use connection string
- Docker Network: Connect to MongoDB container
Scalingโ
Scale with Docker Swarm or Kubernetes:
docker service scale netpad=3
Best Practicesโ
- Use Multi-Stage Builds: Reduce image size
- Health Checks: Add health check endpoints
- Logging: Configure log drivers
- Security: Run as non-root user
Troubleshootingโ
Container Won't Start:
- Check environment variables
- Verify MongoDB connection
- Check container logs:
docker logs netpad
Performance Issues:
- Allocate sufficient resources
- Use resource limits
- Monitor container metrics
Next Stepsโ
- Self-Hosted Deployment - Alternative deployment
- Configuration - Environment setup