diff --git a/buildiffer/Dockerfile.multiarch b/buildiffer/Dockerfile.multiarch new file mode 100644 index 0000000..635ef14 --- /dev/null +++ b/buildiffer/Dockerfile.multiarch @@ -0,0 +1,18 @@ +FROM docker.io/golang:1.25-alpine3.22 + +RUN go install github.com/bazelbuild/buildtools/buildifier@6.1.0 + +FROM docker.io/alpine:3.22 + +LABEL maintainer="openCloud Team team@opencloud.eu" \ + org.opencontainers.image.title="Bazel Buildifier" \ + org.opencontainers.image.vendor="openCloud GmbH" \ + org.opencontainers.image.authors="openCloud GmbH" \ + org.opencontainers.image.description="Custom container with Bazel Buildifier" \ + org.opencontainers.image.documentation="https://github.com/opencloud-eu/container-ci" \ + org.opencontainers.image.url="https://github.com/opencloud-eu/container-ci" \ + org.opencontainers.image.source="https://github.com/opencloud-eu/container-ci" + +COPY --from=0 /go/bin/buildifier /usr/bin/buildifier + +ENTRYPOINT ["buildifier"] \ No newline at end of file diff --git a/wait-for/Dockerfile.multiarch b/wait-for/Dockerfile.multiarch new file mode 100644 index 0000000..07d4edc --- /dev/null +++ b/wait-for/Dockerfile.multiarch @@ -0,0 +1,22 @@ +FROM docker.io/golang:1.25-alpine3.22 AS builder + +WORKDIR /app + +COPY go.mod main.go ./ + +RUN go build -o wait-for . + +FROM alpine:3.22 + +LABEL maintainer="openCloud Team team@opencloud.eu" \ + org.opencontainers.image.description="Custom wait-for container" \ + org.opencontainers.image.vendor="openCloud GmbH" \ + org.opencontainers.image.authors="openCloud GmbH" \ + org.opencontainers.image.title="openCloud CI wait-for" \ + org.opencontainers.image.documentation="https://github.com/opencloud-eu/container-ci" \ + org.opencontainers.image.url="https://github.com/opencloud-eu/container-ci" \ + org.opencontainers.image.source="https://github.com/opencloud-eu/container-ci" + +COPY --from=builder /app/wait-for /usr/bin/wait-for + +ENTRYPOINT ["wait-for"] \ No newline at end of file diff --git a/wait-for/go.mod b/wait-for/go.mod new file mode 100644 index 0000000..616dc44 --- /dev/null +++ b/wait-for/go.mod @@ -0,0 +1,3 @@ +module wait-for + +go 1.25.5 diff --git a/wait-for/main.go b/wait-for/main.go new file mode 100644 index 0000000..c21fa73 --- /dev/null +++ b/wait-for/main.go @@ -0,0 +1,48 @@ +package main + +import ( + "flag" + "fmt" + "net" + "os" + "time" +) + +func main() { + var timeout int + var host, port string + + flag.IntVar(&timeout, "timeout", 30, "Timeout in seconds") + flag.StringVar(&host, "host", "", "Host to wait for") + flag.StringVar(&port, "port", "", "Port to wait for") + + flag.Parse() + + if host == "" || port == "" { + fmt.Println("Usage: wait-for -host -port [-timeout ]") + os.Exit(1) + } + + fmt.Printf("Waiting for %s:%s (timeout: %d seconds)\n", host, port, timeout) + + address := fmt.Sprintf("%s:%s", host, port) + + timeoutDuration := time.Duration(timeout) * time.Second + start := time.Now() + + for { + conn, err := net.DialTimeout("tcp", address, 5*time.Second) + if err == nil { + conn.Close() + fmt.Printf("Service at %s:%s is available after %v\n", host, port, time.Since(start)) + os.Exit(0) + } + + if time.Since(start) > timeoutDuration { + fmt.Printf("Timeout after %d seconds waiting for %s:%s\n", timeout, host, port) + os.Exit(1) + } + + time.Sleep(1 * time.Second) + } +} \ No newline at end of file