diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..141e71a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +venv/ +.venv/ +__pycache__/ +*.pyc +node_modules/ +frontend/node_modules/ +frontend/dist/ +frontend/release/ +release/ +.git/ diff --git a/.gitignore b/.gitignore index bf09b78..ef329e5 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ __pycache__/ node_modules/ frontend/node_modules/ frontend/dist/ +frontend/release/ +release/ diff --git a/contrib/linux/Dockerfile b/contrib/linux/Dockerfile new file mode 100644 index 0000000..22b7725 --- /dev/null +++ b/contrib/linux/Dockerfile @@ -0,0 +1,31 @@ +FROM node:22.14.0-bookworm + +# System dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3 python3-pip python3-venv libpython3.11 \ + binutils \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /build + +# Copy repo +COPY . . + +# Python venv + dependencies +RUN python3 -m venv venv && \ + venv/bin/pip install --no-cache-dir -r requirements.txt + +# Compile Python CLI into a standalone binary +RUN venv/bin/pip install --no-cache-dir pyinstaller && \ + venv/bin/pyinstaller --onefile --name cli src/cli.py && \ + mkdir -p frontend/resources && \ + cp dist/cli frontend/resources/cli + +# JS dependencies + electron-builder +RUN cd frontend && npm ci && npm install --no-save electron-builder + +# Build +RUN cd frontend && npx vite build && npx electron-builder --linux AppImage --publish never + +# Export AppImage +CMD cp frontend/release/*.AppImage /out/ diff --git a/contrib/linux/build.sh b/contrib/linux/build.sh new file mode 100755 index 0000000..5d66c8d --- /dev/null +++ b/contrib/linux/build.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -euo pipefail + +REPO_ROOT=$(cd "$(dirname "$0")/../.." && pwd) +OUT_DIR="$REPO_ROOT/release" + +mkdir -p "$OUT_DIR" + +docker build -t wallet-generator-builder \ + -f "$REPO_ROOT/contrib/linux/Dockerfile" \ + "$REPO_ROOT" + +docker run --rm \ + -v "$OUT_DIR:/out" \ + wallet-generator-builder + +echo "AppImage saved to: $OUT_DIR" +ls "$OUT_DIR"/*.AppImage diff --git a/frontend/electron/main.cjs b/frontend/electron/main.cjs index 15bbd7c..86a1902 100644 --- a/frontend/electron/main.cjs +++ b/frontend/electron/main.cjs @@ -48,21 +48,24 @@ function resolveWalletFile(kind, filename) { return filePath } -// ── Resolve Python executable ────────────────────────────────────────────────── -function findPython() { +// ── Resolve CLI command (dev: python + cli.py, prod: bundled binary) ────────── +function getCliCommand() { + if (!isDev) { + const bundled = path.join(process.resourcesPath, 'cli') + if (fs.existsSync(bundled)) return { exec: bundled, baseArgs: [] } + } const repoRoot = path.join(__dirname, '..', '..') - const venvPython = path.join(repoRoot, 'venv', 'bin', 'python') - return fs.existsSync(venvPython) ? venvPython : 'python3' + const python = fs.existsSync(path.join(repoRoot, 'venv', 'bin', 'python')) + ? path.join(repoRoot, 'venv', 'bin', 'python') + : 'python3' + return { exec: python, baseArgs: [path.join(repoRoot, 'src', 'cli.py')] } } // ── Call Python CLI ──────────────────────────────────────────────────────────── function callPython(command, args = {}) { return new Promise((resolve, reject) => { - const python = findPython() - const repoRoot = path.join(__dirname, '..', '..') - const cliPath = path.join(repoRoot, 'src', 'cli.py') - - execFile(python, [cliPath, command, JSON.stringify(args)], { cwd: repoRoot }, (err, stdout, stderr) => { + const { exec, baseArgs } = getCliCommand() + execFile(exec, [...baseArgs, command, JSON.stringify(args)], (err, stdout, stderr) => { if (err) { reject(new Error(stderr || err.message)); return } try { const result = JSON.parse(stdout.trim()) @@ -139,7 +142,7 @@ function createWindow() { height: 750, minWidth: 320, minHeight: 480, - title: 'Wallet Generator', + title: 'wallet-gen', backgroundColor: '#0f1117', icon: path.join(__dirname, '..', 'public', 'icons', 'icon.png'), webPreferences: { diff --git a/frontend/index.html b/frontend/index.html index e8c63f8..6584924 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,7 +4,7 @@ -