google / mesop

Build delightful web apps quickly in Python
https://google.github.io/mesop/
Apache License 2.0
4.17k stars 190 forks source link

:memo: Please drop a guide to build a docker image #440

Closed adriens closed 1 week ago

adriens commented 2 weeks ago

Is your feature request related to a problem? Please describe.

Actually, current documentation about deployment only shows how to run it on Google Cloud Run :

"To deploy your Mesop application, we recommend using Google Cloud Run because it's easy to get started and there's a free tier. However, it's possible to deploy your Mesop to other Cloud platforms."

In my case, I need to deploy the resulting app to our local infrastructures... then we need to provide a docker Image.

Describe the solution you'd like

Please provide a few lines detailing how to build and run the docker image of the meseop app'. It seems like it depends on fastAPI so it should do the job (this is also what seduced me).

Describe alternatives you've considered

Explore and make the doc by ourselves.

Additional context

I'll use mesop as part of the Call for Paper for #NODES24. it will be the front-end of our ChatBOT, which strongly relies on Google APIGEE by the way

CFP Submitted(1)

richard-to commented 1 week ago

Do you want the docker image to serve your custom Mesop application? I think I can provide an example of that.


Just FYI, Mesop under the hood uses Flask currently.

adriens commented 1 week ago

Hi @richard-to , yes, that's it as for my demo I plan do deploy it as an image that was previously pushed to ghcr.io from our Gh ACtions... then pulled by podman.

A simple dummy code snippet or directory to acheve that would be just awesome :star_struck:

richard-to commented 1 week ago

Here's one of my demo apps. I added a Dockerfile to it here: https://github.com/richard-to/mesop-jeopardy/blob/main/Dockerfile

You can run this using:

docker-compose up -d

Then you can view it at localhost:8080

Note that the app will run, but it won't work without setting a Google API Key for Gemini.

I figure you just want an example of a Docker image, so it's not necessary.

adriens commented 1 week ago

Hey @richard-to , thanks a lot for your help. Yup, that's the kind of thing I was looking for. Now, thanks to your post I have alle the required materlal to rapidly drop somehting interesting next week for my internal demo.

Thanks a lot for you help :pray:

# Build Docker image for deployment.

FROM python:3.10.14-bullseye

RUN apt-get update && \
  apt-get install -y \
  # General dependencies
  locales \
  locales-all && \
  # Clean local repository of package files since they won't be needed anymore.
  # Make sure this line is called after all apt-get update/install commands have
  # run.
  apt-get clean && \
  # Also delete the index files which we also don't need anymore.
  rm -rf /var/lib/apt/lists/*

ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8

# Install dependencies
COPY requirements.txt .
RUN pip install -r requirements.txt

# Create non-root user
RUN groupadd -g 900 mesop && useradd -u 900 -s /bin/bash -g mesop mesop
USER mesop

# Add app code here
COPY . /srv/mesop-jeopardy
WORKDIR /srv/mesop-jeopardy

# Run Mesop through gunicorn. Should be available at localhost:8080
CMD ["gunicorn", "--bind", "0.0.0.0:8080", "app:me"]
wwwillchen commented 1 week ago

@richard-to would be great to add this to our deployment guide https://google.github.io/mesop/guides/deployment/ :)

I've seen quite a few questions elsewhere about this.

adriens commented 1 week ago

That would be awesome

adriens commented 5 days ago

:partying_face: Just plugged a mesop front-end in front of our AI agent: image

Behind the scene :

adriens commented 5 days ago

Tweet

image

richard-to commented 5 days ago

Awesome. I'm excited that you were able to get Mesop integrated. Good luck on the presentation for #nodes24. Feel free to post the presentation if it gets accepted.