-
Notifications
You must be signed in to change notification settings - Fork 90
Description
Have you searched for this feature request?
- I searched but did not find similar requests
Problem Statement
We need to make it easier to manage images that are used in our stacks. Right now it's very handy to use the internal git repos to slurp up stacks as you are ideating, but not any containers that they require. We should consider methods by which this could be handled.
Some questions that come to mind:
-
Is this adding too much complexity to idpbuilder?
-
Should we support building images as well as hosting them on the internal OCI registry?
-
Can we make use of kaniko or Buildah in an automated way?
-
Should we provide new top level commands to manage the images directly within idpbuilder rather than requiring folks to use other tools like the docker CLI, skopeo etc?
This last bit might at least help with the issue of the gitea using a self-signed certificate and thus the incompatibility with the docker cli (requiring re-configuring the daemon.json to allow insecure registries)
Possible Solution
At the very least if we can add the ability to push and pull images from gitea using idpbuilder will make rapidly itterating on stacks that contain images a little easier. We can configure the go registry client to use insecure registries like so:
import (
"crypto/tls"
"crypto/x509"
"net/http"
"encoding/base64"
"encoding/json"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
)
// Create custom TLS config
tlsConfig := &tls.Config{
InsecureSkipVerify: true, // Skip certificate verification
// Alternatively, if you have the certificate:
// RootCAs: certPool, // Add your custom CA certificate pool
}
// Create HTTP client with custom TLS config
httpClient := &http.Client{
Transport: &http.Transport{
TLSClientConfig: tlsConfig,
},
}
// Create Docker client
cli, err := client.NewClientWithOpts(
client.FromEnv,
client.WithHTTPClient(httpClient),
)
if err != nil {
// Handle error
}
registryAddr := "cnoe.localtest.me:8443/giteaadmin/""
authConfig := types.AuthConfig{
Username: "giteaAdmin",
Password: "generatedPAT",
ServerAddress: registryAddr,
}
encodedJSON, err := json.Marshal(authConfig)
if err != nil {
// Handle error
}
authStr := base64.URLEncoding.EncodeToString(encodedJSON)
// Use with ImagePush
imageRef := registryAddr + "/repository/image:tag"
resp, err := cli.ImagePush(ctx, imageRef, types.ImagePushOptions{
RegistryAuth: authStr,
})
Alternatives Considered
DO nothing, update documentation to show folks how to deal with the self-signed cert issue.