Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeicor committed Jun 2, 2024
0 parents commit 7492b18
Show file tree
Hide file tree
Showing 22 changed files with 2,045 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch: { }

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: "write"
pages: "write"
id-token: "write"

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build-and-deploy:

runs-on: "ubuntu-latest"

environment:
name: "github-pages"
url: "${{ steps.deployment.outputs.page_url }}"

steps:
# Prepare
- uses: "actions/checkout@v4"
with:
lfs: "true"

# Build
- run: "./build.sh"

# Deploy
- uses: "actions/configure-pages@v5"
- uses: "actions/upload-pages-artifact@v3"
with:
path: 'export'
- id: "deployment"
uses: "actions/deploy-pages@v4"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/web/out.wasm
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# OCP C2W

This project can build [Build123d](https://github.com/gumyr/build123d)-based CAD
models (which relies on [OCP](https://github.com/CadQuery/OCP)) **completely inside the web browser**, thanks to [container2wasm](https://github.com/ktock/container2wasm).

- You can [run the demo script on github pages](https://yeicor-3d.github.io/ocp-c2w/). It works, but it is **extremely slow**...
- You can also get an **interactive console** and basic networking by [clicking this link](https://yeicor-3d.github.io/ocp-c2w/?args=bash&net=browser).
9 changes: 9 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -ex

docker build --tag c2w-build123d --network host docker

./c2w --debug-image --dockerfile docker/Dockerfile.c2w c2w-build123d web/out.wasm

echo "web/out.wasm is ready. Run server.py to serve web/ files on http://localhost:8000"
Binary file added c2w
Binary file not shown.
Binary file added c2w-net
Binary file not shown.
19 changes: 19 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM python:3-slim as base

RUN apt-get update && apt-get install -y libgl1 && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY tea_cup.py requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

RUN /bin/bash -c "find /usr/local/lib/python* -name '*.so*' -size +10M -print0 | tar -czvf libs.tar.gz --remove-files --null -T /dev/stdin | tee /dev/stderr"

FROM python:3-slim

WORKDIR /app

COPY --from=base / /

ENTRYPOINT ["/bin/bash", "-exc", "tar -C / -xzvf libs.tar.gz && rm libs.tar.gz && python -m trace --ignore-dir=$(python -c 'import sys; sep=\":\"; print(sep.join(sys.path)[1:])') -t ./tea_cup.py" ]
Loading

0 comments on commit 7492b18

Please sign in to comment.