MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / buildWithContainer

Function buildWithContainer

scripts/build-linux-appimage.js:145–301  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

143
144// Build using Docker or Podman
145function buildWithContainer() {
146 const runtime = containerRuntime.getRuntime();
147 const runtimeLabel = containerRuntime.getRuntimeLabel();
148 console.log(`Using ${runtimeLabel} for Linux build...\n`);
149
150 // Create a temporary Dockerfile for building
151 const dockerfileContent = `# Electron 43+ V8 headers require C++20 (GCC 13+). Bookworm's GCC 12 fails to compile better-sqlite3.
152FROM node:22-trixie-slim
153
154# Install build dependencies for AppImage and native modules
155RUN apt-get update && apt-get install -y \\
156 g++ \\
157 make \\
158 python3 \\
159 libnss3 \\
160 libatk-bridge2.0-0 \\
161 libdrm2 \\
162 libxkbcommon0 \\
163 libxcomposite1 \\
164 libxdamage1 \\
165 libxfixes3 \\
166 libxrandr2 \\
167 libgbm1 \\
168 libasound2 \\
169 libpango-1.0-0 \\
170 libatk1.0-0 \\
171 libcairo-gobject2 \\
172 libgtk-3-0 \\
173 libgdk-pixbuf-2.0-0 \\
174 && rm -rf /var/lib/apt/lists/*
175
176WORKDIR /app
177
178# Configure npm for better network reliability
179RUN npm config set fetch-retries 5 && \\
180 npm config set fetch-retry-mintimeout 20000 && \\
181 npm config set fetch-retry-maxtimeout 120000 && \\
182 npm config set fetch-timeout 300000
183
184# Copy package files and scripts (needed for postinstall hook)
185COPY package*.json ./
186COPY scripts/ ./scripts/
187
188# Skip postinstall during install; rebuild native modules explicitly below
189RUN npm install --ignore-scripts --loglevel=error || \\
190 (sleep 5 && npm install --ignore-scripts --loglevel=error) || \\
191 (sleep 10 && npm install --ignore-scripts --loglevel=error) && \\
192 npm cache clean --force
193
194# Clean any existing native module builds to ensure fresh rebuild
195RUN rm -rf node_modules/better-sqlite3/build || true
196
197# Rebuild native modules for Electron on Linux (requires GCC 13+ from trixie)
198RUN npx @electron/rebuild --version=$(node -p 'require("electron/package.json").version') || npx electron-builder install-app-deps
199
200# Copy application files
201COPY . .
202

Callers 1

mainFunction · 0.85

Calls 2

toWSLPathFunction · 0.85

Tested by

no test coverage detected