numbat icon indicating copy to clipboard operation
numbat copied to clipboard

add docker support

Open blairun opened this issue 1 year ago • 2 comments

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

  • The docker-compose.yaml file includes two build options. Uncomment the preferred option before running.
  • The application is exposed on port 8192. Adjust this in the docker-compose.yaml file if needed.

Testing

  • [ ] Verify that the Docker build process completes successfully.
  • [ ] Confirm that the web application is accessible and functioning correctly when deployed using Docker.
  • [ ] Test both build options in the docker-compose.yaml file.

blairun avatar Aug 24 '24 17:08 blairun

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).

sharkdp avatar Aug 29 '24 19:08 sharkdp

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.

blairun avatar Aug 31 '24 00:08 blairun

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

irevoire avatar Nov 03 '24 22:11 irevoire

Tentatively closing this for now.

sharkdp avatar Nov 08 '24 07:11 sharkdp