Skip to content
Merged
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
6 changes: 2 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ dist/
!packages/**/dist/**

# Environment files
.env.local
.env.development.local
.env.test.local
.env.production.local
.env*
!.env.example

# IDE and editor files
.vscode/
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
workflow_dispatch:

env:
NODE_VERSION: '20'
NODE_VERSION: '22'

jobs:
unit-tests:
Expand All @@ -17,7 +17,7 @@ jobs:

services:
postgres:
image: postgres:16
image: postgres:17-alpine
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: pagespace_test
Expand Down
5 changes: 2 additions & 3 deletions apps/processor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ COPY packages/db/package.json ./packages/db/
COPY packages/lib/package.json ./packages/lib/
COPY apps/processor/package.json ./apps/processor/

# Install all dependencies
# Install dependencies (allow lockfile update since processor deps changed)
RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store pnpm config set store-dir /pnpm/store && pnpm install --no-frozen-lockfile --prod=false
# Install dependencies
RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store pnpm config set store-dir /pnpm/store && pnpm install --frozen-lockfile --prod=false

# Now copy source code AFTER dependencies are installed
COPY tsconfig.json ./
Expand Down
58 changes: 38 additions & 20 deletions apps/realtime/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,58 @@
# syntax=docker/dockerfile:1.6
# This Dockerfile runs the realtime service.
# It uses the same pattern as the working migrate container.
FROM node:22.17.0-alpine
# Multi-stage build for the realtime Socket.IO service

# Set working directory
# Stage 1: Install dependencies and build
FROM node:22.17.0-alpine AS builder
WORKDIR /app

# Install basic tools and configure npm
RUN apk add --no-cache git && \
npm config set fetch-timeout 300000 && \
npm config set fetch-retry-maxtimeout 120000 && \
npm config set fetch-retry-mintimeout 10000

# Enable corepack and prepare specific pnpm version
RUN corepack enable && \
(corepack prepare pnpm@10.13.1 --activate || corepack prepare pnpm@10.13.1 --activate || corepack prepare pnpm@10.13.1 --activate)

# Copy package files first for better Docker layer caching
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY packages/db/package.json ./packages/db/
COPY packages/lib/package.json ./packages/lib/
COPY apps/web/package.json ./apps/web/
COPY apps/realtime/package.json ./apps/realtime/

# Install ALL dependencies for the entire monorepo
RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store pnpm config set store-dir /pnpm/store && pnpm install --frozen-lockfile --prod=false

# Copy only the source code needed (avoid copying node_modules)
COPY packages ./packages
COPY apps ./apps
COPY types ./types
COPY packages/db ./packages/db
COPY packages/lib ./packages/lib
COPY apps/realtime ./apps/realtime
COPY tsconfig.json ./

# Copy .env file for environment variables
COPY .env ./
# Build shared packages and the realtime service
RUN pnpm --filter @pagespace/db build && \
pnpm --filter @pagespace/lib build && \
pnpm --filter realtime build

# Stage 2: Production runner
FROM node:22.17.0-alpine AS runner
WORKDIR /app

RUN corepack enable && \
(corepack prepare pnpm@10.13.1 --activate || corepack prepare pnpm@10.13.1 --activate || corepack prepare pnpm@10.13.1 --activate)

# Copy manifests and lockfile for production install
COPY --from=builder /app/package.json /app/pnpm-lock.yaml /app/pnpm-workspace.yaml ./
COPY --from=builder /app/packages/db/package.json ./packages/db/
COPY --from=builder /app/packages/lib/package.json ./packages/lib/
COPY --from=builder /app/apps/web/package.json ./apps/web/
COPY --from=builder /app/apps/realtime/package.json ./apps/realtime/

# Install production-only dependencies
RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store pnpm config set store-dir /pnpm/store && pnpm install --frozen-lockfile --prod

# Copy only compiled runtime artifacts from builder
COPY --from=builder /app/packages/db/dist ./packages/db/dist
COPY --from=builder /app/packages/lib/dist ./packages/lib/dist
COPY --from=builder /app/apps/realtime/dist ./apps/realtime/dist

ENV NODE_ENV=production

USER node

EXPOSE 3001

# Run the realtime service with tsx
CMD ["pnpm", "--filter", "realtime", "start"]
CMD ["node", "apps/realtime/dist/index.js"]
6 changes: 2 additions & 4 deletions apps/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ ENV NEXT_PUBLIC_GOOGLE_OAUTH_IOS_CLIENT_ID=$NEXT_PUBLIC_GOOGLE_OAUTH_IOS_CLIENT_

# Next.js collects telemetry data by default.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry.
# ENV NEXT_TELEMETRY_DISABLED 1
ENV NEXT_TELEMETRY_DISABLED=1

# We are installing devDependencies via the --prod=false flag, so this is not needed
# ENV NODE_ENV=development
Expand All @@ -65,8 +64,7 @@ FROM node:22.17.0-alpine AS runner
WORKDIR /app

ENV NODE_ENV=production
# Uncomment the following line in case you want to disable telemetry.
# ENV NEXT_TELEMETRY_DISABLED 1
ENV NEXT_TELEMETRY_DISABLED=1

# Use the existing node user (UID 1000) from the base image
# This matches the processor container's UID for shared volume access
Expand Down
3 changes: 0 additions & 3 deletions apps/web/Dockerfile.migrate
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,3 @@ COPY tsconfig.json ./

# Build the database package to ensure latest schema changes are compiled
RUN pnpm --filter @pagespace/db build

# Copy .env file for tsx --env-file
COPY .env ./
5 changes: 1 addition & 4 deletions apps/web/Dockerfile.seed
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,5 @@ COPY packages ./packages
COPY apps ./apps
COPY tsconfig.json ./

# Copy .env file for tsx --env-file
COPY .env ./

# Run seed
CMD ["pnpm", "--filter", "@pagespace/db", "db:seed"]
CMD ["pnpm", "--filter", "@pagespace/db", "db:seed"]
6 changes: 3 additions & 3 deletions apps/web/Dockerfile.worker
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ COPY --from=deps --chown=worker:nodejs /app .

USER worker

# Health check
# Health check - verify the main process (PID 1) is alive
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD node -e "console.log('Worker health check')" || exit 1
CMD node -e "try { process.kill(1, 0); } catch(e) { process.exit(1); }"

# Run the worker using tsx
CMD ["pnpm", "tsx", "apps/web/src/workers/file-processor.ts"]
CMD ["pnpm", "tsx", "apps/web/src/workers/file-processor.ts"]