Features
- OAuth 2.0 authentication with automatic token refresh
- Support for GitLab.com and self-hosted instances
- Group filtering for large organizations
- Repository and branch browsing
- Automatic token refresh with expiry management
- Internal URL support for same-network deployments
Prerequisites
- A GitLab account (GitLab.com or self-hosted)
- Access to the repositories you want to deploy
- Admin access to create OAuth applications
- Your Dokploy instance must be accessible for OAuth callbacks
Creating a GitLab OAuth Application
Navigate to Applications
For GitLab.com:
- Go to your GitLab profile
- Click Settings → Applications
- Click Add new application
- Go to Admin Area → Applications
- Click New application
You can also create user-level applications in User Settings → Applications
Configure Application Details
Fill in the application information:Name: Choose a descriptive name (e.g., “Dokploy Production”)Redirect URI: Your Dokploy callback URL:
Set Scopes
Enable the following scopes:
-
api- Full API access -
read_user- Read user information -
read_repository- Read repository content -
write_repository- Clone repositories
The
api scope provides comprehensive access. For more restrictive access, use only read scopes.Configuring in Dokploy
Navigate to Git Providers
In Dokploy dashboard:
- Go to Settings → Git Providers
- Click Add Git Provider
- Select GitLab
Enter Configuration
Fill in the GitLab OAuth details:Provider Name: A friendly name (e.g., “GitLab Production”)GitLab URL:Application ID: The Application ID from GitLabSecret: The Secret from GitLabGroup Name (optional): Filter repositories by groupComma-separated list of group paths.
- For GitLab.com:
https://gitlab.com - For self-hosted:
https://gitlab.yourdomain.com
- Leave empty if not on same network
- For same-network:
http://gitlab.internal:8080
Internal URL is used for token operations when Dokploy and GitLab are on the same network, reducing latency.
Save and Authorize
- Click Save
- You’ll be redirected to GitLab
- Click Authorize to grant access
- You’ll be redirected back to Dokploy
Self-Hosted GitLab Configuration
Basic Setup
For self-hosted GitLab instances:Internal URL Configuration
When Dokploy and GitLab are on the same network:- Faster token refresh operations
- Reduced external network usage
- Works even if external URL is behind firewall
Basic Authentication in URL
If your GitLab instance requires basic auth:- Extracts credentials from URL
- Adds
Authorization: Basicheader - Removes credentials from subsequent URLs
Using GitLab in Applications
Deploying from GitLab
Create or Edit Application
When creating/editing an application:
- Set Source Type to “Git”
- Select your GitLab provider
Select Repository
Choose from accessible repositories:
- Format:
namespace/project-name - Includes personal and group repositories
- Filtered by group name if configured
Repository Structure
GitLab repositories include:Token Management
Automatic Token Refresh
Dokploy automatically refreshes expired tokens:- Before Each Operation: Checks token expiry
- Safety Margin: Refreshes 60 seconds before expiry
- Refresh Flow:
- Store New Tokens: Updates access and refresh tokens in database
Token Expiration
- Default Expiry: 2 hours (7200 seconds)
- Stored as Unix Timestamp:
expiresAtfield - Automatic Refresh: Happens transparently during:
- Repository listing
- Branch fetching
- Repository cloning
- Connection testing
Group Filtering
Single Group
Filter by a single group:mygroup/project1mygroup/project2
Multiple Groups
Comma-separated groups:Subgroups
Include subgroups:mygroup/frontend/app1mygroup/frontend/app2mygroup/backend/api
No Filtering
Leave empty to show:- All personal repositories
- All group repositories you have access to
API Integration
Repository Listing
Fetches projects with pagination:- 100 projects per page (GitLab maximum)
- Uses
x-totalheader for total count - Fetches all pages automatically
Branch Listing
Fetches branches for a project:Repository Cloning
Clone command format:- Uses OAuth2 token authentication
- Shallow clone (—depth 1) for speed
- Optional submodule support
Troubleshooting
Authorization Fails
Authorization Fails
No Repositories Shown
No Repositories Shown
Symptoms: Test connection succeeds but no repositories availableSolutions:
- Check Group Filter: Verify group names are correct
- Review Permissions: User must have at least Reporter role
- Test API Access:
- Clear and Reconnect: Remove and re-add the provider
Token Refresh Errors
Token Refresh Errors
Symptoms: “Failed to refresh token” errors in logsSolutions:
- Check Secret: Ensure client secret is correct
- Verify Application: Application might be deleted or revoked
- Review Internal URL: If set, must be accessible from Dokploy
- Reauthorize: Remove provider and go through OAuth flow again
Clone Failures
Clone Failures
Symptoms: “Repository configuration failed” during deploymentSolutions:
- Verify Required Fields:
- Repository name
- Owner/namespace
- Branch name
- Path namespace
- Check Token: Use Test Connection to verify
- Review Permissions: Ensure read_repository scope
- Test Manually:
Self-Hosted Certificate Issues
Self-Hosted Certificate Issues
Symptoms: SSL/TLS errors when connectingSolutions:
- Valid Certificate: Ensure GitLab has valid SSL certificate
- Internal URL: Use HTTP for internal URL if on same network
- Certificate Trust: Dokploy must trust the CA
- Disable SSL Verification (not recommended): Configure in GitLab settings if absolutely necessary
Security Best Practices
1. OAuth Secret Management
- Store client secret securely
- Never commit to version control
- Rotate periodically
- Use different applications for different environments
2. Scope Limitation
Request only necessary scopes:- Minimum:
read_user,read_repository - Standard: Add
write_repositoryfor full functionality - Avoid:
sudoor admin scopes unless absolutely required
3. Group Filtering
For large organizations:- Use group filtering to limit repository access
- Separate providers for different teams
- Regular access audits
4. Token Storage
- Tokens are encrypted in database
- Never logged or exposed in UI
- Automatically refreshed before expiry
- Invalidated when provider is removed
5. Self-Hosted Security
- Use HTTPS for external URLs
- Keep GitLab instance updated
- Configure internal URLs only on trusted networks
- Regular security audits
Advanced Configuration
Multiple GitLab Providers
Configure separate providers for:- Different Instances: GitLab.com + self-hosted
- Different Groups: Frontend team, Backend team
- Different Environments: Production, Staging
- Separate OAuth tokens
- Independent group filters
- Isolated repository access
Webhook Integration (Future)
While not currently implemented, prepare for webhook support:- Note your Dokploy webhook endpoint
- Plan webhook events needed (Push, Tag, Merge Request)
- Prepare secret token generation
API Response Examples
Project List Response
Branch List Response
Next Steps
Deploy an Application
Create your first deployment from GitLab
GitHub Integration
Compare with GitHub integration
Gitea Integration
Self-hosted Git alternative
Git Providers Overview
Compare all Git provider options