Files
excalidraw-mcp-sentinel/Dockerfile.canvas
T
forkless a8ee1c229e
Docker Build (ARM64) / Build & Push (push) Successful in 50s
feat: env-var-ize WS URL as CUSTOM_VITE_WS_URL, add .env.example
2026-06-24 20:55:02 +02:00

70 lines
1.9 KiB
Docker

# Dockerfile for Canvas Server (Optional)
# Provides the web interface, REST API, and SQLite persistence (Alpine)
# Stage 1: Build frontend
FROM node:20-alpine AS frontend-builder
WORKDIR /app
ARG CUSTOM_VITE_WS_URL
ENV CUSTOM_VITE_WS_URL=$CUSTOM_VITE_WS_URL
COPY package*.json ./
RUN --mount=type=cache,target=/root/.npm npm ci --ignore-scripts
COPY frontend ./frontend
COPY vite.config.js ./
RUN npm run build:frontend
# Stage 2: Build backend (TypeScript compilation + native modules)
FROM node:20-alpine AS backend-builder
RUN apk add --no-cache python3 make g++
WORKDIR /app
COPY package*.json ./
RUN --mount=type=cache,target=/root/.npm npm ci
COPY src ./src
COPY tsconfig.json ./
RUN npm run build:server
# Stage 3: Production Canvas Server
FROM node:20-alpine AS production
RUN apk add --no-cache python3 make g++
RUN addgroup -S -g 1001 nodejs && \
adduser -S -u 1001 -G nodejs nodejs
WORKDIR /app
COPY package*.json ./
RUN --mount=type=cache,target=/root/.npm npm ci --omit=dev
# Remove build tools after native modules are compiled
RUN apk del python3 make g++
COPY --from=backend-builder /app/dist ./dist
COPY --from=frontend-builder /app/dist/frontend ./dist/frontend
RUN mkdir -p /app/data && chown -R nodejs:nodejs /app
USER nodejs
ENV NODE_ENV=production
ENV PORT=3000
# HOST=0.0.0.0 is correct inside Docker: the container binds all interfaces,
# but external access is gated by the published port mapping in docker-compose.yml.
# For local dev without Docker, the server defaults to localhost (127.0.0.1).
ENV HOST=0.0.0.0
ENV EXCALIDRAW_DB_PATH=/app/data/excalidraw.db
EXPOSE 3000
CMD ["node", "dist/server.js"]
LABEL org.opencontainers.image.source="https://github.com/celstnblacc/excalidraw-mcp-sentinel"
LABEL org.opencontainers.image.description="MCP Excalidraw Canvas Server - Web UI and REST API (with SQLite persistence & multi-tenancy)"
LABEL org.opencontainers.image.licenses="MIT"