Add Docker build environment for KiCad WASM
- Add Dockerfile with ARM64-native emscripten/emsdk:4.0.2-arm64 image - Add docker-compose.yml with resource limits (10 CPUs, 16GB RAM) - Add helper scripts (build.sh, shell.sh, entrypoint.sh) - Add Docker README with usage instructions - Update playwright.config.ts to find free port dynamically - Add .dockerignore and .gitignore entries for build artifacts The Docker environment provides reproducible builds with: - Named volume for build cache (faster I/O on macOS) - Resource limits to prevent system lockups - Interactive shell access for debugging 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
c408410c7d
commit
b5e46a0aba
9 changed files with 262 additions and 3 deletions
|
|
@ -1,4 +1,49 @@
|
|||
import { defineConfig, devices } from '@playwright/test';
|
||||
import { execSync } from 'child_process';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
const PORT_FILE = path.join(__dirname, '.test-port');
|
||||
|
||||
// Get existing port from file or find a new one
|
||||
// This ensures all workers use the same port
|
||||
function getOrFindPort(): number {
|
||||
// Check if port file exists and is recent (created in last 60 seconds)
|
||||
try {
|
||||
const stat = fs.statSync(PORT_FILE);
|
||||
const age = Date.now() - stat.mtimeMs;
|
||||
if (age < 60000) {
|
||||
const port = parseInt(fs.readFileSync(PORT_FILE, 'utf-8').trim());
|
||||
if (port > 0 && port < 65536) {
|
||||
return port;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// File doesn't exist or can't be read
|
||||
}
|
||||
|
||||
// Find a new free port
|
||||
const port = findFreePort();
|
||||
fs.writeFileSync(PORT_FILE, port.toString());
|
||||
return port;
|
||||
}
|
||||
|
||||
// Find a free port dynamically using a shell command
|
||||
function findFreePort(): number {
|
||||
// Use Python to find a free port (works on macOS and Linux)
|
||||
try {
|
||||
const result = execSync(
|
||||
'python3 -c "import socket; s=socket.socket(); s.bind((\'\',0)); print(s.getsockname()[1]); s.close()"',
|
||||
{ encoding: 'utf-8' }
|
||||
);
|
||||
return parseInt(result.trim());
|
||||
} catch {
|
||||
// Fallback to default port range
|
||||
return 9000 + Math.floor(Math.random() * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
const port = getOrFindPort();
|
||||
|
||||
export default defineConfig({
|
||||
testDir: './e2e',
|
||||
|
|
@ -13,7 +58,7 @@ export default defineConfig({
|
|||
testIgnore: ['**/button-finder.spec.ts'],
|
||||
|
||||
use: {
|
||||
baseURL: 'http://localhost:8080',
|
||||
baseURL: `http://localhost:${port}`,
|
||||
trace: 'on-first-retry',
|
||||
// Grant clipboard and font permissions for tests
|
||||
permissions: ['clipboard-read', 'clipboard-write', 'local-fonts'],
|
||||
|
|
@ -27,8 +72,8 @@ export default defineConfig({
|
|||
],
|
||||
|
||||
webServer: {
|
||||
command: 'npx serve wasm-app -p 8080',
|
||||
port: 8080,
|
||||
command: `npx serve wasm-app -p ${port}`,
|
||||
port: port,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue