sourcegraph/dev/run-server-image.sh
Robert Lin 1ab7471f91
dev/ci: restructure integration tests, unify test server setup (#29429)
- unify `sourcegraph/server` setup in integration tests so that we use the same scripts in each
- move all integration tests into new `dev/ci/integration` directory, and introduce a structure of `run.sh` and `test.sh` - see `dev/ci/integration/README.md` for overview
- some minor refactors to unify the tests a bit more
- remove unused `servers.yaml` that was part of the Vagrant setup
2022-01-07 13:39:11 -08:00

43 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# This runs a published or local server image for testing and development purposes.
IMAGE=${IMAGE:-sourcegraph/server:${TAG:-insiders}}
URL=${URL:-"http://localhost:7080"}
DATA=/tmp/sourcegraph
echo "--- Checking for existing Sourcegraph instance at $URL"
if curl --output /dev/null --silent --head --fail "$URL"; then
echo "❌ Can't run a new Sourcegraph instance on $URL because another instance is already running."
echo "❌ The last time this happened, there was a runaway integration test run on the same Buildkite agent and the fix was to delete the pod and rebuild."
exit 1
fi
# shellcheck disable=SC2153
case "$CLEAN" in
"true")
clean=y
;;
"false")
clean=n
;;
*)
echo -n "Do you want to delete $DATA and start clean? [Y/n] "
read -r clean
;;
esac
if [ "$clean" != "n" ] && [ "$clean" != "N" ]; then
echo "--- Deleting $DATA"
rm -rf $DATA
fi
echo "--- Starting server ${IMAGE}"
docker run "$@" \
--publish 7080:7080 \
--rm \
-e SRC_LOG_LEVEL=dbug \
-e DEBUG=t \
--volume $DATA/config:/etc/sourcegraph \
--volume $DATA/data:/var/opt/sourcegraph \
"$IMAGE"