insecure registry
Publish Action Image / build (push) Failing after 9s
Publish Action Image / publish (push) Failing after 9s

This commit is contained in:
2026-06-29 17:32:29 +10:00
parent 52c986b859
commit f323d18cf7
4 changed files with 43 additions and 24 deletions
+2 -1
View File
@@ -103,7 +103,8 @@ func applyRegistryDefaults(r *RegistryConfig, m *MetaConfig) {
if r.URL == "" { if r.URL == "" {
r.URL = DefaultRegistryURL r.URL = DefaultRegistryURL
} }
if r.PullSecret == "" { // Insecure (in-cluster) registries need no imagePullSecret.
if r.PullSecret == "" && !r.Insecure {
r.PullSecret = DefaultPullSecret r.PullSecret = DefaultPullSecret
} }
if r.Repository == "" { if r.Repository == "" {
+7 -2
View File
@@ -40,8 +40,13 @@ type MetaConfig struct {
type RegistryConfig struct { type RegistryConfig struct {
URL string `yaml:"url"` URL string `yaml:"url"`
Repository string `yaml:"repository,omitempty"` // default: ${tenant}/${name} Repository string `yaml:"repository,omitempty"` // default: ${tenant}/${name}
PullSecret string `yaml:"pull_secret,omitempty"` // default: regcred PullSecret string `yaml:"pull_secret,omitempty"` // default: regcred; set to "" to disable
// Insecure marks the registry as HTTP-only (no TLS). Skips docker login,
// omits imagePullSecrets from manifests, and configures buildkitd for
// plain-HTTP pushes. Typical for in-cluster registries accessed via
// ClusterIP/service DNS rather than an Ingress.
Insecure bool `yaml:"insecure,omitempty"`
} }
// ------------------------------------------------------------ // ------------------------------------------------------------
+26 -17
View File
@@ -78,27 +78,36 @@ func writeDeployJobs(b *strings.Builder, cfg *config.KforgeConfig, opts GiteaAct
"run": `echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV`, "run": `echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV`,
}) })
writeStep(b, "Login to registry", map[string]any{ if !cfg.Registry.Insecure {
"uses": "docker/login-action@v2", writeStep(b, "Login to registry", map[string]any{
"with": map[string]any{ "uses": "docker/login-action@v2",
"registry": cfg.Registry.URL, "with": map[string]any{
"username": "${{ secrets.DOCKER_USERNAME }}", "registry": cfg.Registry.URL,
"password": "${{ secrets.DOCKER_PASSWORD }}", "username": "${{ secrets.DOCKER_USERNAME }}",
}, "password": "${{ secrets.DOCKER_PASSWORD }}",
}) },
})
}
fullRepo := cfg.Registry.URL + "/" + cfg.Meta.Tenant + "/" + cfg.Meta.Name fullRepo := cfg.Registry.URL + "/" + cfg.Meta.Tenant + "/" + cfg.Meta.Name
buildWith := map[string]any{
"context": ".",
"platforms": "linux/amd64",
"file": cfg.Defaults.Dockerfile,
"push": true,
"tags": fmt.Sprintf("%s:latest\n%s:${{ env.SHORT_SHA }}", fullRepo, fullRepo),
"provenance": false,
"sbom": false,
}
if cfg.Registry.Insecure {
buildWith["buildkitd-config-inline"] = fmt.Sprintf(
"[registry.%q]\n http = true\n insecure = true",
cfg.Registry.URL,
)
}
writeStep(b, "Build and push image", map[string]any{ writeStep(b, "Build and push image", map[string]any{
"uses": "docker/build-push-action@v5", "uses": "docker/build-push-action@v5",
"with": map[string]any{ "with": buildWith,
"context": ".",
"platforms": "linux/amd64",
"file": cfg.Defaults.Dockerfile,
"push": true,
"tags": fmt.Sprintf("%s:latest\n%s:${{ env.SHORT_SHA }}", fullRepo, fullRepo),
"provenance": false,
"sbom": false,
},
}) })
if cfg.ActionRef != "" { if cfg.ActionRef != "" {
+8 -4
View File
@@ -151,8 +151,10 @@ func Deployment(env *config.ResolvedEnvironment, tokens interpolate.Tokens) (str
b.WriteString(renderResourceLines(env.Resources, " ")) b.WriteString(renderResourceLines(env.Resources, " "))
b.WriteString(" imagePullSecrets:\n") if env.ImagePullSecret != "" {
fmt.Fprintf(&b, " - name: %s\n", env.ImagePullSecret) b.WriteString(" imagePullSecrets:\n")
fmt.Fprintf(&b, " - name: %s\n", env.ImagePullSecret)
}
return b.String(), nil return b.String(), nil
} }
@@ -331,8 +333,10 @@ func CronJob(env *config.ResolvedEnvironment, job *config.ResolvedCronJob, token
b.WriteString(renderResourceLines(*job.Resources, " ")) b.WriteString(renderResourceLines(*job.Resources, " "))
} }
b.WriteString(" imagePullSecrets:\n") if env.ImagePullSecret != "" {
fmt.Fprintf(&b, " - name: %s\n", env.ImagePullSecret) b.WriteString(" imagePullSecrets:\n")
fmt.Fprintf(&b, " - name: %s\n", env.ImagePullSecret)
}
return b.String(), nil return b.String(), nil
} }