1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-22 01:47:08 +02: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:
Fynn Petersen-Frey 2022-07-13 05:21:11 +02:00 committed by GitHub
parent c60e852226
commit d69470e207
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 7 deletions

View File

@ -7,6 +7,8 @@ DB_USERNAME=postgres
DB_PASSWORD=postgres DB_PASSWORD=postgres
DB_DATABASE_NAME=immich DB_DATABASE_NAME=immich
# Optional Database settings:
# DB_PORT=5432
@ -17,6 +19,12 @@ DB_DATABASE_NAME=immich
REDIS_HOSTNAME=immich_redis REDIS_HOSTNAME=immich_redis
# Optional Redis settings:
# REDIS_PORT=6379
# REDIS_DBINDEX=0
# REDIS_PASSWORD=
# REDIS_SOCKET=

View File

@ -3,7 +3,7 @@ import { TypeOrmModuleOptions } from '@nestjs/typeorm';
export const databaseConfig: TypeOrmModuleOptions = { export const databaseConfig: TypeOrmModuleOptions = {
type: 'postgres', type: 'postgres',
host: process.env.DB_HOSTNAME || 'immich_postgres', host: process.env.DB_HOSTNAME || 'immich_postgres',
port: 5432, port: parseInt(process.env.DB_PORT || '5432'),
username: process.env.DB_USERNAME, username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD, password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE_NAME, database: process.env.DB_DATABASE_NAME,

View File

@ -36,7 +36,10 @@ import { AppLoggerMiddleware } from './middlewares/app-logger.middleware';
useFactory: async () => ({ useFactory: async () => ({
redis: { redis: {
host: process.env.REDIS_HOSTNAME || 'immich_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,
}, },
}), }),
}), }),

View File

@ -3,13 +3,20 @@ import { RedisClient } from 'redis';
import { ServerOptions } from 'socket.io'; import { ServerOptions } from 'socket.io';
import { createAdapter } from 'socket.io-redis'; 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 pubClient = createClient({ url: `redis://${redis_host}:6379` });
// const subClient = pubClient.duplicate(); // const subClient = pubClient.duplicate();
const pubClient = new RedisClient({ const pubClient = new RedisClient({
host: redis_host, host: redisHost,
port: 6379, port: redisPort,
db: redisDb,
password: redisPassword,
path: redisSocket,
}); });
const subClient = pubClient.duplicate(); const subClient = pubClient.duplicate();

View File

@ -27,7 +27,10 @@ import {
useFactory: async () => ({ useFactory: async () => ({
redis: { redis: {
host: process.env.REDIS_HOSTNAME || 'immich_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,
}, },
}), }),
}), }),

View File

@ -4,7 +4,7 @@ import {DataSource} from "typeorm";
export const databaseConfig: PostgresConnectionOptions = { export const databaseConfig: PostgresConnectionOptions = {
type: 'postgres', type: 'postgres',
host: process.env.DB_HOSTNAME || 'immich_postgres', host: process.env.DB_HOSTNAME || 'immich_postgres',
port: 5432, port: parseInt(process.env.DB_PORT || '5432'),
username: process.env.DB_USERNAME, username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD, password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE_NAME, database: process.env.DB_DATABASE_NAME,