Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Build Docker by Briefcase and Briefcase Package Web Static #2118

Closed
wladradchenko opened this issue Jan 18, 2025 · 6 comments
Labels
enhancement New features, or improvements to existing features.

Comments

@wladradchenko
Copy link

What is the problem or limitation you are having?

I am working on a project using Briefcase, and I encountered an issue when trying to build a Docker container for my application. I found information in the documentation about Docker integration (https://briefcase.readthedocs.io/en/stable/reference/platforms/linux/system.html), and I tried running the command briefcase build docker, but it failed with the error message "Unable to clean up from determining if Docker is mapping users." My project is based on Briefcase, and there is a need to run it in a Docker container. To do so, I am currently forced to restructure my app into a regular Flask app, but I wonder if there is a way to leverage the existing pyproject.toml configuration of Briefcase to build a Docker container in a manner similar to the following Dockerfile:

FROM nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04
RUN apt-get update && \
    apt-get install -y git libgl1 libglib2.0-0 libsndfile1 ffmpeg python3 python3-pip && \
    apt-get clean && \
    cd / && \
    git clone https://github.com/octaspace/wunjo.git && \
    cd wunjo && \
    python3 -m pip install -r requirements.txt && \
    pip3 install -U xformers --index-url https://download.pytorch.org/whl/cu124
EXPOSE 8000
ENV DEBUG=True
ENV PORT=8000
WORKDIR /wunjo
ENTRYPOINT ["python3", "app.py"]

Describe the solution you'd like

I would like to be able to build a Docker container directly using Briefcase, without having to restructure my project. Ideally, Briefcase should offer a way to configure Docker support in the pyproject.toml file and create a Docker container for my application while retaining the existing architecture. I would also like to understand how to package the web static files in a way that allows them to be served through a Docker container without additional modifications.

Describe alternatives you've considered

I have considered changing my application architecture to use Flask directly, outside of Briefcase, in order to facilitate Docker integration. However, I would prefer to keep the existing architecture that Briefcase provides, as it offers useful tooling for packaging and distributing the application. Additionally, I attempted to use briefcase build web static and briefcase run web, but I encountered an HTML page with a command like import runpy result = runpy.run_module("wunjo", run_name="main", alter_sys=True). I am unclear about what this is for and how to proceed. When using briefcase package web static, the resulting ZIP file contains only wheels and not the app program itself, and I am unsure how to deploy it.

As an alternative, I tried to package the web static files and connect my Flask app through Briefcase with Docker, but the process was not straightforward, and I did not find clear instructions for deploying it successfully.

Additional context

It would be very helpful to have clearer documentation or support for building Docker containers directly with Briefcase while maintaining the original architecture, or at least guidance on how to integrate Docker without changing the structure of my app. I am also looking for more information on how to properly handle static files in Briefcase when targeting Docker containers.

@wladradchenko wladradchenko added the enhancement New features, or improvements to existing features. label Jan 18, 2025
@wladradchenko
Copy link
Author

wladradchenko commented Jan 18, 2025

I also found wunjo-2.0.6b1-py3-none-any.whl, I unpacked it, but I didn't understand how to run it as a flask application.

@wladradchenko
Copy link
Author

I figured out the issue. It turned out very cool.

@rmartin16
Copy link
Member

FWIW, I think Briefcase already accommodates such a packaging workflow. However, I do not imagine that Briefcase would create the image to deploy and run your app. Instead, that image is the deployment environment for Briefcase's packaging artifact. In this way, you would run briefcase package and then incorporate the package contents in to the Docker image. If we consider the static web site zip, you could use a Dockerfile to extract the zip file in to the image and have the image start the web server on start up.

@freakboy3742
Copy link
Member

Agreed - a "Docker" packaging format would make some sense for the Web backend.

The complication would be exactly what we put in the Docker container. At present, the static web backend is no more than a folder of files, so it's up to the web host how those files are served. If we produced a Docker backend, we'd need to express an opinion (or provide options for) the web server used inside the container.

@freakboy3742
Copy link
Member

freakboy3742 commented Jan 19, 2025

See #2122 for a formalisation of this request.

@wladradchenko
Copy link
Author

Thanks for the answers. I liked that the whl file of my application was compiled, I used it in Docker with env variables, and got a server application from Docker. This solved all my queries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features, or improvements to existing features.
Projects
None yet
Development

No branches or pull requests

3 participants