From 04060b82a0de4a80f2d142ec52a4d99932327b3d Mon Sep 17 00:00:00 2001 From: Anirban Basu Date: Mon, 6 May 2024 09:17:42 +0900 Subject: [PATCH] feat: Attempting Ploomber cloud deployment. --- .github/workflows/ploomber-cloud.yaml | 34 ++++++++++++++++++ Dockerfile | 28 ++++++++------- README.md | 2 +- local.dockerfile | 50 +++++++++++++++++++++++++++ ploomber-cloud.json | 4 +++ 5 files changed, 104 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/ploomber-cloud.yaml create mode 100644 local.dockerfile create mode 100644 ploomber-cloud.json diff --git a/.github/workflows/ploomber-cloud.yaml b/.github/workflows/ploomber-cloud.yaml new file mode 100644 index 0000000..3c706a5 --- /dev/null +++ b/.github/workflows/ploomber-cloud.yaml @@ -0,0 +1,34 @@ +name: Ploomber Cloud + +on: + push: + branches: + # only deploy from the main branch + - main + +jobs: + deploy-to-ploomber-cloud: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: '3.12' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install ploomber-cloud + + - name: Deploy + env: + PLOOMBER_CLOUD_KEY: ${{ secrets.PLOOMBER_CLOUD_KEY }} + LANGFUSE_PUBLIC_KEY: ${{ secrets.LANGFUSE_PUBLIC_KEY }} + LANGFUSE_SECRET_KEY: ${{ secrets.LANGFUSE_SECRET_KEY }} + run: | + ploomber-cloud deploy --watch-incremental + # The --watch-incremental flag will print deployment status and deployment + # log updates to the GitHub logs. + # To learn more, visit: https://docs.cloud.ploomber.io/en/latest/user-guide/github.html diff --git a/Dockerfile b/Dockerfile index 3971492..613e4bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# ** This Dockerfile is for use with Ploomber cloud deployment ** + # Pull Python 3.12 on Debian Bookworm slim image FROM python:3.12.3-slim-bookworm @@ -21,14 +23,8 @@ RUN apt-get update && apt-get -y upgrade && apt-get -y dist-upgrade && apt-get - # Set the working directory in the container WORKDIR /app -# Copy the project files -COPY ./*.py ./ -COPY ./pages/*.py ./pages/ -COPY ./utils/*.py ./utils/ -COPY ./*.md ./LICENSE ./requirements.txt ./ -COPY ./.env.docker ./.env -COPY ./*.sh ./ -RUN chmod +x *.sh +# Copy only the requirements file to take advantage of layering (see: https://docs.cloud.ploomber.io/en/latest/user-guide/dockerfile.html) +COPY ./requirements.txt ./ # Setup Virtual environment RUN python -m venv /app/venv @@ -39,10 +35,16 @@ ENV PATH="/app/venv/bin:$PATH" ENV VIRTUAL_ENV="/app/venv" # Install dependencies -RUN /app/venv/bin/pip install -r requirements.txt +RUN /app/venv/bin/pip install -r requirements.txt --no-cache-dir + +# Copy the project files +COPY ./*.md ./LICENSE ./ +COPY ./.env.docker ./.env +COPY ./*.py ./ +COPY ./pages/*.py ./pages/ +COPY ./utils/*.py ./utils/ -EXPOSE 8765 +# Expose the port to conect +EXPOSE 80 # Run the application -# CMD ["solara", "run", "solapp.py", "--host=0.0.0.0", "--production"] -ENTRYPOINT [ "/app/run_starlette.sh" ] -# Expose the port to conect \ No newline at end of file +ENTRYPOINT ["solara", "run", "solapp.py", "--host=0.0.0.0", "--port=80", "--production"] \ No newline at end of file diff --git a/README.md b/README.md index 028b180..7400eaa 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ Some settings can be modified through the app's web interface. All settings can You can run the app in a Docker container. By default, the app inside the Docker container will not use persistable index storage, document storage or graph storage. To run the app in a Docker container, you have to build its image (which we name as `tldrlc` although you can choose any other name) and run an instance (which we name as `tldrlc-container` but you can also pick a name of your choice) of that image, as follows. ``` -docker build -t tldrlc . +docker build -f local.dockerfile -t tldrlc . docker create -p 8765:8765/tcp --name tldrlc-container tldrlc docker container start tldrlc-container ``` diff --git a/local.dockerfile b/local.dockerfile new file mode 100644 index 0000000..476ca71 --- /dev/null +++ b/local.dockerfile @@ -0,0 +1,50 @@ +# Copyright 2024 Anirban Basu + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Pull Python 3.12 on Debian Bookworm slim image +FROM python:3.12.3-slim-bookworm + +# Upgrade and install basic packages +RUN apt-get update && apt-get -y upgrade && apt-get -y dist-upgrade && apt-get -y install nano build-essential + +# Set the working directory in the container +WORKDIR /app + +# Copy only the requirements file to take advantage of layering (see: https://docs.cloud.ploomber.io/en/latest/user-guide/dockerfile.html) +COPY ./requirements.txt ./ + +# Setup Virtual environment +RUN python -m venv /app/venv +RUN /app/venv/bin/python -m ensurepip +RUN /app/venv/bin/pip install --no-cache --upgrade pip setuptools + +ENV PATH="/app/venv/bin:$PATH" +ENV VIRTUAL_ENV="/app/venv" + +# Install dependencies +RUN /app/venv/bin/pip install -r requirements.txt --no-cache-dir + +# Copy the project files +COPY ./*.md ./LICENSE ./ +COPY ./*.sh ./ +RUN chmod +x *.sh +COPY ./.env.docker ./.env +COPY ./*.py ./ +COPY ./pages/*.py ./pages/ +COPY ./utils/*.py ./utils/ + +# Expose the port to conect +EXPOSE 8765 +# Run the application +ENTRYPOINT [ "/app/run_starlette.sh" ] \ No newline at end of file diff --git a/ploomber-cloud.json b/ploomber-cloud.json new file mode 100644 index 0000000..6370756 --- /dev/null +++ b/ploomber-cloud.json @@ -0,0 +1,4 @@ +{ + "id": "falling-salad-5976", + "type": "docker" +} \ No newline at end of file