feat:use selfhosted docker

This commit is contained in:
2025-12-16 12:59:43 +01:00
parent 577a3cab56
commit ae6a96d73b
5 changed files with 133 additions and 1 deletions

33
.dockerignore Normal file
View File

@@ -0,0 +1,33 @@
node_modules
.svelte-kit
build
.env
.env.*
!.env.example
!.env.docker
.git
.gitignore
.prettierrc
.prettierignore
.eslintrc
.editorconfig
npm-debug.log
yarn-error.log
pnpm-debug.log
.DS_Store
Thumbs.db
*.log
.vscode
.idea
*.swp
*.swo
*.swn
coverage
.nyc_output
dist
logs
drizzle
docker-compose.yml
Dockerfile
README.md
AGENTS.md

46
Dockerfile Normal file
View File

@@ -0,0 +1,46 @@
# Build stage
FROM node:20-alpine AS builder
# Install pnpm
RUN npm install -g pnpm
WORKDIR /app
# Copy package files
COPY package.json pnpm-lock.yaml ./
# Install dependencies
RUN pnpm install --frozen-lockfile
# Copy source code
COPY . .
# Build the app
RUN pnpm run build
# Production stage
FROM node:20-alpine
# Install pnpm
RUN npm install -g pnpm
WORKDIR /app
# Copy package files
COPY package.json pnpm-lock.yaml ./
# Install production dependencies only
RUN pnpm install --prod --frozen-lockfile
# Copy built app from builder
COPY --from=builder /app/build ./build
# Expose port
EXPOSE 3000
# Set environment variables
ENV NODE_ENV=production
ENV ORIGIN=http://localhost:3000
# Start the app
CMD ["node", "build"]

52
docker-compose.yml Normal file
View File

@@ -0,0 +1,52 @@
services:
postgres:
image: postgres:16-alpine
container_name: serengo-postgres
restart: unless-stopped
environment:
POSTGRES_USER: serengo
POSTGRES_PASSWORD: serengo_password
POSTGRES_DB: serengo
ports:
- '5432:5432'
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U serengo']
interval: 10s
timeout: 5s
retries: 5
app:
build:
context: .
dockerfile: Dockerfile
container_name: serengo-app
restart: unless-stopped
ports:
- '3000:3000'
environment:
- NODE_ENV=production
- DATABASE_URL=postgresql://serengo:serengo_password@postgres:5432/serengo
- ORIGIN=http://localhost:3000
# Add your environment variables here or use env_file
- GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}
- GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}
- R2_ACCOUNT_ID=${R2_ACCOUNT_ID}
- R2_ACCESS_KEY_ID=${R2_ACCESS_KEY_ID}
- R2_SECRET_ACCESS_KEY=${R2_SECRET_ACCESS_KEY}
- R2_BUCKET_NAME=${R2_BUCKET_NAME}
- GOOGLE_MAPS_API_KEY=${GOOGLE_MAPS_API_KEY}
- VAPID_PUBLIC_KEY=${VAPID_PUBLIC_KEY}
- VAPID_PRIVATE_KEY=${VAPID_PRIVATE_KEY}
- VAPID_SUBJECT=${VAPID_SUBJECT}
depends_on:
postgres:
condition: service_healthy
# Uncomment to use .env file
# env_file:
# - .env
volumes:
postgres_data:
driver: local

View File

@@ -25,6 +25,7 @@
"@lucide/svelte": "^0.544.0",
"@oslojs/crypto": "^1.0.1",
"@oslojs/encoding": "^1.1.0",
"@sveltejs/adapter-node": "^5.4.0",
"@sveltejs/kit": "^2.22.0",
"@sveltejs/vite-plugin-svelte": "^6.0.0",
"@tailwindcss/vite": "^4.1.13",

View File

@@ -1,4 +1,4 @@
import adapter from '@sveltejs/adapter-vercel';
import adapter from '@sveltejs/adapter-node';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */