| 1 |
services: |
| 2 |
mysql: |
| 3 |
image: 'mysql:latest' |
| 4 |
ports: |
| 5 |
- "127.0.0.1:9910:3306" |
| 6 |
environment: |
| 7 |
- MYSQL_DATABASE=gorm |
| 8 |
- MYSQL_USER=gorm |
| 9 |
- MYSQL_PASSWORD=gorm |
| 10 |
- MYSQL_RANDOM_ROOT_PASSWORD="yes" |
| 11 |
postgres: |
| 12 |
image: 'postgres:latest' |
| 13 |
ports: |
| 14 |
- "127.0.0.1:9920:5432" |
| 15 |
environment: |
| 16 |
- TZ=Asia/Shanghai |
| 17 |
- POSTGRES_DB=gorm |
| 18 |
- POSTGRES_USER=gorm |
| 19 |
- POSTGRES_PASSWORD=gorm |
| 20 |
mssql: |
| 21 |
image: '${MSSQL_IMAGE}:latest' |
| 22 |
ports: |
| 23 |
- "127.0.0.1:9930:1433" |
| 24 |
environment: |
| 25 |
- TZ=Asia/Shanghai |
| 26 |
- ACCEPT_EULA=Y |
| 27 |
- MSSQL_SA_PASSWORD=LoremIpsum86 |
| 28 |
tidb: |
| 29 |
image: 'pingcap/tidb:v6.5.0' |
| 30 |
ports: |
| 31 |
- "127.0.0.1:9940:4000" |
| 32 |
command: /tidb-server -store unistore -path "" -lease 0s > tidb.log 2>&1 & |
| 33 |
gaussdb: |
| 34 |
image: 'opengauss/opengauss:7.0.0-RC1.B023' |
| 35 |
hostname: opengauss-server |
| 36 |
ports: |
| 37 |
- "127.0.0.1:9950:5432" |
| 38 |
environment: |
| 39 |
- TZ=Asia/Shanghai |
| 40 |
- GS_PASSWORD=Gaussdb@123 |
| 41 |
- GS_CLUSTER_NAME=opengauss_cluster |
| 42 |
- PGDATA=/var/lib/opengauss/data |
| 43 |
entrypoint: "" |
| 44 |
command: |- |
| 45 |
/bin/sh -c 'set -euo pipefail; |
| 46 |
/usr/local/bin/entrypoint.sh gaussdb & |
| 47 |
counter=1; |
| 48 |
while [ "$$counter" -le 20 ]; do |
| 49 |
if su - omm -c "gsql -U omm -d postgres -c \"SELECT 1;\""; then |
| 50 |
echo "Creating database gorm..."; |
| 51 |
su - omm -c "gsql -U omm -d postgres -c \"CREATE DATABASE gorm DBCOMPATIBILITY '\'PG\'';\""; |
| 52 |
echo "Database initialized successfully"; |
| 53 |
break; |
| 54 |
fi; |
| 55 |
echo "Waiting for database to be ready... ($$counter/12)"; |
| 56 |
sleep 5; |
| 57 |
counter=$$(($$counter + 1)); |
| 58 |
done; |
| 59 |
# timeout handling |
| 60 |
if [ $$counter -gt 20 ]; then |
| 61 |
echo "Error: Database failed to start within timeout"; |
| 62 |
exit 1; |
| 63 |
fi; |
| 64 |
# keep the container running: wait for the database process in the foreground |
| 65 |
wait |
| 66 |
' |