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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ RUN sentry-cli --version \
FROM debian:buster-slim

RUN apt-get update \
&& apt-get install -y ca-certificates gosu --no-install-recommends \
&& apt-get install -y ca-certificates gosu curl --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
23 changes: 23 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,29 @@ if [[ -n "${RELAY_DELAY_STARTUP_SECONDS:-}" ]]; then
sleep "${RELAY_DELAY_STARTUP_SECONDS}"
fi

# Make sure that a specified URL (e.g. the upstream or a proxy sidecar) is reachable before starting.
# Only 200 response is accepted as success.
if [[ -n "${RELAY_PRESTART_ENDPOINT:-}" ]]; then
max_retry="${RELAY_PRESTART_MAX_RETRIES:-120}"
curl_timeout="${RELAY_PRESTART_REQUEST_TIMEOUT:-1}"
for attempt in $(seq 0 "${max_retry}"); do
if [[ "${attempt}" == "${max_retry}" ]]; then
echo "The prestart endpoint has not returned 200 after ${max_retry} attempts, exiting!"
exit 1
fi
status=$(curl --max-time "${curl_timeout}" --show-error --silent \
--output /dev/null --write-out "%{http_code}" \
-H 'Connection: close' \
"${RELAY_PRESTART_ENDPOINT}" \
|| true)
if [[ "${status}" == "200" ]]; then
break
fi
echo "Waiting for a 200 response from ${RELAY_PRESTART_ENDPOINT}, got ${status}"
sleep 1
done
fi

# For compatibility with older images
if [ "$1" == "bash" ]; then
set -- bash "${@:2}"
Expand Down