feat(deploy): publish Tradarr images to Gitea

This commit is contained in:
2026-11-23 16:17:18 +01:00
parent a857e5b992
commit 18c1010f98
8 changed files with 250 additions and 39 deletions

View File

@ -2,6 +2,7 @@ package server
import (
"os"
"reflect"
"testing"
"gopkg.in/yaml.v3"
@ -46,31 +47,55 @@ func TestStandardComposeRunsLayaOnCPUAndKeepsOllamaOptional(t *testing.T) {
})
}
func TestProductionComposeBuildsBackendFromCurrentLocalCode(t *testing.T) {
data, err := os.ReadFile("../../../docker-compose.prod.yml")
if err != nil {
t.Fatal(err)
func TestProductionComposeUsesPublishedImagesAndPreservesRuntime(t *testing.T) {
read := func(path string) map[string]any {
t.Helper()
data, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
var document map[string]any
if err := yaml.Unmarshal(data, &document); err != nil {
t.Fatal(err)
}
return document
}
var compose struct {
Services map[string]struct {
Image string `yaml:"image"`
Build *struct {
Context string `yaml:"context"`
Dockerfile string `yaml:"dockerfile"`
} `yaml:"build"`
} `yaml:"services"`
standard := read("../../../docker-compose.yml")
production := read("../../../docker-compose.prod.yml")
services := production["services"].(map[string]any)
names := map[string]string{"backend": "backend", "frontend": "frontend", "scraper": "scraper", "laya": "laya"}
for name, raw := range services {
service := raw.(map[string]any)
if _, exists := service["build"]; exists {
t.Errorf("%s still builds", name)
}
if service["pull_policy"] == "build" {
t.Errorf("%s has build pull policy", name)
}
if suffix, ok := names[name]; ok {
want := "gitea.anthonybouteiller.ovh/blomios/tradarr-" + suffix + ":${TRADARR_IMAGE_TAG:?TRADARR_IMAGE_TAG is required}"
if service["image"] != want {
t.Errorf("%s image=%v", name, service["image"])
}
}
original := standard["services"].(map[string]any)[name].(map[string]any)
delete(original, "build")
delete(original, "pull_policy")
if _, ok := names[name]; ok {
delete(original, "image")
delete(service, "image")
}
if name == "backend" {
if service["stop_grace_period"] != "5m" {
t.Error("production shutdown grace lost")
}
delete(service, "stop_grace_period")
}
if !reflect.DeepEqual(original, service) {
t.Errorf("%s runtime differs from standard Compose", name)
}
}
if err := yaml.Unmarshal(data, &compose); err != nil {
t.Fatalf("parse docker-compose.prod.yml: %v", err)
}
backend, ok := compose.Services["backend"]
if !ok {
t.Fatal("production Compose has no backend service")
}
if backend.Build == nil || backend.Build.Context != "./backend" {
t.Errorf("backend build=%+v; want an image built from local ./backend source", backend.Build)
}
if backend.Image == "gitea.anthonybouteiller.ovh/blomios/tradarr-backend:v1.1.0" {
t.Errorf("backend still pins historical v1.1.0 image instead of current ticket code")
if !reflect.DeepEqual(standard["volumes"], production["volumes"]) {
t.Error("volumes differ")
}
}