chore: add config to run production locally

This commit is contained in:
Nicolas Meienberger 2023-10-11 16:09:11 +02:00 committed by Nicolas Meienberger
parent 0f16571ee3
commit 362ff6eff8
5 changed files with 9 additions and 5 deletions

View file

@ -26,7 +26,6 @@ COPY ./tsconfig.json ./tsconfig.json
COPY ./next.config.mjs ./next.config.mjs
COPY ./public ./public
COPY ./tests ./tests
COPY ./.env.example ./.env
RUN npm run build

View file

@ -85,6 +85,10 @@ services:
traefik.enable: true
traefik.http.services.dashboard.loadbalancer.server.port: 3000
traefik.http.middlewares.redirect-to-https.redirectscheme.scheme: https
# Local ip
traefik.http.routers.dashboard.rule: PathPrefix("/")
traefik.http.routers.dashboard.service: dashboard
traefik.http.routers.dashboard.entrypoints: web
# Local domain
traefik.http.routers.dashboard-local-insecure.rule: Host(`${LOCAL_DOMAIN}`)
traefik.http.routers.dashboard-local-insecure.entrypoints: web

View file

@ -21,7 +21,7 @@
"start:dev-container": "./.devcontainer/filewatcher.sh && npm run start:dev",
"start:rc": "docker compose -f docker-compose.rc.yml --env-file .env up --build",
"start:dev": "npm run prepare && docker compose -f docker-compose.dev.yml up --build",
"start:prod": "npm run prepare && docker compose -f docker-compose.prod.yml up --build",
"start:prod": "npm run prepare && docker compose --env-file ./.env -f docker-compose.prod.yml up --build",
"start:pg": "docker run --name test-db -p 5433:5432 -d --rm -e POSTGRES_PASSWORD=postgres postgres:14",
"version": "echo $npm_package_version",
"release:rc": "./scripts/deploy/release-rc.sh",

View file

@ -42,6 +42,9 @@ const productionLogger = () => {
new transports.File({
filename: path.join(logsFolder, 'app.log'),
}),
new transports.Console({
level: 'info',
}),
],
exceptionHandlers: [new transports.File({ filename: path.join(logsFolder, 'error.log') })],
});

View file

@ -16,7 +16,7 @@ const formatErrors = (errors: { fieldErrors: Record<string, string[]> }) =>
export class TipiConfig {
private static instance: TipiConfig;
private config: z.infer<typeof envSchema>;
private config: z.infer<typeof envSchema> = {} as z.infer<typeof envSchema>;
constructor() {
const conf = { ...process.env, ...nextConfig()?.serverRuntimeConfig };
@ -55,12 +55,10 @@ export class TipiConfig {
} else {
const errors = formatErrors(parsedConfig.error.flatten());
Logger.error(`❌ Invalid env config ${JSON.stringify(errors)}`);
throw new Error(`Invalid env config ${JSON.stringify(errors)}`);
}
} else {
const errors = formatErrors(parsedFileConfig.error.flatten());
Logger.error(`❌ Invalid settings.json file: ${JSON.stringify(errors)}`);
throw new Error('Invalid settings.json file');
}
}