feat: Pass Gitea registry credentials to provisioning runner
- Add GiteaCredentials interface to config-generator - Update JobConfig to include gitea registry credentials - Fetch Gitea credentials from settings in provision route - Pass gitea credentials through to job config This enables the runner to login to the Gitea registry on target servers, allowing deployment of private LetsBe images. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
b870c58695
commit
25a67ffea0
|
|
@ -9,6 +9,7 @@ import {
|
|||
generateRunnerToken,
|
||||
hashRunnerToken,
|
||||
DockerHubCredentials,
|
||||
GiteaCredentials,
|
||||
} from '@/lib/services/config-generator'
|
||||
import { spawnProvisioningContainer, isDockerAvailable } from '@/lib/services/docker-spawner'
|
||||
import { netcupService } from '@/lib/services/netcup-service'
|
||||
|
|
@ -161,8 +162,20 @@ export async function POST(
|
|||
console.log(`[Provision] Using Docker Hub credentials for user: ${dockerHubSettings.username}`)
|
||||
}
|
||||
|
||||
// Fetch Gitea registry credentials from settings
|
||||
const giteaSettings = await settingsService.getGiteaCredentials()
|
||||
let gitea: GiteaCredentials | undefined
|
||||
if (giteaSettings.username && giteaSettings.token && giteaSettings.registry) {
|
||||
gitea = {
|
||||
registry: giteaSettings.registry,
|
||||
username: giteaSettings.username,
|
||||
token: giteaSettings.token,
|
||||
}
|
||||
console.log(`[Provision] Using Gitea registry: ${giteaSettings.registry}`)
|
||||
}
|
||||
|
||||
// Generate job config
|
||||
const jobConfig = generateJobConfig(order, serverPassword, dockerHub)
|
||||
const jobConfig = generateJobConfig(order, serverPassword, dockerHub, gitea)
|
||||
|
||||
// Create provisioning job record
|
||||
const job = await prisma.provisioningJob.create({
|
||||
|
|
|
|||
|
|
@ -26,6 +26,12 @@ export interface JobConfig {
|
|||
token: string
|
||||
registry?: string // Custom registry URL, defaults to Docker Hub
|
||||
}
|
||||
// Gitea registry credentials (optional - for private LetsBe images)
|
||||
gitea?: {
|
||||
registry: string
|
||||
username: string
|
||||
token: string
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -71,6 +77,15 @@ export interface DockerHubCredentials {
|
|||
registry?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Gitea registry credentials for the job config
|
||||
*/
|
||||
export interface GiteaCredentials {
|
||||
registry: string
|
||||
username: string
|
||||
token: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the job configuration from an order
|
||||
* This config is mounted into the Docker container at /job/config.json
|
||||
|
|
@ -78,7 +93,8 @@ export interface DockerHubCredentials {
|
|||
export function generateJobConfig(
|
||||
order: Order,
|
||||
decryptedPassword: string,
|
||||
dockerHub?: DockerHubCredentials
|
||||
dockerHub?: DockerHubCredentials,
|
||||
gitea?: GiteaCredentials
|
||||
): JobConfig {
|
||||
if (!order.serverIp) {
|
||||
throw new Error('Order is missing server IP')
|
||||
|
|
@ -118,6 +134,15 @@ export function generateJobConfig(
|
|||
}
|
||||
}
|
||||
|
||||
// Add Gitea registry credentials if provided
|
||||
if (gitea?.username && gitea?.token && gitea?.registry) {
|
||||
config.gitea = {
|
||||
registry: gitea.registry,
|
||||
username: gitea.username,
|
||||
token: gitea.token,
|
||||
}
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue