add:db migration to dockerbuild and edit origin url

This commit is contained in:
2025-12-16 14:18:30 +01:00
parent 0c1c9d202d
commit deebeb056f
7 changed files with 47 additions and 6 deletions

View File

@@ -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"]

30
docker-entrypoint.sh Normal file
View File

@@ -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 "$@"

View File

@@ -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 }); }
}

View File

@@ -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'
);

View File

@@ -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

View File

@@ -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/*'

View File

@@ -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