🐛 Fix database for docker container

This commit is contained in:
Manuel
2023-08-23 22:18:31 +02:00
parent c06905bfd0
commit 4a04725aaf
3 changed files with 6 additions and 1 deletions

View File

@@ -4,7 +4,6 @@ echo "Exporting hostname..."
export NEXTAUTH_URL_INTERNAL="http://$HOSTNAME:7575"
echo "Pushing database changes..."
npm config set update-notifier false
prisma db push --skip-generate
echo "Starting production server..."

View File

@@ -22,6 +22,7 @@ const env = createEnv({
),
DOCKER_HOST: z.string().optional(),
DOCKER_PORT: portSchema,
HOSTNAME: z.string().optional()
},
/**
@@ -56,6 +57,7 @@ const env = createEnv({
NEXT_PUBLIC_DEFAULT_COLOR_SCHEME: process.env.DEFAULT_COLOR_SCHEME,
NEXT_PUBLIC_PORT: process.env.PORT,
NEXT_PUBLIC_NODE_ENV: process.env.NODE_ENV,
HOSTNAME: process.env.HOSTNAME
},
});

View File

@@ -41,6 +41,10 @@ const getTrpcConfiguration = () => ({
const getBaseUrl = () => {
if (typeof window !== 'undefined') return ''; // browser should use relative url
if (env.HOSTNAME) {
console.log('Constructing internal hostname address using', env.HOSTNAME, env.NEXT_PUBLIC_PORT);
return `http://${env.HOSTNAME}:${env.NEXT_PUBLIC_PORT}`;
}
return `http://localhost:${env.NEXT_PUBLIC_PORT ?? 3000}`; // dev SSR should use localhost
};