-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathcreate-docker-container.bash
More file actions
executable file
·58 lines (51 loc) · 1.48 KB
/
create-docker-container.bash
File metadata and controls
executable file
·58 lines (51 loc) · 1.48 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
# @AI-Generated
# Generated in whole or in part by Cursor with a mix of different LLM models (Auto select mode)
# Description:
# 2026-05-21: Add mysql-8.4 support (TNZ-99882)
set -eu
set -o pipefail
THIS_FILE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
CI="${THIS_FILE_DIR}/../../wg-app-platform-runtime-ci"
. "$CI/shared/helpers/git-helpers.bash"
REPO_NAME=$(git_get_remote_name)
REPO_PATH="${THIS_FILE_DIR}/../"
unset THIS_FILE_DIR
if [[ ${DB:-empty} == "empty" ]]; then
DB=mysql
fi
TAG=${TAG:-latest}
CONTAINER_NAME="$REPO_NAME-$DB-docker-container"
if [[ "${DB}" == "mysql" ]] || [[ "${DB}" == "mysql-8.0" ]]; then
IMAGE="docker.io/cloudfoundry/tas-runtime-mysql-8.0:${TAG}"
DB="mysql"
elif [[ "${DB}" == "mysql-8.4" ]]; then
IMAGE="docker.io/cloudfoundry/tas-runtime-mysql-8.4:${TAG}"
DB="mysql"
elif [[ "${DB}" == "mysql-5.7" ]]; then
IMAGE="docker.io/cloudfoundry/tas-runtime-mysql-5.7:${TAG}"
DB="mysql"
elif [[ "${DB}" == "postgres" ]]; then
IMAGE="docker.io/cloudfoundry/tas-runtime-postgres:${TAG}"
else
echo "Unsupported DB flavor"
exit 1
fi
if [[ -z "${*}" ]]; then
ARGS="-it"
else
ARGS="${*}"
fi
docker pull "${IMAGE}"
docker rm -f "${CONTAINER_NAME}" || true # needed for compatibility with podman
docker run -it \
--env "DB=${DB}" \
--env "REPO_NAME=$REPO_NAME" \
--env "REPO_PATH=/repo" \
--rm \
--name "$CONTAINER_NAME" \
-v "${REPO_PATH}:/repo" \
-v "${CI}:/ci" \
${ARGS} \
"${IMAGE}" \
/bin/bash