安装和配置 > 使用 ThingWorx Docker > 对 ThingWorx Docker 使用外部 PostgreSQL 数据库
对 ThingWorx Docker 使用外部 PostgreSQL 数据库
以下是适用于 PostgreSQL 的 Docker Compose 示例文件,该文件使用了外部数据库:
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"
有关在外部环境下设置 PostgreSQL 数据库和架构的信息,请参阅 Installing ThingWorx (《安装 ThingWorx》) 指南。