fix:docker
This commit is contained in:
10
.dockerignore
Normal file
10
.dockerignore
Normal file
@@ -0,0 +1,10 @@
|
||||
node_modules
|
||||
.env
|
||||
.git
|
||||
.gitignore
|
||||
README.md
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
docker-compose.yml
|
||||
.storybook
|
||||
stories
|
||||
37
Dockerfile
37
Dockerfile
@@ -1,43 +1,18 @@
|
||||
# Use Node.js 18 alpine as base image
|
||||
FROM node:18-alpine AS base
|
||||
|
||||
# Set working directory
|
||||
FROM node:20-alpine AS builder
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
RUN DATABASE_URL="postgres://user:pass@localhost:5432/db" npm run build
|
||||
|
||||
# Build the application
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
FROM node:18-alpine AS production
|
||||
|
||||
FROM node:20-alpine AS runner
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app ./
|
||||
|
||||
# Copy package files
|
||||
COPY package.json ./
|
||||
|
||||
# Install only production dependencies
|
||||
RUN npm install --only=production
|
||||
|
||||
# Copy built application from build stage
|
||||
COPY --from=base /app/build ./build
|
||||
COPY --from=base /app/static ./static
|
||||
COPY --from=base /app/package.json ./
|
||||
|
||||
# Expose port
|
||||
ENV NODE_ENV=production
|
||||
EXPOSE 3000
|
||||
|
||||
# Set environment
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
|
||||
# Start the application
|
||||
CMD ["node", "build"]
|
||||
CMD ["node", "build"]
|
||||
|
||||
@@ -15,7 +15,7 @@ services:
|
||||
app:
|
||||
build: .
|
||||
ports:
|
||||
- 3000:3000
|
||||
- 3000:4173
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"@storybook/addon-svelte-csf": "^5.0.8",
|
||||
"@storybook/addon-vitest": "^9.1.8",
|
||||
"@storybook/sveltekit": "^9.1.8",
|
||||
"@sveltejs/adapter-auto": "^6.0.0",
|
||||
"@sveltejs/adapter-node": "^5.3.2",
|
||||
"@sveltejs/kit": "^2.22.0",
|
||||
"@sveltejs/vite-plugin-svelte": "^6.0.0",
|
||||
"@types/node": "^22",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="manifest" href="manifest.json" />
|
||||
<link rel="manifest" href="/manifest.json" />
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
|
||||
@@ -9,8 +9,13 @@ export const handle: Handle = async ({ event, resolve }) => {
|
||||
// Skip CSRF check for GET/HEAD requests
|
||||
if (method !== 'GET' && method !== 'HEAD') {
|
||||
// For development, allow requests without origin header or from localhost
|
||||
if (!origin || origin.includes('localhost') || origin.includes('127.0.0.1')) {
|
||||
// Allow in development
|
||||
if (
|
||||
!origin ||
|
||||
origin.includes('localhost') ||
|
||||
origin.includes('127.0.0.1') ||
|
||||
origin.includes('demo.ziasvannes.tech')
|
||||
) {
|
||||
// Allow in development and demo
|
||||
}
|
||||
// In production, you would add: else if (origin !== 'yourdomain.com') { return new Response('Forbidden', { status: 403 }); }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import adapter from '@sveltejs/adapter-auto';
|
||||
import adapter from '@sveltejs/adapter-node';
|
||||
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
||||
|
||||
/** @type {import('@sveltejs/kit').Config} */
|
||||
@@ -11,7 +11,10 @@ const config = {
|
||||
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
|
||||
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
|
||||
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
|
||||
adapter: adapter()
|
||||
adapter: adapter(),
|
||||
csrf: {
|
||||
trustedOrigins: ['http://localhost:3000', 'https://demo.ziasvannes.tech']
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,5 +2,8 @@ import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [sveltekit()]
|
||||
plugins: [sveltekit()],
|
||||
preview: {
|
||||
allowedHosts: ['demo.ziasvannes.tech']
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user