From deebeb056fa5ffec6b0a881eb8b4847546114bc4 Mon Sep 17 00:00:00 2001 From: zias Date: Tue, 16 Dec 2025 14:18:30 +0100 Subject: [PATCH] add:db migration to dockerbuild and edit origin url --- Dockerfile | 11 +++++++++++ docker-entrypoint.sh | 30 ++++++++++++++++++++++++++++++ src/hooks.server.ts | 4 ++-- src/lib/server/oauth.ts | 2 +- static/robots.txt | 2 +- svelte.config.js | 2 +- vite.config.ts | 2 +- 7 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile index e71fdd4..1e0ba05 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,6 +54,14 @@ RUN npm ci --omit=dev # Copy built app from builder COPY --from=builder /app/build ./build +# Copy drizzle migrations and config +COPY --from=builder /app/drizzle ./drizzle +COPY --from=builder /app/drizzle.config.ts ./drizzle.config.ts + +# Copy entrypoint script +COPY docker-entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/docker-entrypoint.sh + # Expose port EXPOSE 3000 @@ -61,5 +69,8 @@ EXPOSE 3000 ENV NODE_ENV=production ENV ORIGIN=http://localhost:3000 +# Use entrypoint script +ENTRYPOINT ["docker-entrypoint.sh"] + # Start the app CMD ["node", "build"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..0bde02f --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,30 @@ +#!/bin/sh +set -e + +echo "Running database migrations..." + +# Run migrations using the drizzle migration files +node -e " +const { drizzle } = require('drizzle-orm/postgres-js'); +const postgres = require('postgres'); +const { migrate } = require('drizzle-orm/postgres-js/migrator'); + +async function runMigrations() { + const migrationClient = postgres(process.env.DATABASE_URL, { max: 1 }); + const db = drizzle(migrationClient); + + console.log('Starting migration...'); + await migrate(db, { migrationsFolder: './drizzle' }); + console.log('Migration completed successfully!'); + + await migrationClient.end(); +} + +runMigrations().catch((err) => { + console.error('Migration failed:', err); + process.exit(1); +}); +" + +echo "Starting application..." +exec "$@" diff --git a/src/hooks.server.ts b/src/hooks.server.ts index d58a3c5..003dbbb 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -13,9 +13,9 @@ export const handle: Handle = async ({ event, resolve }) => { !origin || origin.includes('localhost') || origin.includes('127.0.0.1') || - origin.includes('serengo.ziasvannes.tech') + origin.includes('serengo.zias.be') ) { - // Allow in development and serengo.ziasvannes.tech + // Allow in development and serengo.zias.be } // In production, you would add: else if (origin !== 'yourdomain.com') { return new Response('Forbidden', { status: 403 }); } } diff --git a/src/lib/server/oauth.ts b/src/lib/server/oauth.ts index 9df80b2..e78f06c 100644 --- a/src/lib/server/oauth.ts +++ b/src/lib/server/oauth.ts @@ -4,5 +4,5 @@ import { GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET } from '$env/static/private'; export const google = new Google( GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, - 'https://serengo.ziasvannes.tech/login/google/callback' + 'https://serengo.zias.be/login/google/callback' ); diff --git a/static/robots.txt b/static/robots.txt index a972930..54c7d6d 100644 --- a/static/robots.txt +++ b/static/robots.txt @@ -7,7 +7,7 @@ Disallow: /_app/ Disallow: /.svelte-kit/ # Sitemap location -Sitemap: https://serengo.ziasvannes.tech/sitemap.xml +Sitemap: https://serengo.zias.be/sitemap.xml # Crawl delay for polite crawling Crawl-delay: 1 diff --git a/svelte.config.js b/svelte.config.js index 5cdc093..3f21651 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -13,7 +13,7 @@ const config = { // See https://svelte.dev/docs/kit/adapters for more information about adapters. adapter: adapter(), csrf: { - trustedOrigins: ['http://localhost:3000', 'https://serengo.ziasvannes.tech'] + trustedOrigins: ['http://localhost:3000', 'https://serengo.zias.be'] }, alias: { '@/*': './src/lib/*' diff --git a/vite.config.ts b/vite.config.ts index 48695d8..51c482d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,7 +4,7 @@ import { defineConfig } from 'vite'; export default defineConfig({ plugins: [tailwindcss(), sveltekit()], - preview: { allowedHosts: ['ziasvannes.tech'] }, + preview: { allowedHosts: ['zias.be'] }, build: { target: 'es2020', cssCodeSplit: true