Utilizzo di un database di PostgreSQL esterno per il Docker di ThingWorx
Nell'esempio seguente è mostrato un file Docker Compose per un PostgreSQL che utilizza un database esterno:
Per informazioni sull'impostazione dello schema e del database del server PostgreSQL in scenari esterni, fare riferimento a Installazione di ThingWorx.
Per ThingWorx 9.0 e 9.1: 
version: '2.2'
# Note, this example includes a _blank_ postgreSQL docker image for demonstration
# purposes. The postgresql service should be removed and DATABASE_HOST should point
# to the production database either with a DNS name, or IP.
services:
postgresql:
image: postgres:9.4
ports:
- "5432"
healthcheck:
test: pg_isready -U postgres
interval: 15s
environment:
# NOTE: You must manually set a default postgres password if using this
# example for testing.
- "POSTGRES_PASSWORD="
volumes:
- "./thingworx-postgres-storage/postgres-data:/var/lib/postgresql/data"
platform:
image: thingworx/platform-postgres:latest
healthcheck:
test: curl -s -w '%{http_code}' -U 'bad:creds'
localhost:8080/Thingworx/Subsystems/PlatformSubsystem | grep -w 401
interval: 15s
depends_on:
postgresql:
condition: service_healthy
ports:
- "8080:8080"
- "8443:8443"
environment:
- "ENABLE_CLUSTERED_MODE=false"
- "INITIAL_HEAP=2"
- "MAX_HEAP=4"
- "DATABASE_HOST=postgresql"
- "DATABASE_PORT=5432"
- "TWX_DATABASE_USERNAME=thingworx"
- "TWX_DATABASE_SCHEMA=thingworx"
# NOTE: TWX_DATABASE_PASSWORD must be set for your environment manually.
- "TWX_DATABASE_PASSWORD="
- "ENABLE_HTTP=true"
- "ENABLE_HTTPS=false"
# NOTE: If supplying a keystore for SSL, you must set your keystore password
#- "SSL_KEYSTORE_PASSWORD="
- "DATABASE_ADMIN_USERNAME=postgres"
# NOTE: DATABASE_ADMIN_PASSWORD should match your environment or POSTGRES_PASSWORD
# if using above service for testing.
- "DATABASE_ADMIN_PASSWORD="
- "TABLESPACE_LOCATION=/var/lib/postgresql/data"
volumes:
- "./thingworx-postgres-storage/ThingworxPlatform:/ThingworxPlatform"
- "./thingworx-postgres-storage/ThingworxStorage:/ThingworxStorage"
- "./thingworx-postgres-storage/ThingworxBackupStorage:/ThingworxBackupStorage"
- "./thingworx-postgres-storage/tomcat-logs:/opt/apache-tomcat/logs"
Per ThingWorx 9.2 e versioni successive: 
version: '2.2'
# Note, this example includes a _blank_ postgreSQL docker image for demonstration
# purposes. The postgresql service should be removed and DATABASE_HOST should point
# to the production database either with a DNS name, or IP.
services:
postgresql:
image: postgres:9.4
ports:
- "5432"
healthcheck:
test: pg_isready -U postgres
interval: 15s
environment:
# NOTE: You must manually set a default postgres password if using this
# example for testing.
- "POSTGRES_PASSWORD="
volumes:
- "./thingworx-postgres-storage/postgres-data:/var/lib/postgresql/data"

postgresql-init:
image: thingworx/postgresql-init-twx:latest
entrypoint: bash -c -x "/usr/local/bin/db-check.sh && /usr/local/bin/db-setup.sh && sleep infinity"
healthcheck:
test: [ "CMD-SHELL", "grep 'success' tmp/status.txt || exit 1" ]
interval: 15s
retries: 5
depends_on:
postgresql:
condition: service_healthy
environment:
# NOTE: Set DATABASE_ADMIN_USERNAME, DATABASE_ADMIN_PASSWORD DATABASE_ADMIN_SCHEMA for connecting
# to the postgres as super user
- "DATABASE_ADMIN_USERNAME="
- "DATABASE_ADMIN_PASSWORD="
- "DATABASE_ADMIN_SCHEMA="
- "DATABASE_HOST=postgresql"
- "DATABASE_PORT=5432"
- "TWX_DATABASE_USERNAME="
- "TWX_DATABASE_SCHEMA="
- "TWX_DATABASE_PASSWORD="
- "TABLESPACE_LOCATION=/var/lib/postgresql/data"
platform:
image: thingworx/platform-mssql:latest
healthcheck:
test: curl -f localhost:8080/Thingworx/health
interval: 15s
depends_on:
postgresql-init:
condition: service_healthy
ports:
- "8080:8080"
- "8443:8443"
environment:
- "INITIAL_HEAP=2"
- "MAX_HEAP=4"
- "DATABASE_HOST=mssql"
- "DATABASE_PORT=1433"
- "TWX_DATABASE_USERNAME=thingworx"
- "TWX_DATABASE_SCHEMA=thingworx"
# NOTE: TWX_DATABASE_PASSWORD for MSSQL platform must be set to match your
# environment.
- "TWX_DATABASE_PASSWORD="
- "ENABLE_HTTP=true"
- "ENABLE_HTTPS=false"
# NOTE: If supplying a keystore for SSL, you must set your keystore password
#- "SSL_KEYSTORE_PASSWORD="
volumes:
- "./thingworx-mssql-storage/ThingworxPlatform:/ThingworxPlatform"
- "./thingworx-mssql-storage/ThingworxStorage:/ThingworxStorage"
- "./thingworx-mssql-storage/ThingworxBackupStorage:/ThingworxBackupStorage"
- "./thingworx-mssql-storage/tomcat-logs:/app/opt/apache-tomcat/logs"
È stato utile?