commit 20d03769e1ad48a5c0846ae5948f189dc8e9ccb6 Author: Marc Plano-Lesay Date: Tue Dec 9 09:30:47 2025 +1100 Initial commit diff --git a/.dagger/.gitattributes b/.dagger/.gitattributes new file mode 100644 index 0000000..3a45493 --- /dev/null +++ b/.dagger/.gitattributes @@ -0,0 +1,4 @@ +/dagger.gen.go linguist-generated +/internal/dagger/** linguist-generated +/internal/querybuilder/** linguist-generated +/internal/telemetry/** linguist-generated diff --git a/.dagger/.gitignore b/.dagger/.gitignore new file mode 100644 index 0000000..773338b --- /dev/null +++ b/.dagger/.gitignore @@ -0,0 +1,5 @@ +/dagger.gen.go +/internal/dagger +/internal/querybuilder +/internal/telemetry +/.env diff --git a/.dagger/go.mod b/.dagger/go.mod new file mode 100644 index 0000000..c1ac057 --- /dev/null +++ b/.dagger/go.mod @@ -0,0 +1,51 @@ +module dagger/containers + +go 1.25.5 + +require ( + github.com/99designs/gqlgen v0.17.81 + github.com/Khan/genqlient v0.8.1 + github.com/vektah/gqlparser/v2 v2.5.30 + go.opentelemetry.io/otel v1.38.0 + go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.14.0 + go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.14.0 + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.38.0 + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.38.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.38.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 + go.opentelemetry.io/otel/log v0.14.0 + go.opentelemetry.io/otel/metric v1.38.0 + go.opentelemetry.io/otel/sdk v1.38.0 + go.opentelemetry.io/otel/sdk/log v0.14.0 + go.opentelemetry.io/otel/sdk/metric v1.38.0 + go.opentelemetry.io/otel/trace v1.38.0 + go.opentelemetry.io/proto/otlp v1.8.0 + golang.org/x/sync v0.17.0 + google.golang.org/grpc v1.76.0 +) + +require ( + github.com/cenkalti/backoff/v5 v5.0.3 // indirect + github.com/go-logr/logr v1.4.3 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect + github.com/sosodev/duration v1.3.1 // indirect + go.opentelemetry.io/auto/sdk v1.1.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 // indirect + golang.org/x/net v0.44.0 // indirect + golang.org/x/sys v0.36.0 // indirect + golang.org/x/text v0.29.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 // indirect + google.golang.org/protobuf v1.36.9 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.14.0 + +replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.14.0 + +replace go.opentelemetry.io/otel/log => go.opentelemetry.io/otel/log v0.14.0 + +replace go.opentelemetry.io/otel/sdk/log => go.opentelemetry.io/otel/sdk/log v0.14.0 diff --git a/.dagger/go.sum b/.dagger/go.sum new file mode 100644 index 0000000..39e1c4a --- /dev/null +++ b/.dagger/go.sum @@ -0,0 +1,90 @@ +github.com/99designs/gqlgen v0.17.81 h1:kCkN/xVyRb5rEQpuwOHRTYq83i0IuTQg9vdIiwEerTs= +github.com/99designs/gqlgen v0.17.81/go.mod h1:vgNcZlLwemsUhYim4dC1pvFP5FX0pr2Y+uYUoHFb1ig= +github.com/Khan/genqlient v0.8.1 h1:wtOCc8N9rNynRLXN3k3CnfzheCUNKBcvXmVv5zt6WCs= +github.com/Khan/genqlient v0.8.1/go.mod h1:R2G6DzjBvCbhjsEajfRjbWdVglSH/73kSivC9TLWVjU= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM= +github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 h1:8Tjv8EJ+pM1xP8mK6egEbD1OgnVTyacbefKhmbLhIhU= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2/go.mod h1:pkJQ2tZHJ0aFOVEEot6oZmaVEZcRme73eIFmhiVuRWs= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= +github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= +github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4= +github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/vektah/gqlparser/v2 v2.5.30 h1:EqLwGAFLIzt1wpx1IPpY67DwUujF1OfzgEyDsLrN6kE= +github.com/vektah/gqlparser/v2 v2.5.30/go.mod h1:D1/VCZtV3LPnQrcPBeR/q5jkSQIPti0uYCP/RI0gIeo= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= +go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= +go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.14.0 h1:OMqPldHt79PqWKOMYIAQs3CxAi7RLgPxwfFSwr4ZxtM= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.14.0/go.mod h1:1biG4qiqTxKiUCtoWDPpL3fB3KxVwCiGw81j3nKMuHE= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.14.0 h1:QQqYw3lkrzwVsoEX0w//EhH/TCnpRdEenKBOOEIMjWc= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.14.0/go.mod h1:gSVQcr17jk2ig4jqJ2DX30IdWH251JcNAecvrqTxH1s= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.38.0 h1:vl9obrcoWVKp/lwl8tRE33853I8Xru9HFbw/skNeLs8= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.38.0/go.mod h1:GAXRxmLJcVM3u22IjTg74zWBrRCKq8BnOqUVLodpcpw= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.38.0 h1:Oe2z/BCg5q7k4iXC3cqJxKYg0ieRiOqF0cecFYdPTwk= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.38.0/go.mod h1:ZQM5lAJpOsKnYagGg/zV2krVqTtaVdYdDkhMoX6Oalg= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 h1:GqRJVj7UmLjCVyVJ3ZFLdPRmhDUp2zFmQe3RHIOsw24= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0/go.mod h1:ri3aaHSmCTVYu2AWv44YMauwAQc0aqI9gHKIcSbI1pU= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.38.0 h1:lwI4Dc5leUqENgGuQImwLo4WnuXFPetmPpkLi2IrX54= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.38.0/go.mod h1:Kz/oCE7z5wuyhPxsXDuaPteSWqjSBD5YaSdbxZYGbGk= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 h1:aTL7F04bJHUlztTsNGJ2l+6he8c+y/b//eR0jjjemT4= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0/go.mod h1:kldtb7jDTeol0l3ewcmd8SDvx3EmIE7lyvqbasU3QC4= +go.opentelemetry.io/otel/log v0.14.0 h1:2rzJ+pOAZ8qmZ3DDHg73NEKzSZkhkGIua9gXtxNGgrM= +go.opentelemetry.io/otel/log v0.14.0/go.mod h1:5jRG92fEAgx0SU/vFPxmJvhIuDU9E1SUnEQrMlJpOno= +go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= +go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= +go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= +go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= +go.opentelemetry.io/otel/sdk/log v0.14.0 h1:JU/U3O7N6fsAXj0+CXz21Czg532dW2V4gG1HE/e8Zrg= +go.opentelemetry.io/otel/sdk/log v0.14.0/go.mod h1:imQvII+0ZylXfKU7/wtOND8Hn4OpT3YUoIgqJVksUkM= +go.opentelemetry.io/otel/sdk/log/logtest v0.14.0 h1:Ijbtz+JKXl8T2MngiwqBlPaHqc4YCaP/i13Qrow6gAM= +go.opentelemetry.io/otel/sdk/log/logtest v0.14.0/go.mod h1:dCU8aEL6q+L9cYTqcVOk8rM9Tp8WdnHOPLiBgp0SGOA= +go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= +go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= +go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= +go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= +go.opentelemetry.io/proto/otlp v1.8.0 h1:fRAZQDcAFHySxpJ1TwlA1cJ4tvcrw7nXl9xWWC8N5CE= +go.opentelemetry.io/proto/otlp v1.8.0/go.mod h1:tIeYOeNBU4cvmPqpaji1P+KbB4Oloai8wN4rWzRrFF0= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I= +golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= +golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= +golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= +golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= +golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= +gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= +gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= +google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 h1:BIRfGDEjiHRrk0QKZe3Xv2ieMhtgRGeLcZQ0mIVn4EY= +google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5/go.mod h1:j3QtIyytwqGr1JUDtYXwtMXWPKsEa5LtzIFN1Wn5WvE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 h1:eaY8u2EuxbRv7c3NiGK0/NedzVsCcV6hDuU5qPX5EGE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5/go.mod h1:M4/wBTSeyLxupu3W3tJtOgB14jILAS/XWPSSa3TAlJc= +google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= +google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= +google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw= +google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/.dagger/main.go b/.dagger/main.go new file mode 100644 index 0000000..154f32f --- /dev/null +++ b/.dagger/main.go @@ -0,0 +1,445 @@ +// Container image builder for Ubuntu and Chainguard-based images with extensible tools +package main + +import ( + "context" + "dagger/containers/internal/dagger" + "fmt" + + "gopkg.in/yaml.v3" +) + +type Containers struct{} + +// Configuration structures +type ToolsConfig struct { + Core CoreTools `yaml:"core"` + Tools map[string]ToolDef `yaml:"tools"` +} + +type CoreTools struct { + Git string `yaml:"git"` + Jq string `yaml:"jq"` + Yq string `yaml:"yq"` + Node20 string `yaml:"node20"` + Node22 string `yaml:"node22"` + Node24 string `yaml:"node24"` +} + +type ToolDef struct { + Version string `yaml:"version"` + Description string `yaml:"description"` +} + +// Load tools configuration from YAML +func (m *Containers) loadConfig(ctx context.Context, configFile *dagger.File) (*ToolsConfig, error) { + content, err := configFile.Contents(ctx) + if err != nil { + return nil, err + } + + var config ToolsConfig + if err := yaml.Unmarshal([]byte(content), &config); err != nil { + return nil, err + } + + return &config, nil +} + +// archFor returns architecture strings used by various upstream releases. +// arch: used by jq/yq/kustomize/dagger ("amd64"|"arm64") +// goArch: used by zola ("x86_64"|"aarch64") +func (m *Containers) archFor(platform dagger.Platform) (arch, goArch string) { + arch = "amd64" + goArch = "x86_64" + if platform == "linux/arm64" { + arch = "arm64" + goArch = "aarch64" + } + return +} + +// withHTTPExecutable downloads a file via Dagger HTTP and installs it to dst with +x +func (m *Containers) withHTTPExecutable(ctr *dagger.Container, url, dst string) *dagger.Container { + file := dag.HTTP(url) + return ctr.WithFile(dst, file).WithExec([]string{"chmod", "+x", dst}) +} + +// withHTTPFile downloads a remote file via Dagger HTTP to a temporary path +func (m *Containers) withHTTPFile(ctr *dagger.Container, url, tmpPath string) *dagger.Container { + file := dag.HTTP(url) + return ctr.WithFile(tmpPath, file) +} + +// extractTarGz extracts a .tar.gz archive to destination directory +func (m *Containers) extractTarGz(ctr *dagger.Container, archivePath, destDir string) *dagger.Container { + return ctr.WithExec([]string{"tar", "-xzf", archivePath, "-C", destDir}) +} + +// installJq installs jq for the provided arch into /usr/local/bin +func (m *Containers) installJq(ctr *dagger.Container, config *ToolsConfig, arch string) *dagger.Container { + jqURL := fmt.Sprintf("https://github.com/jqlang/jq/releases/download/jq-%s/jq-linux-%s", config.Core.Jq, arch) + ctr = m.withHTTPExecutable(ctr, jqURL, "/usr/local/bin/jq") + + return ctr +} + +// installYq installs yq for the provided arch into /usr/local/bin +func (m *Containers) installYq(ctr *dagger.Container, config *ToolsConfig, arch string) *dagger.Container { + yqURL := fmt.Sprintf("https://github.com/mikefarah/yq/releases/download/v%s/yq_linux_%s", config.Core.Yq, arch) + ctr = m.withHTTPExecutable(ctr, yqURL, "/usr/local/bin/yq") + + return ctr +} + +// installKustomize downloads and installs kustomize for the given arch +func (m *Containers) installKustomize(ctr *dagger.Container, toolDef ToolDef, arch string) *dagger.Container { + url := fmt.Sprintf("https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%%2Fv%s/kustomize_v%s_linux_%s.tar.gz", toolDef.Version, toolDef.Version, arch) + tmp := fmt.Sprintf("/tmp/kustomize_v%s_linux_%s.tar.gz", toolDef.Version, arch) + ctr = m.withHTTPFile(ctr, url, tmp) + + return m.extractTarGz(ctr, tmp, "/usr/local/bin") +} + +// installDagger downloads and installs dagger CLI for the given arch +func (m *Containers) installDagger(ctr *dagger.Container, toolDef ToolDef, arch string) *dagger.Container { + url := fmt.Sprintf("https://github.com/dagger/dagger/releases/download/v%s/dagger_v%s_linux_%s.tar.gz", toolDef.Version, toolDef.Version, arch) + tmp := fmt.Sprintf("/tmp/dagger_v%s_linux_%s.tar.gz", toolDef.Version, arch) + ctr = m.withHTTPFile(ctr, url, tmp) + + return m.extractTarGz(ctr, tmp, "/usr/local/bin") +} + +// installZola downloads and installs zola for the given goArch +func (m *Containers) installZola(ctr *dagger.Container, toolDef ToolDef, goArch string) *dagger.Container { + url := fmt.Sprintf("https://github.com/getzola/zola/releases/download/v%s/zola-v%s-%s-unknown-linux-gnu.tar.gz", toolDef.Version, toolDef.Version, goArch) + tmp := fmt.Sprintf("/tmp/zola-v%s-%s-unknown-linux-gnu.tar.gz", toolDef.Version, goArch) + ctr = m.withHTTPFile(ctr, url, tmp) + + return m.extractTarGz(ctr, tmp, "/usr/local/bin") +} + +// Build Ubuntu base image with core tools +func (m *Containers) buildUbuntuBase(ctx context.Context, config *ToolsConfig, platform dagger.Platform) *dagger.Container { + ctr := dag.Container(dagger.ContainerOpts{Platform: platform}).From("ubuntu:24.04") + + // Determine architecture for downloads + arch, _ := m.archFor(platform) + // Node.js uses "x64" for amd64 in official tarball names + nodeArch := arch + if arch == "amd64" { + nodeArch = "x64" + } + + // Update and install base dependencies + ctr = ctr.WithExec([]string{"apt-get", "update"}). + WithExec([]string{"apt-get", "install", "-y", + "ca-certificates", + "curl", + "wget", + "gnupg", + "lsb-release", + "xz-utils", + }) + + // Install Git + ctr = ctr.WithExec([]string{"apt-get", "install", "-y", "git"}) + + // Install jq & yq + ctr = m.installJq(ctr, config, arch) + ctr = m.installYq(ctr, config, arch) + + // Install multiple Node.js versions side-by-side (20, 22, 24) + // We fetch official tarballs and create versioned shims: node20/node22/node24 and npm20/npm22/npm24 + // Default `node`/`npm` will point to Node 24 + // Prepare Node.js tarballs via Dagger HTTP (cached) and install three versions side-by-side + { + nodeURL := func(ver string) string { + return fmt.Sprintf("https://nodejs.org/dist/v%s/node-v%s-linux-%s.tar.xz", ver, ver, nodeArch) + } + n20 := dag.HTTP(nodeURL(config.Core.Node20)) + n22 := dag.HTTP(nodeURL(config.Core.Node22)) + n24 := dag.HTTP(nodeURL(config.Core.Node24)) + + n20Name := fmt.Sprintf("/tmp/node-v%s-linux-%s.tar.xz", config.Core.Node20, nodeArch) + n22Name := fmt.Sprintf("/tmp/node-v%s-linux-%s.tar.xz", config.Core.Node22, nodeArch) + n24Name := fmt.Sprintf("/tmp/node-v%s-linux-%s.tar.xz", config.Core.Node24, nodeArch) + + ctr = ctr.WithFile(n20Name, n20). + WithFile(n22Name, n22). + WithFile(n24Name, n24) + + // Use bash for pipefail support (dash/sh doesn't support 'pipefail') + ctr = ctr.WithExec([]string{"bash", "-lc", + fmt.Sprintf(`set -euo pipefail +mkdir -p /opt + +extract_node() { + tarball="$1" + ver="$2" + major="$3" + dest="/opt/node-v${ver}" + mkdir -p "$dest" + # Official tarballs extract as node-v-linux-; normalize into /opt/node-v + tar -xJf "$tarball" -C "$dest" --strip-components=1 + if [ ! -d "$dest" ]; then + echo "Expected $dest to exist after extraction" >&2 + exit 1 + fi + ln -sf "$dest/bin/node" "/usr/local/bin/node${major}" + ln -sf "$dest/bin/npm" "/usr/local/bin/npm${major}" + if [ -f "$dest/bin/npx" ]; then + ln -sf "$dest/bin/npx" "/usr/local/bin/npx${major}" + fi +} + +extract_node "%s" "%s" 20 +extract_node "%s" "%s" 22 +extract_node "%s" "%s" 24 + +# Set default to Node 24 +ln -sf "/usr/local/bin/node24" "/usr/local/bin/node" +ln -sf "/usr/local/bin/npm24" "/usr/local/bin/npm" +if [ -e "/usr/local/bin/npx24" ]; then + ln -sf "/usr/local/bin/npx24" "/usr/local/bin/npx" +fi +`, n20Name, config.Core.Node20, n22Name, config.Core.Node22, n24Name, config.Core.Node24)}) + } + + // Clean up + ctr = ctr.WithExec([]string{"apt-get", "clean"}). + WithExec([]string{"rm", "-rf", "/var/lib/apt/lists/*"}) + + return ctr +} + +// Build Chainguard base image with core tools +func (m *Containers) buildChainguardBase(ctx context.Context, config *ToolsConfig, platform dagger.Platform) *dagger.Container { + // Using Chainguard's Wolfi-based images which are minimal + ctr := dag.Container(dagger.ContainerOpts{Platform: platform}).From("cgr.dev/chainguard/wolfi-base:latest") + + // Determine architecture for downloads + arch, _ := m.archFor(platform) + + // Install core tools using apk (Wolfi package manager) + ctr = ctr.WithExec([]string{"apk", "update"}). + WithExec([]string{"apk", "add", "git", "curl", "wget", "bash", "ca-certificates"}) + + // Create /usr/local/bin if it doesn't exist + ctr = ctr.WithExec([]string{"mkdir", "-p", "/usr/local/bin"}) + + // Install jq & yq + ctr = m.installJq(ctr, config, arch) + ctr = m.installYq(ctr, config, arch) + + // Install Node.js + ctr = ctr.WithExec([]string{"apk", "add", "nodejs", "npm"}) + + return ctr +} + +// Build Ubuntu image with specific tool +func (m *Containers) buildUbuntuTool(ctx context.Context, base *dagger.Container, toolName string, toolDef ToolDef, platform dagger.Platform) *dagger.Container { + ctr := base + + // Determine architecture for downloads + arch, goArch := m.archFor(platform) + + switch toolName { + case "kustomize": + ctr = m.installKustomize(ctr, toolDef, arch) + + case "dagger": + ctr = m.installDagger(ctr, toolDef, arch) + + case "esphome": + ctr = ctr.WithExec([]string{"apt-get", "update"}). + WithExec([]string{"apt-get", "install", "-y", "python3", "python3-pip", "python3-venv"}). + WithExec([]string{"pip3", "install", "--break-system-packages", fmt.Sprintf("esphome==%s", toolDef.Version)}). + WithExec([]string{"apt-get", "clean"}) + + case "zola": + ctr = m.installZola(ctr, toolDef, goArch) + + case "yamllint": + ctr = ctr.WithExec([]string{"apt-get", "update"}). + WithExec([]string{"apt-get", "install", "-y", "python3", "python3-pip"}). + WithExec([]string{"pip3", "install", "--break-system-packages", fmt.Sprintf("yamllint==%s", toolDef.Version)}). + WithExec([]string{"apt-get", "clean"}) + } + + return ctr +} + +// Build Chainguard image with specific tool +func (m *Containers) buildChainguardTool(ctx context.Context, base *dagger.Container, toolName string, toolDef ToolDef, platform dagger.Platform) *dagger.Container { + ctr := base + + // Determine architecture for downloads + arch, goArch := m.archFor(platform) + + switch toolName { + case "kustomize": + ctr = m.installKustomize(ctr, toolDef, arch) + + case "dagger": + ctr = m.installDagger(ctr, toolDef, arch) + + case "esphome": + ctr = ctr.WithExec([]string{"apk", "add", "python3", "py3-pip"}). + WithExec([]string{"pip3", "install", fmt.Sprintf("esphome==%s", toolDef.Version)}) + + case "zola": + ctr = m.installZola(ctr, toolDef, goArch) + + case "yamllint": + ctr = ctr.WithExec([]string{"apk", "add", "python3", "py3-pip"}). + WithExec([]string{"pip3", "install", fmt.Sprintf("yamllint==%s", toolDef.Version)}) + } + + return ctr +} + +// BuildAll builds all container images for multiple architectures +func (m *Containers) BuildAll(ctx context.Context, + // Configuration file + configFile *dagger.File, + // Registry to push images to + // +optional + registry string, + // Optional image name prefix to insert between registry and image name (e.g., "foo" -> registry/foo/image:tag) + // +optional + prefix string, + // Username for authenticating to the registry + // +optional + registryUsername string, + // Password/token for authenticating to the registry + // +optional + registryPassword *dagger.Secret, +) error { + // Load configuration + config, err := m.loadConfig(ctx, configFile) + if err != nil { + return fmt.Errorf("failed to load config: %w", err) + } + + platforms := []dagger.Platform{"linux/amd64", "linux/arm64"} + + // Build and publish Ubuntu base + ubuntuBaseTag := "ubuntu-runner:24.04" + if prefix != "" { + ubuntuBaseTag = fmt.Sprintf("%s/%s/%s", registry, prefix, ubuntuBaseTag) + } else { + ubuntuBaseTag = fmt.Sprintf("%s/%s", registry, ubuntuBaseTag) + } + + var ubuntuBaseVariants []*dagger.Container + for _, platform := range platforms { + ubuntuBase := m.buildUbuntuBase(ctx, config, platform) + ubuntuBaseVariants = append(ubuntuBaseVariants, ubuntuBase) + } + + // Configure registry auth if provided + publisher := dag.Container() + if registry != "" && registryUsername != "" && registryPassword != nil { + publisher = publisher.WithRegistryAuth(registry, registryUsername, registryPassword) + } + + if _, err := publisher.Publish(ctx, ubuntuBaseTag, dagger.ContainerPublishOpts{ + PlatformVariants: ubuntuBaseVariants, + }); err != nil { + return fmt.Errorf("failed to publish ubuntu base: %w", err) + } + fmt.Printf("Published (multi-arch): %s\n", ubuntuBaseTag) + + // Build and publish tool-specific images + for toolName, toolDef := range config.Tools { + // Ubuntu variant + var ubuntuToolVariants []*dagger.Container + for _, platform := range platforms { + ubuntuBase := m.buildUbuntuBase(ctx, config, platform) + ubuntuTool := m.buildUbuntuTool(ctx, ubuntuBase, toolName, toolDef, platform) + ubuntuToolVariants = append(ubuntuToolVariants, ubuntuTool) + } + + ubuntuTag := fmt.Sprintf("ubuntu-%s:%s", toolName, toolDef.Version) + if prefix != "" { + ubuntuTag = fmt.Sprintf("%s/%s/%s", registry, prefix, ubuntuTag) + } else { + ubuntuTag = fmt.Sprintf("%s/%s", registry, ubuntuTag) + } + publisher := dag.Container() + if registry != "" && registryUsername != "" && registryPassword != nil { + publisher = publisher.WithRegistryAuth(registry, registryUsername, registryPassword) + } + if _, err := publisher.Publish(ctx, ubuntuTag, dagger.ContainerPublishOpts{ + PlatformVariants: ubuntuToolVariants, + }); err != nil { + return fmt.Errorf("failed to publish ubuntu-%s: %w", toolName, err) + } + fmt.Printf("Published (multi-arch): %s\n", ubuntuTag) + + // Chainguard variant + var chainguardToolVariants []*dagger.Container + for _, platform := range platforms { + chainguardBase := m.buildChainguardBase(ctx, config, platform) + chainguardTool := m.buildChainguardTool(ctx, chainguardBase, toolName, toolDef, platform) + chainguardToolVariants = append(chainguardToolVariants, chainguardTool) + } + + chainguardTag := fmt.Sprintf("%s:%s", toolName, toolDef.Version) + if prefix != "" { + chainguardTag = fmt.Sprintf("%s/%s/%s", registry, prefix, chainguardTag) + } else { + chainguardTag = fmt.Sprintf("%s/%s", registry, chainguardTag) + } + publisher = dag.Container() + if registry != "" && registryUsername != "" && registryPassword != nil { + publisher = publisher.WithRegistryAuth(registry, registryUsername, registryPassword) + } + if _, err := publisher.Publish(ctx, chainguardTag, dagger.ContainerPublishOpts{ + PlatformVariants: chainguardToolVariants, + }); err != nil { + return fmt.Errorf("failed to publish %s: %w", toolName, err) + } + fmt.Printf("Published (multi-arch): %s\n", chainguardTag) + } + + return nil +} + +// Build a single tool image +func (m *Containers) BuildTool(ctx context.Context, + // Tool name to build (e.g., "kustomize", "dagger") + tool string, + // Configuration file + configFile *dagger.File, + // Base image type: "ubuntu" or "chainguard" + // +optional + // +default="ubuntu" + base string, + // Platform to build for + // +optional + // +default="linux/amd64" + platform dagger.Platform, +) (*dagger.Container, error) { + // Load configuration + config, err := m.loadConfig(ctx, configFile) + if err != nil { + return nil, fmt.Errorf("failed to load config: %w", err) + } + + toolDef, ok := config.Tools[tool] + if !ok { + return nil, fmt.Errorf("tool %s not found in config", tool) + } + + var baseImage *dagger.Container + if base == "ubuntu" { + baseImage = m.buildUbuntuBase(ctx, config, platform) + return m.buildUbuntuTool(ctx, baseImage, tool, toolDef, platform), nil + } else { + baseImage = m.buildChainguardBase(ctx, config, platform) + return m.buildChainguardTool(ctx, baseImage, tool, toolDef, platform), nil + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/.mise.toml b/.mise.toml new file mode 100644 index 0000000..1ed0d58 --- /dev/null +++ b/.mise.toml @@ -0,0 +1,3 @@ +[tools] +dagger = "0.19.8" +go = "1.25.5" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..137069b --- /dev/null +++ b/LICENSE @@ -0,0 +1,73 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + + (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + + You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + +To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..b4337ea --- /dev/null +++ b/README.md @@ -0,0 +1,168 @@ +# Container Image Builder + +Dagger-based pipeline for building extensible container images with two base variants (Ubuntu 24.04 and Chainguard) and customizable tool sets. + +## Overview + +This project provides a systematic way to build and maintain container images with: +- **Multi-architecture support**: All images built for linux/amd64 and linux/arm64 +- **Two base image variants**: Ubuntu 24.04 and Chainguard (Wolfi-based) +- **Core tools** available in all images: Git, jq, yq, Node.js (20/22/24) +- **Specialized tools** as separate image variants: kustomize, Dagger, ESPHome, Zola, yamllint +- **Automated dependency updates** via Renovate + +## Prerequisites + +- [Mise](https://mise.jdx.dev/) for tool management +- Docker or compatible container runtime (for running Dagger) + +## Setup + +1. Install tools via Mise: +```bash +mise install +``` + +This installs: +- Dagger 0.19.8 +- Go 1.23 + +2. Verify installation: +```bash +dagger version +``` + +## Usage + +### Building Individual Tool Images + +Build a specific tool image: + +```bash +# Ubuntu-based image (default: amd64) +dagger call build-tool --tool=yamllint --config-file=tools.yaml --base=ubuntu + +# Chainguard-based image (default: amd64) +dagger call build-tool --tool=kustomize --config-file=tools.yaml --base=chainguard + +# Build for arm64 platform +dagger call build-tool --tool=yamllint --config-file=tools.yaml --platform=linux/arm64 + +# Build for amd64 platform (explicit) +dagger call build-tool --tool=yamllint --config-file=tools.yaml --platform=linux/amd64 +``` + +### Verifying Tool Installation + +```bash +# Check yamllint version +dagger call build-tool --tool=yamllint --config-file=tools.yaml \ + with-exec --args=yamllint,--version stdout + +# Check multiple tools +dagger call build-tool --tool=yamllint --config-file=tools.yaml \ + with-exec --args=jq,--version \ + with-exec --args=yq,--version \ + with-exec --args=node,--version stdout +``` + +### Building All Images + +Build and publish all images to a registry (multi-arch: amd64 + arm64): + +```bash +dagger call build-all --config-file=tools.yaml --registry=docker.io/myorg +``` + +This creates multi-architecture images with the following naming scheme: +- **Ubuntu base**: `ubuntu-runner:24.04` (amd64 + arm64) +- **Ubuntu + tool**: `ubuntu-{tool}:{version}` (e.g., `ubuntu-esphome:2025.11.2`) (amd64 + arm64) +- **Chainguard + tool**: `{tool}:{version}` (e.g., `esphome:2025.11.2`) (amd64 + arm64) + +All images are published as multi-platform manifests supporting both linux/amd64 and linux/arm64. + +## Configuration + +### Adding New Tools + +Edit `tools.yaml` to add new tools: + +```yaml +tools: + newtool: + version: "1.2.3" + description: "Description of the new tool" +``` + +Then update `dagger/main.go` to add installation logic in both `buildUbuntuTool()` and `buildChainguardTool()` functions. + +### Updating Tool Versions + +Tool versions are managed in `tools.yaml`. Renovate will automatically create PRs to update these versions. + +## Architecture + +- **`tools.yaml`**: Version configuration for all tools +- **`dagger/main.go`**: Dagger pipeline implementation +- **`renovate.json`**: Renovate configuration for automated updates +- **`.mise.toml`**: Mise tool version management + +## Available Tools + +### Core Tools (all images) +- Git +- jq +- yq +- Node.js (20, 22, 24) + +### Specialized Tools +- **kustomize**: Kubernetes configuration customization +- **dagger**: Application delivery as code +- **esphome**: ESPHome firmware builder +- **zola**: Static site generator +- **yamllint**: YAML linter + +## Renovate Integration + +The project is configured with Renovate to automatically: +- Monitor releases for all tools +- Create PRs when new versions are available +- Update both `tools.yaml` and `.mise.toml` files + +## Development + +### Project Structure + +``` +. +├── dagger/ +│ ├── main.go # Dagger module implementation +│ ├── go.mod +│ └── go.sum +├── tools.yaml # Tool version configuration +├── renovate.json # Renovate configuration +├── .mise.toml # Mise configuration +└── README.md # This file +``` + +### Local Testing + +Test building a single tool image locally: + +```bash +dagger call build-tool --tool=yamllint --config-file=tools.yaml +``` + +## Image Tags + +Images follow a consistent tagging scheme: + +| Base | Tool | Tag Format | Example | +|------|------|------------|---------| +| Ubuntu | None | `ubuntu-runner:24.04` | Base Ubuntu image | +| Ubuntu | Any | `ubuntu-{tool}:{version}` | `ubuntu-kustomize:5.5.0` | +| Chainguard | Any | `{tool}:{version}` | `kustomize:5.5.0` | + +## License + +Apache-2.0 diff --git a/dagger.json b/dagger.json new file mode 100644 index 0000000..36d348f --- /dev/null +++ b/dagger.json @@ -0,0 +1,8 @@ +{ + "name": "containers", + "engineVersion": "v0.19.8", + "sdk": { + "source": "go" + }, + "source": ".dagger" +} diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..8def394 --- /dev/null +++ b/renovate.json @@ -0,0 +1,109 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "assignees": ["kernald"], + "extends": [ + "config:recommended" + ], + "description": "Renovate configuration for container tool versions", + "packageRules": [ + { + "description": "Update Git version in tools.yaml", + "matchFileNames": ["tools.yaml"], + "matchPackageNames": ["git"], + "datasourceTemplate": "github-tags", + "depNameTemplate": "git/git", + "extractVersionTemplate": "^v(?.*)$" + }, + { + "description": "Update jq version in tools.yaml", + "matchFileNames": ["tools.yaml"], + "matchPackageNames": ["jq"], + "datasourceTemplate": "github-releases", + "depNameTemplate": "jqlang/jq", + "extractVersionTemplate": "^jq-(?.*)$" + }, + { + "description": "Update yq version in tools.yaml", + "matchFileNames": ["tools.yaml"], + "matchPackageNames": ["yq"], + "datasourceTemplate": "github-releases", + "depNameTemplate": "mikefarah/yq", + "extractVersionTemplate": "^v(?.*)$" + }, + { + "description": "Update Node.js versions in tools.yaml", + "matchFileNames": ["tools.yaml"], + "matchPackagePatterns": ["^node"], + "datasourceTemplate": "node-version" + }, + { + "description": "Update kustomize version in tools.yaml", + "matchFileNames": ["tools.yaml"], + "matchPackageNames": ["kustomize"], + "datasourceTemplate": "github-releases", + "depNameTemplate": "kubernetes-sigs/kustomize", + "extractVersionTemplate": "^kustomize/v(?.*)$" + }, + { + "description": "Update Dagger version in tools.yaml and .mise.toml", + "matchFileNames": ["tools.yaml", ".mise.toml"], + "matchPackageNames": ["dagger"], + "datasourceTemplate": "github-releases", + "depNameTemplate": "dagger/dagger", + "extractVersionTemplate": "^v(?.*)$" + }, + { + "description": "Update ESPHome version in tools.yaml", + "matchFileNames": ["tools.yaml"], + "matchPackageNames": ["esphome"], + "datasourceTemplate": "pypi", + "depNameTemplate": "esphome" + }, + { + "description": "Update Zola version in tools.yaml", + "matchFileNames": ["tools.yaml"], + "matchPackageNames": ["zola"], + "datasourceTemplate": "github-releases", + "depNameTemplate": "getzola/zola", + "extractVersionTemplate": "^v(?.*)$" + }, + { + "description": "Update yamllint version in tools.yaml", + "matchFileNames": ["tools.yaml"], + "matchPackageNames": ["yamllint"], + "datasourceTemplate": "pypi", + "depNameTemplate": "yamllint" + }, + { + "description": "Update Go version in .mise.toml", + "matchFileNames": [".mise.toml"], + "matchPackageNames": ["go"], + "datasourceTemplate": "golang-version" + } + ], + "regexManagers": [ + { + "description": "Update versions in tools.yaml", + "fileMatch": ["^tools\\.yaml$"], + "matchStrings": [ + "(?git|jq|yq|node20|node22|node24|kustomize|dagger|esphome|zola|yamllint):\\s*\"(?[^\"]+)\"" + ], + "datasourceTemplate": "custom" + } + ], + "customManagers": [ + { + "customType": "regex", + "description": "Update tool versions in tools.yaml", + "fileMatch": ["^tools\\.yaml$"], + "matchStrings": [ + "\\s+(?\\w+):\\s*\\n\\s+version:\\s+\"(?[^\"]+)\"" + ], + "datasourceTemplate": "github-releases" + } + ], + "labels": ["dependencies", "renovate"], + "vulnerabilityAlerts": { + "enabled": true + } +} diff --git a/tools.yaml b/tools.yaml new file mode 100644 index 0000000..7a4b626 --- /dev/null +++ b/tools.yaml @@ -0,0 +1,33 @@ +# Tool versions configuration +# This file is used by both Dagger pipelines and Renovate for version management + +# Core tools available in all images +core: + git: "2.45.2" + jq: "1.7.1" + yq: "4.44.3" + node20: "20.19.6" + node22: "22.21.1" + node24: "24.11.1" + +# Specialized tools for custom images +tools: + kustomize: + version: "5.5.0" + description: "Kubernetes configuration customization tool" + + dagger: + version: "0.19.8" + description: "Application delivery as code" + + esphome: + version: "2025.11.2" + description: "ESPHome firmware builder" + + zola: + version: "0.20.0" + description: "Static site generator" + + yamllint: + version: "1.35.1" + description: "YAML linter"