Prerequisites
Before installing DefDrive locally, ensure you have the following installed:- Go 1.24.1 or higher - Download Go
- PostgreSQL - A running PostgreSQL database instance
- Git - For cloning the repository
Installation Steps
Install Dependencies
Install all required Go dependencies using:This will download and install all packages specified in
go.mod, including:- Gin web framework
- GORM (PostgreSQL driver)
- JWT authentication
- godotenv for environment variables
Configure Environment Variables
Create a Edit the
.env file in the root directory:.env file with your configuration. See the Environment Variables page for detailed information about each variable.Set Up PostgreSQL Database
Ensure PostgreSQL is running and create a database:The application will automatically create the required tables on first run using GORM’s AutoMigrate feature.
Verify Installation
Once the server is running, you should see output similar to:Database Connection
DefDrive includes automatic retry logic for database connections. If the initial connection fails, it will retry up to 5 times with a 5-second delay between attempts.
DATABASE_URL environment variable in the format:
Data Storage
By default, uploaded files are stored in the directory specified by theDATA_PATH environment variable (default: ./data). Make sure this directory exists and has proper write permissions:
Development Mode
For development, you can usego run for hot reloading, or consider using tools like:
Troubleshooting
Database Connection Issues
If you encounter database connection errors:-
Verify PostgreSQL is running:
-
Check your
DATABASE_URLformat - Ensure the database exists
- Verify network connectivity to the database host
Port Already in Use
If port 8080 is already in use, change thePORT environment variable in your .env file:
Next Steps
- Configure Environment Variables for production
- Set up Docker deployment for containerized environments
- Review the API documentation to start building integrations