Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions buildiffer/Dockerfile.multiarch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM docker.io/golang:1.25-alpine3.22

RUN go install github.com/bazelbuild/buildtools/[email protected]

FROM docker.io/alpine:3.22

LABEL maintainer="openCloud Team [email protected]" \
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"]
22 changes: 22 additions & 0 deletions wait-for/Dockerfile.multiarch
Original file line number Diff line number Diff line change
@@ -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 [email protected]" \
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"]
3 changes: 3 additions & 0 deletions wait-for/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module wait-for

go 1.25.5
48 changes: 48 additions & 0 deletions wait-for/main.go
Original file line number Diff line number Diff line change
@@ -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 <host> -port <port> [-timeout <seconds>]")
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)
}
}