mirror of
https://github.com/immich-app/immich.git
synced 2024-12-28 22:51:59 +00:00
Add extended redis & DB port configuration via environment variables (#330)
* Add database port configuration via env variable Add redis connection configuration via env variables * Add redis connection configuration via env variables
This commit is contained in:
parent
c60e852226
commit
d69470e207
6 changed files with 28 additions and 7 deletions
|
@ -7,6 +7,8 @@ DB_USERNAME=postgres
|
|||
DB_PASSWORD=postgres
|
||||
DB_DATABASE_NAME=immich
|
||||
|
||||
# Optional Database settings:
|
||||
# DB_PORT=5432
|
||||
|
||||
|
||||
|
||||
|
@ -17,6 +19,12 @@ DB_DATABASE_NAME=immich
|
|||
|
||||
REDIS_HOSTNAME=immich_redis
|
||||
|
||||
# Optional Redis settings:
|
||||
# REDIS_PORT=6379
|
||||
# REDIS_DBINDEX=0
|
||||
# REDIS_PASSWORD=
|
||||
# REDIS_SOCKET=
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
|||
export const databaseConfig: TypeOrmModuleOptions = {
|
||||
type: 'postgres',
|
||||
host: process.env.DB_HOSTNAME || 'immich_postgres',
|
||||
port: 5432,
|
||||
port: parseInt(process.env.DB_PORT || '5432'),
|
||||
username: process.env.DB_USERNAME,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_DATABASE_NAME,
|
||||
|
|
|
@ -36,7 +36,10 @@ import { AppLoggerMiddleware } from './middlewares/app-logger.middleware';
|
|||
useFactory: async () => ({
|
||||
redis: {
|
||||
host: process.env.REDIS_HOSTNAME || 'immich_redis',
|
||||
port: 6379,
|
||||
port: parseInt(process.env.REDIS_PORT || '6379'),
|
||||
db: parseInt(process.env.REDIS_DBINDEX || '0'),
|
||||
password: process.env.REDIS_PASSWORD || undefined,
|
||||
path: process.env.REDIS_SOCKET || undefined,
|
||||
},
|
||||
}),
|
||||
}),
|
||||
|
|
|
@ -3,13 +3,20 @@ import { RedisClient } from 'redis';
|
|||
import { ServerOptions } from 'socket.io';
|
||||
import { createAdapter } from 'socket.io-redis';
|
||||
|
||||
const redis_host = process.env.REDIS_HOSTNAME || 'immich_redis';
|
||||
const redisHost = process.env.REDIS_HOSTNAME || 'immich_redis';
|
||||
const redisPort = parseInt(process.env.REDIS_PORT || '6379');
|
||||
const redisDb = parseInt(process.env.REDIS_DBINDEX || '0');
|
||||
const redisPassword = process.env.REDIS_PASSWORD || undefined;
|
||||
const redisSocket = process.env.REDIS_SOCKET || undefined;
|
||||
// const pubClient = createClient({ url: `redis://${redis_host}:6379` });
|
||||
// const subClient = pubClient.duplicate();
|
||||
|
||||
const pubClient = new RedisClient({
|
||||
host: redis_host,
|
||||
port: 6379,
|
||||
host: redisHost,
|
||||
port: redisPort,
|
||||
db: redisDb,
|
||||
password: redisPassword,
|
||||
path: redisSocket,
|
||||
});
|
||||
|
||||
const subClient = pubClient.duplicate();
|
||||
|
|
|
@ -27,7 +27,10 @@ import {
|
|||
useFactory: async () => ({
|
||||
redis: {
|
||||
host: process.env.REDIS_HOSTNAME || 'immich_redis',
|
||||
port: 6379,
|
||||
port: parseInt(process.env.REDIS_PORT || '6379'),
|
||||
db: parseInt(process.env.REDIS_DBINDEX || '0'),
|
||||
password: process.env.REDIS_PASSWORD || undefined,
|
||||
path: process.env.REDIS_SOCKET || undefined,
|
||||
},
|
||||
}),
|
||||
}),
|
||||
|
|
|
@ -4,7 +4,7 @@ import {DataSource} from "typeorm";
|
|||
export const databaseConfig: PostgresConnectionOptions = {
|
||||
type: 'postgres',
|
||||
host: process.env.DB_HOSTNAME || 'immich_postgres',
|
||||
port: 5432,
|
||||
port: parseInt(process.env.DB_PORT || '5432'),
|
||||
username: process.env.DB_USERNAME,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_DATABASE_NAME,
|
||||
|
|
Loading…
Reference in a new issue