Skip to content

Commit

Permalink
feat: temporarily re-add Varnish Kafka support
Browse files Browse the repository at this point in the history
  • Loading branch information
yann-soubeyrand committed Jan 12, 2024
1 parent 6e005b7 commit 0a17b30
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 0a17b30

Please sign in to comment.