sharkdp / numbat

A statically typed programming language for scientific computations with first class support for physical dimensions and units
https://numbat.dev
Apache License 2.0
1.26k stars 53 forks source link

add docker support #551

Closed blairun closed 1 week ago

blairun commented 2 months ago

Add Docker support for web deployment

This pull request adds Docker support to easily deploy the Numbat web application. It includes a Dockerfile for building the application and a docker-compose.yaml for orchestrating the deployment.

Changes

New file: Dockerfile

Added a multi-stage Dockerfile that:

  1. Builds the WebAssembly package using Rust and wasm-pack.
  2. Sets up an Nginx server to host the built files.

New file: docker-compose.yaml

Added a docker-compose.yaml file that:

  1. Defines the service for the Numbat web application.
  2. Provides two options for building: a. From the local codebase b. Directly from the GitHub repository

How to use

To deploy the Numbat web application using Docker:

  1. Ensure Docker and Docker Compose are installed on your system.
  2. Navigate to the project root directory.
  3. Run docker-compose up --build to build and start the container.
  4. Access the application at http://localhost:8192.

Notes

Testing

sharkdp commented 2 months ago

Thank you for your contribution.

This works fine, but I wonder if it's really necessary and for what exactly? Once built, Numbat is a static web application. It can be "deployed" by simply copying it to a server. During development, I just run python -m http.server to work with it (see https://github.com/sharkdp/numbat/blob/master/numbat-wasm/README.md).

blairun commented 2 months ago

Thanks for the feedback. Docker support is just meant as an alternative for those who prefer containerized deployments. I prefer deploying numbat this way for its isolation, portability, and ease of setup and maintenance. Of course, if you don't think it fits in the current scope of the project, I completely understand.

irevoire commented 2 weeks ago

I must say I’m a bit lost here as well, once you have your nginx running in your container you still need to write some conf from the host machine right? Like, configure the host nginx to do a reverse proxy to your numbat container? In this case, it always seems easier (and less error-prone) to simply make nginx point to the static website.

Adding support for Docker in this repository means we would have to maintain the Docker container. Your PR doesn’t have a large surface area, but basically, it means we’ll have to update the Docker image as soon as possible and republish it every time Nginx or Alpine has a CVE or something (which happened not that long ago on Alpine iirc). It seems better to rely on the host nginx directly for security and maintenance on our side imo

sharkdp commented 1 week ago

Tentatively closing this for now.