Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
feat: Attempting Ploomber cloud deployment.
Browse files Browse the repository at this point in the history
  • Loading branch information
anirbanbasu committed May 6, 2024
1 parent b8533a9 commit 04060b8
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 14 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/ploomber-cloud.yaml
Original file line number Diff line number Diff line change
@@ -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
28 changes: 15 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
ENTRYPOINT ["solara", "run", "solapp.py", "--host=0.0.0.0", "--port=80", "--production"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
50 changes: 50 additions & 0 deletions local.dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
4 changes: 4 additions & 0 deletions ploomber-cloud.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"id": "falling-salad-5976",
"type": "docker"
}

0 comments on commit 04060b8

Please sign in to comment.