diff --git a/main.go b/main.go index ea090a1..16347fd 100644 --- a/main.go +++ b/main.go @@ -33,6 +33,46 @@ func (v *Varnish) Container() *Container { WithFile("/usr/local/bin/varnish-configuration-loader", dag.Host().File("varnish-configuration-loader"), binaryFileOpts) } +func VarnishKafka(container *Container) *Container { + return container. + WithUser("root"). + WithEntrypoint([]string{"sh", "-c"}). + WithExec([]string{`set -x \ +&& BUILD_DEPENDENCIES=" \ + git \ + build-essential \ + librdkafka-dev \ + libyajl-dev \ + varnish-dev=` + version + ` \ + zlib1g-dev" \ +&& apt-get update \ +&& apt-get -y install \ + librdkafka1 \ + libyajl2 \ +&& apt-get -y install --no-install-recommends $BUILD_DEPENDENCIES \ +&& tmp=$(mktemp -d) \ +&& cd $tmp \ +&& git clone https://github.com/camptocamp/varnishkafka/ -b master \ +&& cd varnishkafka \ +&& make && make install \ +&& cd \ +&& rm -rf $tmp \ +&& apt-get purge -y --auto-remove $BUILD_DEPENDENCIES \ +&& apt-get clean \ +&& rm -rf /var/lib/apt/lists/* +`}). + WithUser("varnish") +} + func (v *Varnish) Publish(ctx context.Context, registry string, username string, password string, repository string, tag string) (string, error) { - return v.Container().WithRegistryAuth(registry, username, dag.SetSecret("registry-password", password)).Publish(ctx, registry+"/"+repository+":"+tag) + container := v.Container().WithRegistryAuth(registry, username, dag.SetSecret("registry-password", password)) + + varnishKafkaContainer := container. + With(VarnishKafka) + + if _, err := varnishKafkaContainer.Publish(ctx, registry+"/"+repository+":"+tag+"_varnishkafka"); err != nil { + return "", err + } + + return container.Publish(ctx, registry+"/"+repository+":"+tag) }