-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (54 loc) · 2.29 KB
/
Dockerfile
File metadata and controls
70 lines (54 loc) · 2.29 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
# =============================================================================
# mdplane Backend Dockerfile (Root Alias)
# This file redirects to apps/server/Dockerfile for backward compatibility
# For the canonical Dockerfile, see: apps/server/Dockerfile
# =============================================================================
# Build stage
FROM oven/bun:1.1 AS builder
WORKDIR /app
# Install pnpm for monorepo dependency resolution
RUN npm install -g pnpm
# Copy dependency manifests first for better layer caching
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY apps/server/package.json ./apps/server/
COPY packages/shared/package.json ./packages/shared/
# Install dependencies
RUN pnpm install --frozen-lockfile
# Copy source files
COPY tsconfig.json tsconfig.base.json ./
COPY apps/server ./apps/server
COPY packages/shared ./packages/shared
# Build shared package first, then server
RUN pnpm --filter @mdplane/shared build
RUN pnpm --filter @mdplane/server build
# =============================================================================
# Production stage - minimal image
# =============================================================================
FROM oven/bun:1.1-slim AS runner
WORKDIR /app
# Install curl for health checks
RUN apt-get update && apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user for security
RUN addgroup --system --gid 1001 mdplane && \
adduser --system --uid 1001 --ingroup mdplane mdplane
# Copy built artifacts from builder stage
COPY --from=builder --chown=mdplane:mdplane /app/apps/server/dist ./dist
COPY --from=builder --chown=mdplane:mdplane /app/apps/server/package.json ./
COPY --from=builder --chown=mdplane:mdplane /app/packages/shared/openapi.bundled.yaml ./openapi.bundled.yaml
# Create data directory for SQLite persistence
RUN mkdir -p /data && chown mdplane:mdplane /data
VOLUME ["/data"]
# Switch to non-root user
USER mdplane
# Environment configuration
ENV NODE_ENV=production
ENV DATABASE_URL=/data/mdplane.sqlite
ENV PORT=3001
# Expose API port
EXPOSE 3001
# Health check - verify API is responding
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3001/health || exit 1
# Start the server
CMD ["bun", "run", "dist/index.js"]