Skip to content

HHH-18973, HHH-19679, HHH-19705, HHH-19710 hibernate-vector module enhancements #10685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
140 changes: 110 additions & 30 deletions docker_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ if command -v docker > /dev/null; then
CONTAINER_CLI=$(command -v docker)
HEALTCHECK_PATH="{{.State.Health.Status}}"
PRIVILEGED_CLI=""
IS_PODMAN=false
if [[ "$(docker version | grep Podman)" == "" ]]; then
IS_DOCKER_RUNTIME=true
else
IS_DOCKER_RUNTIME=false
fi
else
CONTAINER_CLI=$(command -v podman)
HEALTCHECK_PATH="{{.State.Healthcheck.Status}}"
IS_PODMAN=true
IS_DOCKER_RUNTIME=false
# Only use sudo for podman
if command -v sudo > /dev/null; then
PRIVILEGED_CLI="sudo"
Expand All @@ -15,6 +23,12 @@ else
fi
fi

if [[ "$(uname -s)" == "Darwin" ]]; then
IS_OSX=true
else
IS_OSX=false
fi

mysql() {
mysql_9_4
}
Expand Down Expand Up @@ -286,29 +300,93 @@ db2() {
}

db2_11_5() {
$PRIVILEGED_CLI $CONTAINER_CLI rm -f db2 || true
$PRIVILEGED_CLI $CONTAINER_CLI run --name db2 --privileged -e DB2INSTANCE=orm_test -e DB2INST1_PASSWORD=orm_test -e DBNAME=orm_test -e LICENSE=accept -e AUTOCONFIG=false -e ARCHIVE_LOGS=false -e TO_CREATE_SAMPLEDB=false -e REPODB=false -p 50000:50000 -d ${DB_IMAGE_DB2_11_5:-icr.io/db2_community/db2:11.5.9.0}
CONTAINER_OPTIONS=""
if [[ "$IS_OSX" == "true" ]]; then
# Thanks to Mohamed Asfour https://community.ibm.com/community/user/discussion/db2-luw-115xx-mac-m1-ready#bm017584d2-8d76-42a6-8f76-018dac8e78f2
# This SO post explains what goes wrong on OSX: https://stackoverflow.com/questions/70175677/ibmcom-db2-docker-image-fails-on-m1
# Also, use the $HOME directory as base directory to make volume mounts work on Colima on Mac
db2install=$HOME/db2install.sh
rm -f ${db2install} || true
cat <<'EOF' >${db2install}
#!/bin/bash
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - db2inst1 -c '/su - db2inst1 -c '. .profile \&\& /g" {} +
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - db2inst1 -c \"/su - db2inst1 -c \". .profile \&\& /g" {} +
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${DB2INSTANCE?} -c '/su - \${DB2INSTANCE?} -c '. .profile \&\& /g" {} +
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${DB2INSTANCE?} -c \"/su - \${DB2INSTANCE?} -c \". .profile \&\& /g" {} +
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${instance?} -c '/su - \${instance?} -c '. .profile \&\& /g" {} +
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${instance?} -c \"/su - \${instance?} -c \". .profile \&\& /g" {} +
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${instance_name?} -c '/su - \${instance_name?} -c '. .profile \&\& /g" {} +
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${instance_name?} -c \"/su - \${instance_name?} -c \". .profile \&\& /g" {} +
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - db2inst1 -c \\\\\"/su - db2inst1 -c \\\". .profile \&\& /g" {} +
. /var/db2_setup/lib/setup_db2_instance.sh
EOF
chmod 777 ${db2install}
if [[ "$IS_PODMAN" == "true" ]]; then
CONTAINER_OPTIONS='--platform=linux/amd64 -e IS_OSXFS=true -v '${db2install}':/db2install.sh --entrypoint=["/bin/bash","-c","/db2install.sh"]'
CONTAINER_ARGS=
else
CONTAINER_OPTIONS='--platform=linux/amd64 -e IS_OSXFS=true -v '${db2install}':/db2install.sh --entrypoint=/bin/bash'
CONTAINER_ARGS=" -c /db2install.sh"
fi
if [[ "$IS_PODMAN" == "false" ]]; then
export DOCKER_DEFAULT_PLATFORM=linux/amd64
fi
fi
$CONTAINER_CLI rm -f db2 || true
$CONTAINER_CLI run --name db2 --privileged -e DB2INSTANCE=orm_test -e DB2INST1_PASSWORD=orm_test -e DBNAME=orm_test -e LICENSE=accept -e AUTOCONFIG=false -e ARCHIVE_LOGS=false -e TO_CREATE_SAMPLEDB=false -e REPODB=false -e BLU=false -e ENABLE_ORACLE_COMPATIBILITY=false -e UPDATEAVAIL=NO -e PERSISTENT_HOME=true -e HADR_ENABLED=false -p 50000:50000 $CONTAINER_OPTIONS -d ${DB_IMAGE_DB2_11_5:-icr.io/db2_community/db2:11.5.9.0} $CONTAINER_ARGS
# Give the container some time to start
OUTPUT=
while [[ $OUTPUT != *"INSTANCE"* ]]; do
echo "Waiting for DB2 to start..."
sleep 10
OUTPUT=$($PRIVILEGED_CLI $CONTAINER_CLI logs db2 2>&1)
OUTPUT=$($CONTAINER_CLI logs db2 2>&1)
done
$PRIVILEGED_CLI $CONTAINER_CLI exec -t db2 su - orm_test bash -c ". /database/config/orm_test/sqllib/db2profile; /database/config/orm_test/sqllib/bin/db2 'connect to orm_test'; /database/config/orm_test/sqllib/bin/db2 'CREATE USER TEMPORARY TABLESPACE usr_tbsp MANAGED BY AUTOMATIC STORAGE'"
$CONTAINER_CLI exec -t db2 su - orm_test bash -c ". /database/config/orm_test/sqllib/db2profile; /database/config/orm_test/sqllib/bin/db2 'connect to orm_test'; /database/config/orm_test/sqllib/bin/db2 'CREATE USER TEMPORARY TABLESPACE usr_tbsp MANAGED BY AUTOMATIC STORAGE'"
}

