diff --git a/keyserver/docker-compose.yml b/keyserver/docker-compose.yml index 90a274462..4eacd721c 100644 --- a/keyserver/docker-compose.yml +++ b/keyserver/docker-compose.yml @@ -1,54 +1,54 @@ version: "3.9" services: node: build: dockerfile: keyserver/Dockerfile context: ../ args: - HOST_UID=${HOST_UID} - HOST_GID=${HOST_GID} image: commapp/node-keyserver:1.0 restart: always ports: - "3000:3000" env_file: - .env environment: - REDIS_URL=redis://cache - COMM_LISTEN_ADDR=0.0.0.0 - - COMM_MYSQL_HOST=${COMM_MYSQL_HOST:-database} - - COMM_MYSQL_DATABASE - - COMM_MYSQL_USER - - COMM_MYSQL_PASSWORD + - COMM_DATABASE_HOST=${COMM_DATABASE_HOST:-database} + - COMM_DATABASE_DATABASE + - COMM_DATABASE_USER + - COMM_DATABASE_PASSWORD depends_on: - cache - database database: image: mysql:5.7.37-debian restart: always expose: - "3306" # There is no ARM-based Mac build on Docker Hub, so we force x64 # This is what we want in production anyways. ARM-based Mac devs will have # it emulated platform: linux/amd64 command: > --max-allowed-packet=64M --local-infile=0 --sql-mode=STRICT_ALL_TABLES --innodb-buffer-pool-size=1600M environment: - MYSQL_RANDOM_ROOT_PASSWORD=yes - - MYSQL_DATABASE=$COMM_MYSQL_DATABASE - - MYSQL_USER=$COMM_MYSQL_USER - - MYSQL_PASSWORD=$COMM_MYSQL_PASSWORD + - MYSQL_DATABASE=$COMM_DATABASE_DATABASE + - MYSQL_USER=$COMM_DATABASE_USER + - MYSQL_PASSWORD=$COMM_DATABASE_PASSWORD volumes: - mysqldata:/var/lib/mysql cache: image: redis:6.2.6-bullseye restart: always expose: - "6379" command: redis-server --loglevel warning volumes: mysqldata: diff --git a/keyserver/src/database/db-config.js b/keyserver/src/database/db-config.js index 36bd45a81..3d7e74094 100644 --- a/keyserver/src/database/db-config.js +++ b/keyserver/src/database/db-config.js @@ -1,41 +1,41 @@ // @flow import invariant from 'invariant'; import { importJSON } from '../utils/import-json'; export type DBConfig = { +host: string, +user: string, +password: string, +database: string, }; let dbConfig; async function getDBConfig(): Promise { if (dbConfig !== undefined) { return dbConfig; } if ( - process.env.COMM_MYSQL_DATABASE && - process.env.COMM_MYSQL_USER && - process.env.COMM_MYSQL_PASSWORD + process.env.COMM_DATABASE_DATABASE && + process.env.COMM_DATABASE_USER && + process.env.COMM_DATABASE_PASSWORD ) { dbConfig = { - host: process.env.COMM_MYSQL_HOST || 'localhost', - user: process.env.COMM_MYSQL_USER, - password: process.env.COMM_MYSQL_PASSWORD, - database: process.env.COMM_MYSQL_DATABASE, + host: process.env.COMM_DATABASE_HOST || 'localhost', + user: process.env.COMM_DATABASE_USER, + password: process.env.COMM_DATABASE_PASSWORD, + database: process.env.COMM_DATABASE_DATABASE, }; } else { const importedDBConfig = await importJSON({ folder: 'secrets', name: 'db_config', }); invariant(importedDBConfig, 'DB config missing'); dbConfig = importedDBConfig; } return dbConfig; } export { getDBConfig };