diff --git a/Dockerfile b/Dockerfile index b61c732..edd13c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ RUN dnf install -y go git make gettext \ && popd FROM registry.access.redhat.com/ubi8/ubi-micro:${runner_version} -COPY --from=builder /usr/bin/envsubst /root/go/bin/weed /root/seaweedfs/docker/entrypoint.sh /usr/bin/ +COPY --from=builder /usr/bin/envsubst /root/go/bin/weed /usr/bin/ COPY ./cryostat-entrypoint.bash /usr/bin/ COPY seaweed_conf.template.json /etc/seaweed_conf.template.json ENTRYPOINT ["/usr/bin/cryostat-entrypoint.bash"] diff --git a/cryostat-entrypoint.bash b/cryostat-entrypoint.bash index 68ef82c..042db03 100755 --- a/cryostat-entrypoint.bash +++ b/cryostat-entrypoint.bash @@ -15,7 +15,40 @@ set -xe cfg="$(mktemp)" envsubst '$CRYOSTAT_ACCESS_KEY $CRYOSTAT_SECRET_KEY' < /etc/seaweed_conf.template.json > "${cfg}" -exec /usr/bin/entrypoint.sh \ - server -dir="${DATA_DIR:-/tmp}" \ +function waitForStartup() { + echo "cluster.check" | timeout "${BUCKET_CREATION_STARTUP_SECONDS:-30}"s weed shell 1>/dev/null 2>/dev/null || true + sleep "${BUCKET_CREATION_DELAY_SECONDS:-5}" +} + +function createBucket() { + echo "s3.bucket.create -name $1" | timeout "${BUCKET_CREATION_TIMEOUT_SECONDS:-5}"s weed shell +} + +function createBuckets() { + waitForStartup + for name in "$@"; do + createBucket "${name}" + done +} + +names=() +for i in $(echo "$CRYOSTAT_BUCKETS" | tr ',' '\n'); do + len="${#i}" + if [ "${len}" -lt 3 ]; then + echo "Bucket names must be at least 3 characters" + exit 1 + fi + if [ "${len}" -gt 63 ]; then + echo "Bucket names must be at most 63 characters" + exit 1 + fi + names+=("${i}") +done + +createBuckets "${names[@]}" & + +exec weed -logtostderr=true server \ + -dir="${DATA_DIR:-/tmp}" \ + -master.volumePreallocate="${VOLUME_PREALLOCATE:-true}" -volume.max="${VOLUME_MAX:-0}" -master.volumeSizeLimitMB="${VOLUME_SIZE_LIMIT_MB:-4096}" \ -s3 -s3.config="${cfg}" \ "$@"