Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
dist
web/dist
.git
.env
.env.*
!.env.example
docker-compose.yml
Dockerfile
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Stage 1: Build
FROM node:22-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

# Stage 2: Runner
FROM node:22-alpine AS runner
ENV NODE_ENV=production
WORKDIR /app

# Install production dependencies only
COPY package*.json ./
RUN npm ci --omit=dev && npm cache clean --force

# Copy compiled assets and change ownership to the 'node' user
COPY --from=builder --chown=node:node /app/dist ./dist
COPY --from=builder --chown=node:node /app/web/dist ./web/dist
COPY --from=builder --chown=node:node /app/migrations ./dist/migrations

# Copy the entrypoint script
COPY --chown=node:node docker-entrypoint.sh ./
RUN sed -i 's/\r$//' docker-entrypoint.sh && chmod +x docker-entrypoint.sh

# Drop privileges to non-root user for security
USER node

# The application listens on port 4173 by default
EXPOSE 4173
CMD ["./docker-entrypoint.sh"]
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ services:
postgres:
image: pgvector/pgvector:pg16
container_name: sag_lite_postgres
restart: unless-stopped
environment:
POSTGRES_DB: sag_lite
POSTGRES_USER: sag_lite
Expand All @@ -16,5 +17,21 @@ services:
timeout: 5s
retries: 20

app:
build:
context: .
dockerfile: Dockerfile
container_name: sag_lite_app
restart: unless-stopped
ports:
- "4173:4173"
environment:
- DATABASE_URL=postgres://sag_lite:sag_lite_pass@postgres:5432/sag_lite
- HTTP_HOST=0.0.0.0
- HTTP_PORT=4173
depends_on:
postgres:
condition: service_healthy

volumes:
sag_lite_pgdata:
8 changes: 8 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -e

echo "Running migrations..."
node dist/src/db/migrate.js

echo "Starting app..."
exec node dist/src/index.js