Skip to content

Commit

Permalink
fix(config): always use internal port 5432 for postgres in non-test mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nicotsx committed Nov 19, 2023
1 parent 3dd7ef7 commit ef541f1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export const InstallForm: React.FC<IProps> = ({ formFields, info, onSubmit, init
{initalValues ? t('submit-update') : t('sumbit-install')}
</Button>
{initalValues && onReset && (
<Button loading={status === 'resetting'} onClick={onClickReset} className="btn-danger ms-2">
<Button loading={status === 'stopping'} onClick={onClickReset} className="btn-danger ms-2">
{t('reset')}
</Button>
)}
Expand Down
13 changes: 10 additions & 3 deletions src/server/core/TipiConfig/TipiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ export class TipiConfig {
const envMap = envStringToMap(envFile.toString());

const conf = { ...process.env, ...Object.fromEntries(envMap), ...nextConfig().serverRuntimeConfig };
const envConfig: z.infer<typeof envSchema> = {
const envConfig: z.input<typeof envSchema> = {
postgresHost: conf.POSTGRES_HOST,
postgresDatabase: conf.POSTGRES_DBNAME,
postgresUsername: conf.POSTGRES_USERNAME,
postgresPassword: conf.POSTGRES_PASSWORD,
postgresPort: Number(conf.POSTGRES_PORT || 5432),
postgresPort: Number(conf.POSTGRES_PORT),
REDIS_HOST: conf.REDIS_HOST,
redisPassword: conf.REDIS_PASSWORD,
NODE_ENV: conf.NODE_ENV,
Expand Down Expand Up @@ -84,7 +84,14 @@ export class TipiConfig {
}

public getConfig() {
return { ...this.config, ...this.getFileConfig() };
let conf = { ...this.config, ...this.getFileConfig() };

// If we are not in test mode, we need to set the postgres port to 5432 (internal port)
if (conf.NODE_ENV !== 'test') {
conf = { ...conf, postgresPort: 5432 };
}

return conf;
}

public getSettings() {
Expand Down
2 changes: 1 addition & 1 deletion src/server/run-migrations-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const runPostgresMigrations = async (dbName?: string) => {
host: postgresHost,
database: dbName || postgresDatabase,
password: postgresPassword,
port: Number(postgresPort),
port: Number(process.env.POSTGRES_PORT),
});
await client.connect();

Expand Down

0 comments on commit ef541f1

Please sign in to comment.