-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbuild-biosamples-search-image.sh
More file actions
executable file
·58 lines (47 loc) · 2.12 KB
/
Copy pathbuild-biosamples-search-image.sh
File metadata and controls
executable file
·58 lines (47 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
# Builds a local checkout of biosamples-search into a Docker image.
set -euo pipefail
# Configuration (override via environment variables if needed)
# By default, assume a sibling checkout of biosamples-search next to this repo.
# If you want to hard-code an absolute path, use:
REPO_DIR="/mnt/c/users/dgupta/biosamples-peripheral-services/biosamples-search"
#REPO_DIR="${REPO_DIR:-../biosamples-peripheral-services/biosamples-search}"
IMAGE_TAG="${IMAGE_TAG:-biosamples-search:latest}"
DOCKER_CONTEXT="${DOCKER_CONTEXT:-}" # If empty, auto-detect a Dockerfile
GRADLE_TASKS="${GRADLE_TASKS:-build}" # e.g., assemble, build
GRADLE_ARGS="${GRADLE_ARGS:---no-daemon -x test}" # add/remove -x test as needed
USE_DOCKER_GRADLE="${USE_DOCKER_GRADLE:-1}" # 1 = use Dockerized Gradle (JDK 24), 0 = use local Gradle
GRADLE_DOCKER_IMAGE="${GRADLE_DOCKER_IMAGE:-gradle:8.14-jdk24}" # Gradle with JDK 24
# Checks
command -v docker >/dev/null 2>&1 || { echo "docker is required"; exit 1; }
echo "[1/3] Using local biosamples-search checkout: $REPO_DIR"
if [ ! -d "$REPO_DIR" ]; then
echo "Local biosamples-search directory '$REPO_DIR' does not exist."
echo "Set REPO_DIR to the path of your local biosamples-search checkout."
exit 1
fi
cd "$REPO_DIR"
echo "[2/3] Detecting Dockerfile"
if [ -n "${DOCKER_CONTEXT}" ] && [ -f "${DOCKER_CONTEXT}/Dockerfile" ]; then
CONTEXT_DIR="${DOCKER_CONTEXT}"
else
DETECTED=$(find . -maxdepth 3 -type f -name Dockerfile | head -n 1 || true)
if [ -n "$DETECTED" ]; then
CONTEXT_DIR="$(dirname "$DETECTED")"
else
echo "No Dockerfile found. Set DOCKER_CONTEXT to the directory that contains a Dockerfile."
exit 1
fi
fi
echo "[3/3] Building Docker image: ${IMAGE_TAG}"
# Check if buildx is available, otherwise use regular docker build
if docker buildx version >/dev/null 2>&1; then
echo "Using BuildKit (buildx available)"
DOCKER_BUILDKIT=1 docker build -t "${IMAGE_TAG}" "${CONTEXT_DIR}"
else
echo "BuildKit not available, using standard docker build"
docker build -t "${IMAGE_TAG}" "${CONTEXT_DIR}"
fi
echo "${IMAGE_TAG} built successfully"
docker compose up -d elastic
cd -