demopark-electron-api-demos-zh_cn
RUNNING
History Source
SummaryIterations2Transcript8Dockerfile
01Iteration 1
WRITEWriteFile· step #1
0s
Dockerfile1060 bytes written
text27 lines · 1060 chars
# Build container for Electron-based Desktop App (Linux packaging)
FROM node:slim

# Install system dependencies required for building Electron apps
RUN apt-get update -y \
    && apt-get install -y --no-install-recommends build-essential python3 \
    && rm -rf /var/lib/apt/lists/*

# Set working directory for the build
WORKDIR /workspace

# Copy npm manifest first to leverage Docker cache
COPY package.json package-lock.json* ./

# Install dependencies using npm ci for reproducible builds
RUN npm ci

# Copy the rest of the source code
COPY . .

# Build the project for Linux (x64) using the provided npm script
RUN npm run package:linux

# Run the packaged Linux binary by default (auto-detect path for robustness)
# The build outputs to /workspace/out/*-linux-x64/electron-api-demos
CMD ["sh","-lc","set -e; APP_DIR=$(ls -1 /workspace/out | grep -E 'linux-x64$' | head -n1); if [ -z \"$APP_DIR\" ]; then echo 'Could not locate linux-x64 build dir in /workspace/out'; ls -la /workspace/out; exit 1; fi; exec /workspace/out/$APP_DIR/electron-api-demos"]
WRITEWriteFile· step #2
0s
/.dockerignore112 chars
dockerignore15 lines · 112 chars
node_modules/
dist/
out/
.git/
.gitignore
*.log
*.lock
*.tmp
.DS_Store
.cache
.netlify/
.vscode/
coverage/
.env
WRITEWriteFile· step #3
0s
.dockerignore102 bytes written
dockerignore14 lines · 102 chars
node_modules/
dist/
out/
.git/
.gitignore
*.log
*.lock
*.tmp
.DS_Store
.cache
.vscode/
coverage/
.env
VERIFYVerifyBuild· step #4
26s
VerifyBuildbuild_failed
Build error
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock
WRITEWriteFile· step #5
0s
Dockerfile1015 bytes written
text27 lines · 1015 chars
# Build container for Electron-based Desktop App (Linux packaging)
FROM node:slim

# Install system dependencies required for building Electron apps
RUN apt-get update -y \
    && apt-get install -y --no-install-recommends build-essential python3 \
    && rm -rf /var/lib/apt/lists/*

# Set working directory for the build
WORKDIR /workspace

# Copy npm manifest first to leverage Docker cache
COPY package.json package-lock.json* ./

# Install dependencies using npm ci for reproducible builds
RUN npm ci

# Copy the rest of the source code
COPY . .

# Build the project for Linux (x64) using the provided npm script
RUN npm run package:linux

# Run the packaged Linux binary by default (headless execution is not guaranteed in CI)
# The build outputs to /workspace/out/*-linux-x64/<app-folder>
CMD ["bash","-lc","set -e; echo 'Packaged Linux artifacts are located under /workspace/out'; if [ -d /workspace/out/linux-x64 ]; then echo 'Contents of linux-x64:'; ls -la /workspace/out/linux-x64; fi; exec /bin/bash"]
READReadFile· step #6
0s
Dockerfile1015 chars · 27 lines
text27 lines · 1015 chars
# Build container for Electron-based Desktop App (Linux packaging)
FROM node:slim

# Install system dependencies required for building Electron apps
RUN apt-get update -y \
    && apt-get install -y --no-install-recommends build-essential python3 \
    && rm -rf /var/lib/apt/lists/*

# Set working directory for the build
WORKDIR /workspace

# Copy npm manifest first to leverage Docker cache
COPY package.json package-lock.json* ./

# Install dependencies using npm ci for reproducible builds
RUN npm ci

# Copy the rest of the source code
COPY . .

# Build the project for Linux (x64) using the provided npm script
RUN npm run package:linux

# Run the packaged Linux binary by default (headless execution is not guaranteed in CI)
# The build outputs to /workspace/out/*-linux-x64/<app-folder>
CMD ["bash","-lc","set -e; echo 'Packaged Linux artifacts are located under /workspace/out'; if [ -d /workspace/out/linux-x64 ]; then echo 'Contents of linux-x64:'; ls -la /workspace/out/linux-x64; fi; exec /bin/bash"]
02Iteration 2
WRITEWriteFile· step #1
0s
Dockerfile1416 bytes written
text54 lines · 1416 chars
# syntax=docker/dockerfile:1

FROM node:slim AS builder
WORKDIR /app

# Install build dependencies
RUN apt-get update -y && \
    apt-get install -y --no-install-recommends build-essential python3 ca-certificates && \
    rm -rf /var/lib/apt/lists/*

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

# Copy source and build
COPY . .

# Build Linux package
RUN npm run package:linux

# Runtime image
FROM debian:bookworm-slim AS runtime

# Install runtime dependencies for Electron apps
RUN apt-get update -y && \
    apt-get install -y --no-install-recommends \
      ca-certificates \
      fontconfig \
      libasound2 \
      libatk1.0-0 \
      libatk-1.0-0 \
      libxcb1 \
      libxcb-dri3-0 \
      libx11-6 \
      libx11-xcb1 \
      libxss1 \
      libgtk-3-0 \
      libnss3 \
      libgbm1 \
      libpango-1.0-0 \
      libpangocairo-1.0-0 \
      && rm -rf /var/lib/apt/lists/*

# Copy built output from builder
COPY --from=builder /app/out /app/out

# Launcher script to run the packaged app regardless of folder name
RUN mkdir -p /usr/local/bin && \
    printf '#!/bin/sh\nset -e\nAPP_ROOT="/app/out"\nAPP_DIR=$(ls -1 "$APP_ROOT" | head -n 1)\nEXEC=$(ls -1 "$APP_ROOT/$APP_DIR" | head -n 1)\nexec "$APP_ROOT/$APP_DIR/$EXEC" "$@"\n' > /usr/local/bin/run-app.sh && \
    chmod +x /usr/local/bin/run-app.sh

WORKDIR /app/out
CMD ["/bin/sh","-lc","/usr/local/bin/run-app.sh"]
WRITEWriteFile· step #2
0s
.dockerignore197 bytes written
dockerignore26 lines · 197 chars
# Containers
**/.DS_Store
**/Thumbs.db

# Version control
.git
.gitignore

# Dependencies
node_modules/
dist/
out/
build/
coverage/
.env

# Logs
*.log
*.log.*

# Misc
*.tmp
*.bak
**/*.swp
**/*.swo