mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-19 09:25:02 +00:00
Add docker-monitor.sh wrapper script for running monitoring tools in
production Docker containers, with automatic tsx installation.
Changes:
- docker-monitor.sh: Wrapper script for all monitoring commands
- Supports basic monitoring (stats, usage, ops, logs)
- Supports analysis commands (user-deep-dive, large-ops, etc)
- Auto-installs tsx in container when needed
- Handles report extraction from container
- Dockerfile: Include TypeScript source files for tsx execution
- package.json: Add docker:monitor npm scripts
- DOCKER-MONITORING.md: Production Docker monitoring guide
New npm scripts:
- npm run docker:monitor -- <command>: Run any monitoring command
- npm run docker:monitor:usage: Quick storage check
- npm run docker:monitor:all: Full monitoring suite
- npm run docker🐚 Interactive shell
Usage:
./scripts/docker-monitor.sh usage
./scripts/docker-monitor.sh analyze user-deep-dive --user 29
./scripts/docker-monitor.sh monitor-all --save
./scripts/docker-monitor.sh get-reports ./reports
72 lines
No EOL
2.6 KiB
Docker
72 lines
No EOL
2.6 KiB
Docker
# ---- Builder stage ----
|
|
FROM node:22-alpine AS builder
|
|
|
|
WORKDIR /repo
|
|
|
|
RUN apk add --no-cache openssl libc6-compat
|
|
|
|
# Upgrade npm to match lockfile version (npm 11)
|
|
RUN npm install -g npm@11
|
|
|
|
# Root package + lock (for workspace install)
|
|
COPY package.json package-lock.json ./
|
|
COPY packages/shared-schema/package.json ./packages/shared-schema/
|
|
COPY packages/super-sync-server/package.json ./packages/super-sync-server/
|
|
|
|
# Install ALL dependencies for the monorepo
|
|
RUN npm ci --ignore-scripts
|
|
|
|
# Copy source code
|
|
COPY packages/shared-schema/ ./packages/shared-schema/
|
|
COPY packages/super-sync-server/ ./packages/super-sync-server/
|
|
|
|
# Build shared-schema
|
|
WORKDIR /repo/packages/shared-schema
|
|
RUN npm run build
|
|
# Pack shared-schema to tgz for installation in production
|
|
RUN npm pack
|
|
|
|
# Build super-sync-server
|
|
WORKDIR /repo/packages/super-sync-server
|
|
RUN npx prisma generate
|
|
RUN rm -rf dist && npm run build
|
|
|
|
# ---- Runtime stage ----
|
|
FROM node:22-alpine AS production
|
|
|
|
# System deps for Prisma & healthcheck + create user BEFORE copying files
|
|
RUN apk add --no-cache openssl libc6-compat wget && \
|
|
addgroup -g 1001 -S nodejs && \
|
|
adduser -S supersync -u 1001 -G nodejs && \
|
|
mkdir -p /app/data && chown supersync:nodejs /app /app/data
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy built artifacts from builder (note: tsconfig rootDir is "." so structure is dist/src/ and dist/scripts/)
|
|
COPY --from=builder --chown=supersync:nodejs /repo/packages/super-sync-server/dist ./dist
|
|
COPY --from=builder --chown=supersync:nodejs /repo/packages/super-sync-server/public ./public
|
|
COPY --from=builder --chown=supersync:nodejs /repo/packages/super-sync-server/prisma ./prisma
|
|
COPY --from=builder --chown=supersync:nodejs /repo/packages/super-sync-server/scripts ./scripts
|
|
COPY --from=builder --chown=supersync:nodejs /repo/packages/super-sync-server/src ./src
|
|
COPY --from=builder --chown=supersync:nodejs /repo/packages/super-sync-server/package.json ./package.json
|
|
COPY --from=builder --chown=supersync:nodejs /repo/packages/shared-schema/sp-shared-schema-*.tgz ./shared-schema.tgz
|
|
|
|
# Install dependencies and generate Prisma client in single layer
|
|
RUN npm install ./shared-schema.tgz --ignore-scripts && \
|
|
npm install --ignore-scripts --omit=dev && \
|
|
npx prisma@5.22.0 generate && \
|
|
rm -f shared-schema.tgz && \
|
|
npm cache clean --force
|
|
|
|
USER supersync
|
|
|
|
EXPOSE 1900
|
|
|
|
ENV NODE_ENV=production
|
|
ENV PORT=1900
|
|
ENV DATA_DIR=/app/data
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
CMD wget --no-verbose --tries=1 --spider http://localhost:${PORT}/health || exit 1
|
|
|
|
CMD ["sh", "-c", "npx prisma db push --skip-generate && node dist/src/index.js"] |