db2_12_1() {
$PRIVILEGED_CLI $CONTAINER_CLI rm -f db2 || true
$PRIVILEGED_CLI $CONTAINER_CLI run --name db2 --privileged -e DB2INSTANCE=orm_test -e DB2INST1_PASSWORD=orm_test -e DBNAME=orm_test -e LICENSE=accept -e AUTOCONFIG=false -e ARCHIVE_LOGS=false -e TO_CREATE_SAMPLEDB=false -e REPODB=false -p 50000:50000 -d ${DB_IMAGE_DB2_11_5:-icr.io/db2_community/db2:12.1.2.0}
CONTAINER_OPTIONS=""
if [[ "$IS_OSX" == "true" ]]; then
# Thanks to Mohamed Asfour https://community.ibm.com/community/user/discussion/db2-luw-115xx-mac-m1-ready#bm017584d2-8d76-42a6-8f76-018dac8e78f2
# This SO post explains what goes wrong on OSX: https://stackoverflow.com/questions/70175677/ibmcom-db2-docker-image-fails-on-m1
# Also, use the $HOME directory as base directory to make volume mounts work on Colima on Mac
db2install=$HOME/db2install.sh
rm -f ${db2install} || true
cat <<'EOF' >${db2install}
#!/bin/bash
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - db2inst1 -c '/su - db2inst1 -c '. .profile \&\& /g" {} +
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - db2inst1 -c \"/su - db2inst1 -c \". .profile \&\& /g" {} +
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${DB2INSTANCE?} -c '/su - \${DB2INSTANCE?} -c '. .profile \&\& /g" {} +
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${DB2INSTANCE?} -c \"/su - \${DB2INSTANCE?} -c \". .profile \&\& /g" {} +
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${instance?} -c '/su - \${instance?} -c '. .profile \&\& /g" {} +
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${instance?} -c \"/su - \${instance?} -c \". .profile \&\& /g" {} +
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${instance_name?} -c '/su - \${instance_name?} -c '. .profile \&\& /g" {} +
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${instance_name?} -c \"/su - \${instance_name?} -c \". .profile \&\& /g" {} +
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - db2inst1 -c \\\\\"/su - db2inst1 -c \\\". .profile \&\& /g" {} +
. /var/db2_setup/lib/setup_db2_instance.sh
EOF
chmod 777 ${db2install}
if [[ "$IS_PODMAN" == "true" ]]; then
CONTAINER_OPTIONS='--platform=linux/amd64 -e IS_OSXFS=true -v '${db2install}':/db2install.sh --entrypoint=["/bin/bash","-c","/db2install.sh"]'
CONTAINER_ARGS=
else
CONTAINER_OPTIONS='--platform=linux/amd64 -e IS_OSXFS=true -v '${db2install}':/db2install.sh --entrypoint=/bin/bash'
CONTAINER_ARGS=" -c /db2install.sh"
fi
if [[ "$IS_PODMAN" == "false" ]]; then
export DOCKER_DEFAULT_PLATFORM=linux/amd64
fi
fi
$CONTAINER_CLI rm -f db2 || true
$CONTAINER_CLI run --name db2 --privileged -e DB2INSTANCE=orm_test -e DB2INST1_PASSWORD=orm_test -e DBNAME=orm_test -e LICENSE=accept -e AUTOCONFIG=false -e ARCHIVE_LOGS=false -e TO_CREATE_SAMPLEDB=false -e REPODB=false -e BLU=false -e ENABLE_ORACLE_COMPATIBILITY=false -e UPDATEAVAIL=NO -e PERSISTENT_HOME=true -e HADR_ENABLED=false -p 50000:50000 $CONTAINER_OPTIONS -d ${DB_IMAGE_DB2_12_1:-icr.io/db2_community/db2:12.1.2.0} $CONTAINER_ARGS
# Give the container some time to start
OUTPUT=
while [[ $OUTPUT != *"INSTANCE"* ]]; do
echo "Waiting for DB2 to start..."
sleep 10
OUTPUT=$($PRIVILEGED_CLI $CONTAINER_CLI logs db2 2>&1)
OUTPUT=$($CONTAINER_CLI logs db2 2>&1)
done
$PRIVILEGED_CLI $CONTAINER_CLI exec -t db2 su - orm_test bash -c ". /database/config/orm_test/sqllib/db2profile; /database/config/orm_test/sqllib/bin/db2 'connect to orm_test'; /database/config/orm_test/sqllib/bin/db2 'CREATE USER TEMPORARY TABLESPACE usr_tbsp MANAGED BY AUTOMATIC STORAGE'"
$CONTAINER_CLI exec -t db2 su - orm_test bash -c ". /database/config/orm_test/sqllib/db2profile; /database/config/orm_test/sqllib/bin/db2 'connect to orm_test'; /database/config/orm_test/sqllib/bin/db2 'CREATE USER TEMPORARY TABLESPACE usr_tbsp MANAGED BY AUTOMATIC STORAGE'"
}

