package main import ( "context" "log/slog" "net/http" "git.leonardobishop.net/instancer/pkg/deployer" "git.leonardobishop.net/instancer/pkg/janitor" "git.leonardobishop.net/instancer/pkg/registry" "git.leonardobishop.net/instancer/web" "github.com/caarlos0/env/v11" ) type Config struct { ContainerRegistryURL string `env:"CONTAINER_REGISTRY_URL,notEmpty,required"` ContainerRegistryUsername string `env:"CONTAINER_REGISTRY_USERNAME"` ContainerRegistryPassword string `env:"CONTAINER_REGISTRY_PASSWORD"` InstancerDomain string `env:"INSTANCER_DOMAIN"` ImagePrefix string `env:"IMAGE_PREFIX"` ProxyContainerName string `env:"PROXY_CONTAINER_NAME"` } const startupMessage = ` , . , . . . . . . . what's the worst that i can say?... . . . . . . . . ...things are better if i stay... . . . . , . , . . , . . . ! , ! . , . ^ / \ . . /___\ , . |= =| , . | | | | , , | | | | . | | . . | | , , | | . | | | | . /|##!##|\ . / |##!##| \ / |##!##| \ , | / ^ | ^ \ | . | / ( | ) \ | , , . |/ ( | ) \| (( )) (( : )) . (( : )) , (( )) . . (( )) , ( ) . . . . , . , _ __ ___| |_ / _| / __| __| |_ _ | (__| |_| _| (_)_ __ ___| \___|\__|_|_ ___ ___ _ __ | | '_ \/ __| __/ _` + "`" + ` | '_ \ / __/ _ \ '__| | | | | \__ \ || (_| | | | | (_| __/ | |_|_| |_|___/\__\__,_|_| |_|\___\___|_| ____^/\___^--____/\____O______________/\/\-- /\^ ^ ^ ^ ^^ ^ '\ -- - -- - -- __ ___-- ^ ^ ` func main() { slog.Info(startupMessage) var config Config if err := env.Parse(&config); err != nil { panic(err) } registryClient := registry.RegistryClient{ URL: config.ContainerRegistryURL, Username: config.ContainerRegistryUsername, Password: config.ContainerRegistryPassword, } dockerDeployer, err := deployer.New( config.ContainerRegistryURL, config.ContainerRegistryUsername, config.ContainerRegistryPassword, config.InstancerDomain, config.ImagePrefix, config.ProxyContainerName, ) if err != nil { panic(err) } slog.Info("staring janitor job") go janitor.StartJanitor(context.Background(), &dockerDeployer) slog.Info("starting http server") err = http.ListenAndServe(":8080", web.NewMux(®istryClient, &dockerDeployer)) slog.Error("http server closing", "reason", err.Error()) slog.Info("so long and goodnight; so long and goodnight...") }