demopark-electron-api-demos-zh_cn
SUCCESS
26m 00s
History Source
SummaryIterations2Transcript31Dockerfile
Dockerfile41 lines · 814 chars
# syntax=docker/dockerfile:1

FROM node:18-bullseye-slim AS builder

# Install build tools (some native modules may require compilation)
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
      ca-certificates \
      curl \
      git \
      python3 \
      make \
      g++ \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Install dependencies
COPY package.json package-lock.json ./
RUN npm ci

# Copy source
COPY . .

# Optional: prune devtools or large assets here if needed in the future

FROM node:18-bullseye-slim AS runtime

# Create non-root user
RUN groupadd -r app && useradd -m -r -g app app

# Copy built app and node_modules from builder
COPY --from=builder /app /app

WORKDIR /app

USER app

# Expose default Electron app start; starts with npm start
CMD ["npm", "start"]