db2_spatial() {
Expand Down Expand Up @@ -726,28 +804,30 @@ EOF\""
}

disable_userland_proxy() {
if [[ "$HEALTCHECK_PATH" == "{{.State.Health.Status}}" ]]; then
if [[ ! -f /etc/docker/daemon.json ]]; then
echo "Didn't find /etc/docker/daemon.json but need to disable userland-proxy..."
echo "Stopping docker..."
sudo service docker stop
echo "Creating /etc/docker/daemon.json..."
sudo bash -c "echo '{\"userland-proxy\": false}' > /etc/docker/daemon.json"
echo "Starting docker..."
sudo service docker start
echo "Docker successfully started with userland proxies disabled"
elif ! grep -q userland-proxy /etc/docker/daemon.json; then
echo "Userland proxy is still enabled in /etc/docker/daemon.json, but need to disable it..."
export docker_daemon_json=$(</etc/docker/daemon.json)
echo "Stopping docker..."
sudo service docker stop
echo "Updating /etc/docker/daemon.json..."
sudo bash -c "export docker_daemon_json='$docker_daemon_json'; echo \"\${docker_daemon_json/\}/,}\\\"userland-proxy\\\": false}\" > /etc/docker/daemon.json"
echo "Starting docker..."
sudo service docker start
echo "Service status:"
sudo journalctl -xeu docker.service
echo "Docker successfully started with userland proxies disabled"
if [[ "$IS_DOCKER_RUNTIME" == "true" ]]; then
if [[ "$HEALTCHECK_PATH" == "{{.State.Health.Status}}" ]]; then
if [[ ! -f /etc/docker/daemon.json ]]; then
echo "Didn't find /etc/docker/daemon.json but need to disable userland-proxy..."
echo "Stopping docker..."
sudo service docker stop
echo "Creating /etc/docker/daemon.json..."
sudo bash -c "echo '{\"userland-proxy\": false}' > /etc/docker/daemon.json"
echo "Starting docker..."
sudo service docker start
echo "Docker successfully started with userland proxies disabled"
elif ! grep -q userland-proxy /etc/docker/daemon.json; then
echo "Userland proxy is still enabled in /etc/docker/daemon.json, but need to disable it..."
export docker_daemon_json=$(</etc/docker/daemon.json)
echo "Stopping docker..."
sudo service docker stop
echo "Updating /etc/docker/daemon.json..."
sudo bash -c "export docker_daemon_json='$docker_daemon_json'; echo \"\${docker_daemon_json/\}/,}\\\"userland-proxy\\\": false}\" > /etc/docker/daemon.json"
echo "Starting docker..."
sudo service docker start
echo "Service status:"
sudo journalctl -xeu docker.service
echo "Docker successfully started with userland proxies disabled"
fi
fi
fi
}
Expand Down
Loading
Loading