Prerequisites
Ensure you have the following installed:- Docker - Install Docker
- Docker Compose - Install Docker Compose
Quick Start
Configure Environment Variables
Create a Edit the
.env file from the example:.env file with your configuration. See Environment Variables for details.Start Services
Launch all services using Docker Compose:This will start:
- DefDrive application container
- PostgreSQL database container
Docker Compose Configuration
Thecompose.yaml file defines two services:
Application Service
Database Service
Dockerfile
The DefDrive Dockerfile uses a multi-stage build process:The application is built inside the container, ensuring consistent builds across different environments.
Using Pre-built Images
Alternatively, you can use pre-built images from GitHub Container Registry:compose.yaml and comment out the build section.
Docker Compose Commands
Data Persistence
Database Data
PostgreSQL data is persisted in a named Docker volume:Uploaded Files
Uploaded files are stored in a bind mount:./data directory, making them easily accessible and backed up.
Health Checks
The database service includes a health check to ensure it’s ready before the application starts:Port Configuration
By default, DefDrive runs on port 8080 inside the container. You can map it to a different host port:PORT variable in your .env file:
Production Deployment
Using Docker Compose in Production
Set Production Environment Variables
Update your
.env file with production values:- Strong
JWT_SECRET - Secure database credentials
- Production
HOST_URL
Set Up Reverse Proxy
Configure nginx or another reverse proxy to handle SSL/TLS and forward requests to DefDrive.
Troubleshooting
Container Won’t Start
Check logs for errors:Database Connection Failed
Ensure the database service is healthy:Permission Denied Errors
If you encounter permission errors with mounted volumes:Port Already in Use
Change the host port mapping incompose.yaml or your .env file:
Updating DefDrive
To update to the latest version:Always backup your database before updating to prevent data loss.
Backup and Restore
Backup Database
Restore Database
Backup Uploaded Files
Next Steps
- Configure Environment Variables for your deployment
- Set up SSL/TLS with a reverse proxy
- Configure automated backups
- Monitor application logs and performance