-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
76 lines (52 loc) · 2.13 KB
/
Copy pathDockerfile
File metadata and controls
76 lines (52 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Use Node.js 24 image as base
FROM node:24-slim AS builder
# Set working directory inside the container
WORKDIR /app
# Set DATABASE_URL for Prisma (temporary for build, will be overridden at runtime)
ENV DATABASE_URL="file:/app/data/sqlite.db"
# Copy package files for better layer caching
COPY package*.json ./
# Install dependencies (including dev dependencies for build)
RUN npm ci
# Copy prisma schema
COPY prisma ./prisma/
# Generate Prisma client
RUN npx prisma generate
# Copy TypeScript configuration and source code
COPY tsconfig.json ./
COPY src ./src/
# Build the TypeScript application
RUN npm run build
# Compile seed file
RUN npx tsc prisma/seed.ts --outDir dist/prisma --target ES2020 --moduleResolution node --module esnext --esModuleInterop
# Production stage
FROM node:24-slim
# Install openssl for Prisma, git for repository cloning, curl for docker-compose installation
RUN apt-get update -y && apt-get install -y openssl git git-lfs curl && rm -rf /var/lib/apt/lists/*
# Install docker-compose (latest version)
RUN curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose \
&& chmod +x /usr/local/bin/docker-compose \
&& ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
WORKDIR /app
# Set DATABASE_URL for Prisma (will be overridden by .env file at runtime)
ENV DATABASE_URL="file:/app/data/sqlite.db"
# Copy package files
COPY package*.json ./
# Install production dependencies only
RUN npm ci --only=production
# Copy Prisma files
COPY prisma ./prisma/
# Generate Prisma client in production
RUN npx prisma generate
# Copy built application from builder stage
COPY --from=builder /app/dist ./dist
# Copy templates directory
COPY templates ./templates/
# Copy legacy docker-compose file for legacy deployments
COPY legacy-docker-compose.yaml ./legacy-docker-compose.yaml
# Create directory for SQLite database
RUN mkdir -p /app/data
# Create SQLite database file
RUN touch /app/data/sqlite.db
# Start the application with migrations and seeding
CMD ["sh", "-c", "npx prisma migrate deploy && node dist/prisma/seed.js && npm start"]