Commit 7a74b991 authored by foo's avatar foo

docker-compose mysql service updated

parent 56c460de
......@@ -2,19 +2,29 @@ version: '3.8'
services:
mysql:
image: mysql:latest
container_name: mysql
container_name: vpptest-mysql
image: mysql:5.7
volumes:
- ./oai_db.sql:/docker-entrypoint-initdb.d/oai_db.sql
- ./mysql-healthcheck.sh:/tmp/mysql-healthcheck.sh
environment:
- TZ=Europe/Paris
- MYSQL_DATABASE=oai_db
- MYSQL_USER=test
- MYSQL_PASSWORD=test
- MYSQL_ROOT_PASSWORD=linux
healthcheck:
test: /bin/bash -c "/tmp/mysql-healthcheck.sh"
interval: 10s
timeout: 5s
retries: 5
networks:
public_net:
ipv4_address: 192.168.74.200
environment:
MYSQL_ROOT_PASSWORD: 'linux'
volumes:
- ./oai_db.sql:/oai_db.sql
oai-smf:
image: oai-smf:vpp-upf
container_name: oai-smf
container_name: vpptest-oai-smf
privileged: true
networks:
public_net:
......@@ -53,7 +63,7 @@ services:
oai-amf:
image: oai-amf:develop
container_name: oai-amf
container_name: vpptest-oai-amf
privileged: true
networks:
public_net:
......@@ -110,7 +120,7 @@ services:
oai-vpp:
image: vpp-upg:latest
privileged: true
container_name: oai-vpp-upf
container_name: vpptest-oai-vpp-upf
networks:
public_net_access:
ipv4_address: 192.168.75.197
......@@ -172,7 +182,7 @@ services:
oai-nat:
image: ubuntu:bionic
privileged: true
container_name: oai-nat
container_name: vpptest-oai-nat
networks:
public_net:
ipv4_address: 192.168.74.205
......@@ -187,7 +197,7 @@ services:
gnbsim:
image: gnbsim:latest
privileged: true
container_name: gnbsim
container_name: vpptest-gnbsim
environment:
MCC: 208
MNC: 95
......@@ -216,7 +226,7 @@ services:
public_net_access:
ipv4_address: 192.168.75.198
volumes:
- ./lib/modules/5.8.0-43-generic/kernel/drivers/net/gtp.ko:/lib/modules/5.8.0-43-generic/kernel/drivers/net/gtp.ko
- ./lib/modules/4.15.0-76-generic/kernel/drivers/net/gtp.ko:/lib/modules/5.8.0-43-generic/kernel/drivers/net/gtp.ko
networks:
public_net:
......
#!/bin/bash
set -eo pipefail
if [ "$MYSQL_ROOT_PASSWORD" ] && [ -z "$MYSQL_USER" ] && [ -z "$MYSQL_PASSWORD" ]; then
echo >&2 'Healthcheck error: cannot determine root password (and MYSQL_USER and MYSQL_PASSWORD were not set)'
exit 0
fi
host="$(hostname --ip-address || echo '127.0.0.1')"
user="${MYSQL_USER:-root}"
export MYSQL_PWD="${MYSQL_PASSWORD:-$MYSQL_ROOT_PASSWORD}"
args=(
# force mysql to not use the local "mysqld.sock" (test "external" connectivity)
-h"$host"
-u"$user"
--silent
)
STATUS=0
if command -v mysqladmin &> /dev/null; then
if mysqladmin "${args[@]}" ping > /dev/null; then
database_check=$(mysql -u$user -D oai_db --silent -e "SELECT * FROM users;")
if [[ -z $database_check ]]; then
echo "Healthcheck error: oai_db not populated"
STATUS=1
fi
STATUS=0
else
echo "Healthcheck error: Mysql port inactive"
STATUS=1
fi
else
if select="$(echo 'SELECT 1' | mysql "${args[@]}")" && [ "$select" = '1' ]; then
database_check=$(mysql -u$user -D oai_db --silent -e "SELECT * FROM users;")
if [[ -z $database_check ]]; then
echo "Healthcheck error: oai_db not populated"
STATUS=1
fi
STATUS=0
else
echo "Healthcheck error: Mysql port inactive"
STATUS=1
fi
fi
exit $STATUS
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment