Skip to content

Commit f9e8167

Browse files
Merge pull request #64 from FaserF/improved-fixed-docker-web
Docker Web improvements & better security
2 parents 976e542 + a935098 commit f9e8167

38 files changed

+2554
-586
lines changed

.github/scripts/generate_release_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def main():
7373
args = parser.parse_args()
7474

7575
# Fallback version if version generation fails
76-
FALLBACK_VERSION = "2026.1.4"
76+
FALLBACK_VERSION = "2026.1.5"
7777

7878
try:
7979
base_ver = get_current_date_version()

.github/workflows/ci-orchestrator.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
component: backend
101101

102102
test-e2e:
103-
needs: [lint, decision]
103+
needs: [lint, decision, test-backend]
104104
if: needs.decision.outputs.run_e2e == 'true'
105105
uses: ./.github/workflows/test.yml
106106
with:

.github/workflows/deploy-docs.yml

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
workflow_dispatch:
1212

1313
permissions:
14-
contents: read
14+
contents: write
1515
pages: write
1616
id-token: write
1717

@@ -214,18 +214,12 @@ jobs:
214214
env:
215215
BASE_URL: /
216216

217-
- name: Upload artifact
218-
uses: actions/upload-pages-artifact@v4
217+
- name: Upload to gh-pages
218+
uses: JamesIves/github-pages-deploy-action@v4
219219
with:
220-
path: docs/.vitepress/dist
221-
222-
deploy:
223-
environment:
224-
name: github-pages
225-
url: ${{ steps.deployment.outputs.page_url }}
226-
needs: build
227-
runs-on: ubuntu-latest
228-
steps:
229-
- name: Deploy to GitHub Pages
230-
id: deployment
231-
uses: actions/deploy-pages@v4
220+
folder: docs/.vitepress/dist
221+
branch: gh-pages
222+
clean: true
223+
# Preserve the pr-preview directory
224+
clean-exclude: |
225+
pr-preview/

.github/workflows/docs_preview.yml

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,56 @@ jobs:
2828
- name: Checkout
2929
uses: actions/checkout@v6
3030

31+
- name: Set up Python
32+
uses: actions/setup-python@v6
33+
with:
34+
python-version: '3.13'
35+
36+
- name: Install Python Dependencies
37+
run: |
38+
python -m pip install --upgrade pip
39+
pip install .[test]
40+
pip install Pillow
41+
42+
- name: Pre-install Addons (Web)
43+
run: |
44+
mkdir -p src/switchcraft/addons
45+
python -c "import zipfile, os, glob; from pathlib import Path; [zipfile.ZipFile(z).extractall(Path('src/switchcraft/addons') / Path(z).stem.replace('switchcraft_', '')) for z in glob.glob('src/switchcraft/assets/addons/*.zip')]"
46+
47+
- name: Build Web Demo
48+
run: |
49+
python scripts/prepare_web_dist.py --bake
50+
mkdir -p build_web
51+
cp -r src/switchcraft build_web/
52+
53+
PR_NUMBER=${{ github.event.pull_request.number }}
54+
cat > build_web/web_entry.py <<EOF
55+
import os
56+
import sys
57+
import flet as ft
58+
# WASM compatibility patches
59+
if sys.platform == "emscripten":
60+
import pyodide_http
61+
pyodide_http.patch_all()
62+
sys.path.insert(0, os.getcwd())
63+
import switchcraft
64+
switchcraft.IS_DEMO = True
65+
import switchcraft.main
66+
if __name__ == "__main__":
67+
ft.run(switchcraft.main.main, assets_dir="assets")
68+
EOF
69+
70+
cd build_web
71+
# Simplified publish for preview - use the PR specific base-url
72+
flet publish web_entry.py --app-name "SwitchCraft Demo PR-$PR_NUMBER" --base-url "/pr-preview/pr-$PR_NUMBER/demo/" --distpath ../dist --assets switchcraft/assets
73+
cd ..
74+
75+
python scripts/prepare_web_dist.py --patch dist
76+
rm -rf docs/public/demo
77+
mkdir -p docs/public/demo
78+
cp -r dist/* docs/public/demo/
79+
shell: bash
80+
3181
- name: Setup Node
3282
uses: actions/setup-node@v6
3383
with:
@@ -36,8 +86,13 @@ jobs:
3686
cache-dependency-path: docs/package-lock.json
3787

3888
- name: Install dependencies
39-
run: npm ci
40-
working-directory: docs
89+
run: |
90+
cd docs
91+
if [ -f package-lock.json ]; then
92+
npm ci
93+
else
94+
npm install vitepress vue
95+
fi
4196
4297
- name: Build Docs
4398
run: npm run docs:build
@@ -52,15 +107,24 @@ jobs:
52107
preview-branch: gh-pages
53108
umbrella-dir: pr-preview
54109
action: auto
110+
comment: |
111+
🚀 **PR Preview is ready!**
112+
113+
- 📄 [Documentation Preview](https://switchcraft.fabiseitz.de/pr-preview/pr-${{ github.event.pull_request.number }}/)
114+
- 🎮 [Web Demo Preview](https://switchcraft.fabiseitz.de/pr-preview/pr-${{ github.event.pull_request.number }}/demo/)
115+
116+
*Built with love and GitHub Actions.*
55117
56118
cleanup-preview:
57119
runs-on: ubuntu-latest
58120
if: github.event.action == 'closed'
59121
steps:
122+
- name: Checkout
123+
uses: actions/checkout@v6
124+
60125
- name: Cleanup Preview
61126
uses: rossjrw/pr-preview-action@v1
62127
with:
63-
source-dir: docs/.vitepress/dist # Not used for cleanup but required by action validation sometimes
64128
preview-branch: gh-pages
65129
umbrella-dir: pr-preview
66-
action: remove
130+
action: delete

.github/workflows/release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ jobs:
7272
sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" src/switchcraft_ai/manifest.json
7373
sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" src/switchcraft_winget/manifest.json
7474
75+
# JSON-safe update for main asset manifest
76+
python -c "import json, os; p='src/switchcraft/assets/manifest.json'; d=json.load(open(p)) if os.path.exists(p) else {}; d.update({'version': os.environ['VERSION'], 'description': 'SwitchCraft - Enterprise Application Management'}); json.dump(d, open(p, 'w'), indent=4)"
77+
7578
7679
# Update .iss files (Inno Setup installer scripts)
7780
# Extract numeric version only (remove .dev0, +build, etc.) for VersionInfoVersion
@@ -125,7 +128,7 @@ jobs:
125128
git config --global user.name "github-actions[bot]"
126129
git config --global user.email "github-actions[bot]@users.noreply.github.com"
127130
128-
git add pyproject.toml src/switchcraft/__init__.py file_version_info.txt switchcraft.iss switchcraft_legacy.iss src/switchcraft_advanced/manifest.json src/switchcraft_ai/manifest.json src/switchcraft_winget/manifest.json
131+
git add pyproject.toml src/switchcraft/__init__.py file_version_info.txt switchcraft.iss switchcraft_legacy.iss src/switchcraft_advanced/manifest.json src/switchcraft_ai/manifest.json src/switchcraft_winget/manifest.json src/switchcraft/assets/manifest.json
129132
130133
131134
# Only commit if there are changes

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
if: steps.should_run.outputs.should_run == 'true'
5656
run: |
5757
python -m pip install --upgrade pip
58-
pip install .[test,gui,desktop]
58+
pip install .[test,gui,desktop,web-server]
5959
6060
- name: Run All Python Tests
6161
if: steps.should_run.outputs.should_run == 'true'
@@ -121,7 +121,7 @@ jobs:
121121
- name: Install Dependencies
122122
run: |
123123
python -m pip install --upgrade pip
124-
pip install .[test,gui,desktop]
124+
pip install .[test,gui,desktop,web-server]
125125
pip install pytest-asyncio
126126
127127
- name: Run E2E Integration Tests

Dockerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ COPY pyproject.toml .
1616
COPY README.md .
1717
COPY src ./src
1818

19-
# Install dependencies (Modern Flet only)
20-
# Note: We omit 'gui' (Legacy Tkinter) to avoid system package requirements
21-
RUN pip install --no-cache-dir .[modern]
19+
# Install dependencies (Modern Flet + Web Server + Web WASM)
20+
RUN pip install --no-cache-dir .[modern,web-server] flet-web packaging
2221

2322
# Generate Addons (Pre-installed)
2423
RUN python src/generate_addons.py
@@ -42,5 +41,5 @@ ENV SC_DISABLE_WINGET_INSTALL=1
4241
# Create symlink for assets so Flet can find them at /app/assets
4342
RUN ln -s /app/src/switchcraft/assets /app/assets
4443

45-
# Command to run the application in web mode
46-
CMD ["flet", "run", "--web", "--port", "8080", "--host", "0.0.0.0", "src/switchcraft/main.py"]
44+
# Command to run the application using the Auth Proxy Server
45+
CMD ["uvicorn", "switchcraft.server.app:app", "--host", "0.0.0.0", "--port", "8080"]

docker-compose.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
services:
2+
switchcraft-web:
3+
build: .
4+
image: switchcraft-web:latest
5+
container_name: switchcraft-web
6+
ports:
7+
- "8080:8080"
8+
volumes:
9+
- switchcraft_data:/root/.switchcraft
10+
environment:
11+
- SC_CLIENT_ID=${SC_CLIENT_ID}
12+
- SC_CLIENT_SECRET=${SC_CLIENT_SECRET}
13+
- SC_AUTH_PROVIDER=${SC_AUTH_PROVIDER:-entra}
14+
- SC_ENTRA_CLIENT_ID=${SC_ENTRA_CLIENT_ID}
15+
- SC_ENTRA_CLIENT_SECRET=${SC_ENTRA_CLIENT_SECRET}
16+
- SC_ENTRA_TENANT_ID=${SC_ENTRA_TENANT_ID}
17+
- SC_GITHUB_CLIENT_ID=${SC_GITHUB_CLIENT_ID}
18+
- SC_GITHUB_CLIENT_SECRET=${SC_GITHUB_CLIENT_SECRET}
19+
- SC_BASE_URL=${SC_BASE_URL}
20+
- SC_DISABLE_WINGET_INSTALL=1
21+
restart: unless-stopped
22+
23+
volumes:
24+
switchcraft_data:

docs/.vitepress/config.mts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default defineConfig({
1111
lang: 'en-US',
1212

1313
head: [
14-
['link', { rel: 'icon', href: '/favicon.ico' }],
14+
['link', { rel: 'icon', href: (process.env.BASE_URL || '/') + 'favicon.ico' }],
1515
['meta', { name: 'theme-color', content: '#6366f1' }],
1616
['meta', { name: 'og:type', content: 'website' }],
1717
['meta', { name: 'og:title', content: 'SwitchCraft Documentation - The Ultimate Packaging Assistant' }],
@@ -97,7 +97,8 @@ export default defineConfig({
9797
{ text: 'OMA-URI Reference', link: '/Intune_Configuration_Guide' },
9898
{ text: 'GPO / ADMX Policies', link: '/PolicyDefinitions/README' },
9999
{ text: 'Registry Settings', link: '/Registry' },
100-
{ text: 'Security Guide', link: '/SECURITY' }
100+
{ text: 'Security Guide', link: '/SECURITY' },
101+
{ text: 'Docker Self-Hosting', link: '/docker_setup' }
101102
]
102103
},
103104
{

0 commit comments

Comments
 (0)