roipoussiere / cadquery-server

A web server used to render 3d models from CadQuery code loaded dynamically.
MIT License
52 stars 17 forks source link

Add Dockerfile and post to dockerhub #10

Closed qwelyt closed 2 years ago

qwelyt commented 2 years ago

This seems supernice. So nice that I want to be able to run it on my server and develop in that instead of on a local computer.

I've created a Dockerfile that works for this.

FROM python:3.9

RUN pip install 'cadquery-server[cadquery]'

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

RUN mkdir /data
WORKDIR data

RUN echo "import cadquery as cq\nfrom cq_server.ui import UI, show_object\nshow_object(cq.Workplane().box(10,10,10))" > /data/main.py

ENTRYPOINT ["cq-server", "/data"]

So base the entire thing on the python image (which is based on debian), install libgl, create a folder where cq-server will look for files and create a little default example. The example is just a nice add for those that forget to mount /data to something.

This still allows you to use all the flags that cq-server has. So docker run cq-server --ui-theme dark still works for example.

Given this if you accept the proposal, you could use GitHub Actions to build the image and publish it to DockerHub so users could just do docker pull roipoussiere/cadquery-server (or cq-server).

The resulting docker image is about 2.72 GB, but I don't think it's possible to really reduce it without loosing anything.

Thoughts?

qwelyt commented 2 years ago

Now that #11 is merged, what are your thoughts about adding GitHub Actions to automagically build and push to dockerhub when there is new stuff in main? And perhaps also tag images with the releases.

roipoussiere commented 2 years ago

I updated the docker file to load cq-server files locally instead from git (1e8e4ce).

This way it's really fast to rebuild the image when developing and we don't have git dependency.

I also added instructions on readme (47def65).

The image on the docker hub is now updated with the last version. You can give a try:

docker run -p 5000:5000 -v $(pwd)/examples:/data cadquery/cadquery-server

So I'm going to close this, please create a new issue about the CI. :)