A fullstack Next.js application that allows users to deploy HTML files to Dokploy with Google OAuth authentication.
- π Google OAuth authentication with NextAuth
- π€ HTML file upload with validation
- π Automatic deployment to Dokploy
- π Deployment history tracking
- π¨ Modern UI with Tailwind CSS
- πΎ SQLite database (easily switchable to PostgreSQL)
- Node.js 18+ installed
- Google Cloud Console account for OAuth credentials
- Dokploy instance running with API access
- SSH keys configured for Dokploy git access
npm installCopy the example environment file and fill in your credentials:
cp env.example .env.localEdit .env.local with your actual values:
# Google OAuth Configuration
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
# NextAuth Configuration
NEXTAUTH_SECRET=generate-with-openssl-rand-base64-32
NEXTAUTH_URL=http://localhost:3000
# Database Configuration
DATABASE_URL=file:./dev.db
# Dokploy Configuration
DOKPLOY_API_KEY=your-dokploy-api-key
DOKPLOY_URL=https://yourdomain.com
SERVER_ID=your-server-id
ENVIRONMENT_ID=your-environment-id
SSH_HOST=yourdomain.com- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google+ API
- Go to "Credentials" β "Create Credentials" β "OAuth client ID"
- Choose "Web application"
- Add authorized redirect URIs:
http://localhost:3000/api/auth/callback/google(for development)https://your-production-domain.com/api/auth/callback/google(for production)
- Copy the Client ID and Client Secret
openssl rand -base64 32- Log into your Dokploy instance
- Go to Settings β API/CLI section
- Generate an API key
- Get your Server ID and Environment ID from the Dokploy API or UI
Generate Prisma Client and create the database:
npx prisma generate
npx prisma db pushEnsure your server can push to Dokploy via SSH without password prompts:
# Test SSH connection
ssh git@yourdomain.com
# If this works without prompting for a password, you're good to gonpm run devOpen http://localhost:3000 in your browser.
- Login: Click "Login with Google" to authenticate
- Upload: Select an HTML file (max 10MB)
- Deploy: Click "Deploy" to push your file to Dokploy
- Access: Once deployed, click the generated URL to view your site
- History: View all your previous deployments in the dashboard
deployer-app/
βββ prisma/
β βββ schema.prisma # Database schema
βββ src/
β βββ app/
β β βββ api/
β β β βββ auth/
β β β β βββ [...nextauth]/
β β β β βββ route.ts # NextAuth configuration
β β β βββ deploy/
β β β β βββ route.ts # Deployment API
β β β βββ deployments/
β β β βββ route.ts # Fetch deployments API
β β βββ layout.tsx # Root layout with providers
β β βββ page.tsx # Main UI
β βββ components/
β β βββ providers.tsx # SessionProvider wrapper
β βββ types/
β βββ next-auth.d.ts # NextAuth type extensions
βββ env.example # Environment variables template
βββ package.json
Deploy an HTML file to Dokploy.
Authentication: Required (session)
Body: FormData with htmlFile field
Response:
{
"url": "https://deployed-site-url.com"
}Fetch user's deployment history.
Authentication: Required (session)
Response:
[
{
"id": "deployment-id",
"appName": "user-xxx-yyy",
"url": "https://deployed-site-url.com",
"createdAt": "2024-01-01T00:00:00.000Z"
}
]- Create a new app in Dokploy UI
- Set build type to "nixpacks" or "dockerfile"
- Add git remote:
git remote add dokploy git@yourdomain.com:deployer-app.git
- Push to deploy:
git push dokploy main
- Update environment variables in Dokploy UI
- Generate domain for your app
- Push your code to GitHub
- Import project in Vercel
- Add environment variables
- Deploy
Note: Update NEXTAUTH_URL to your production URL.
To switch from SQLite to PostgreSQL:
-
Update
prisma/schema.prisma:datasource db { provider = "postgresql" url = env("DATABASE_URL") }
-
Update
DATABASE_URLin.env.local:DATABASE_URL="postgresql://user:password@host:5432/dbname"
-
Run migrations:
npx prisma migrate dev --name init
- Ensure SSH keys are properly configured
- Test SSH connection:
ssh git@yourdomain.com - Check that the Dokploy git remote is accessible
- Verify API key is correct
- Check that Server ID and Environment ID exist
- Ensure Dokploy instance is accessible
- Verify Google OAuth credentials
- Check redirect URIs match exactly
- Ensure NEXTAUTH_SECRET is set
- Clear browser cookies and try again
- Never commit
.env.localto version control - Use strong NEXTAUTH_SECRET (32+ characters)
- Implement rate limiting for production
- Add file size and type validation
- Consider adding CAPTCHA for public deployments
MIT
For issues and questions, please open an issue on GitHub.