Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
imchairmanm committed Aug 16, 2024
0 parents commit 2af996a
Show file tree
Hide file tree
Showing 8 changed files with 552 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/autocommit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Keep Repository Active

on:
schedule:
- cron: '0 0 */28 * *'

jobs:
create-empty-commit:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main

- name: Configure Git
run: |
git config user.name 'Automatic action'
git config user.email 'noreply@koyeb.com'
- name: Create an empty commit and push
run: |
git commit --allow-empty -m "Automated empty commit to keep repo active" -m "This commit is generated automatically every few weeks to prevent GitHub Actions from being disabled due to inactivity."
git push origin main
20 changes: 20 additions & 0 deletions .github/workflows/cleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Cleanup Koyeb application

on:
delete:
branches:
- '*'

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Install and configure the Koyeb CLI
uses: koyeb-community/koyeb-actions@v2
with:
api_token: "${{ secrets.KOYEB_EXAMPLES_APPS_TOKEN }}"

- name: Cleanup Koyeb application
uses: koyeb/action-git-deploy/cleanup@v1
with:
app-name: shiny-python-${{ github.event.ref }}
30 changes: 30 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build and deploy the application to Koyeb

on:
schedule:
- cron: '35 9 * * *'
push:
branches:
- '*'

jobs:
deploy:
concurrency:
group: "${{ github.ref_name }}"
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- name: Install and configure the Koyeb CLI
uses: koyeb-community/koyeb-actions@v2
with:
api_token: "${{ secrets.KOYEB_EXAMPLES_APPS_TOKEN }}"

- name: Build and deploy the application
uses: koyeb/action-git-deploy@v1
with:
app-name: shiny-python-${{ github.ref_name }}
service-ports: "8000:http"
service-routes: "/:8000"
git-builder: buildpack
git-run-command: "shiny run --host 0.0.0.0 --port 8000 app.py"
skip-cache: true
162 changes: 162 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[![example-shiny-python](https://github.com/koyeb/example-shiny-python/actions/workflows/deploy.yaml/badge.svg)](https://github.com/koyeb/example-shiny-python/actions)

<div align="center">
<a href="https://koyeb.com">
<img src="https://www.koyeb.com/static/images/icons/koyeb.svg" alt="Logo" width="80" height="80">
</a>
<h3 align="center">Koyeb Serverless Platform</h3>
<p align="center">
Deploy a Shiny application in Python on Koyeb
<br />
<a href="https://koyeb.com">Learn more about Koyeb</a>
·
<a href="https://koyeb.com/docs">Explore the documentation</a>
·
<a href="https://koyeb.com/tutorials">Discover our tutorials</a>
</p>
</div>


## About Koyeb and the Shiny Python example application

Koyeb is a developer-friendly serverless platform to deploy apps globally. No-ops, servers, or infrastructure management. This repository contains a Shiny application written in Python that you can deploy on Koyeb in a single click.

This example application is designed to show how web application built with Shiny for Python can be built and deployed on Koyeb. The application is created from the [Shiny map distance template](https://shiny.posit.co/py/templates/map-distance/), allowing you to deploy an interactive, data-driven application to demonstrate Shiny functionality.

## Getting Started

Follow the steps below to deploy and run the Shiny for Python application on your Koyeb account.

### Requirements

You need a Koyeb account to successfully deploy and run this application. If you don't already have an account, you can sign-up for free [here](https://app.koyeb.com/auth/signup).

### Deploy using the Koyeb button

The fastest way to deploy the Shiny for Python application is to click the **Deploy to Koyeb** button below.

[![Deploy to Koyeb](https://www.koyeb.com/static/images/deploy/button.svg)](https://app.koyeb.com/deploy?name=shiny-python&type=git&repository=koyeb%2Fexample-shiny-python&branch=main&builder=buildpack&run_command=shiny+run+--host+0.0.0.0+--port+8000+app.py&instance_type=micro&env%5B%5D=&ports=8000%3Bhttp%3B%2F)

Clicking on this button brings you to the Koyeb App creation page with everything pre-set to launch this application.

_To modify this application example, you will need to fork this repository. Checkout the [fork and deploy](#fork-and-deploy-to-koyeb) instructions._

## Fork and deploy to Koyeb

If you want to customize and enhance this application, you need to fork this repository.

If you used the **Deploy to Koyeb** button, you can simply link your service to your forked repository to be able to push changes. Alternatively, you can manually create the application as described below.

On the [Koyeb Control Panel](https://app.koyeb.com/), on the **Overview** tab, click the **Create Web Service** button to begin.

1. Select **GitHub** as the deployment method.
2. In the repositories list, select the repository you just forked.
3. Select your preferred region and Instance type.
4. Open the **Builder** section. Click the **Override** toggle associated with the **Run command** and enter `shiny run --host 0.0.0.0 --port 8000 app.py` in the field.
6. Choose a name for your Service, i.e `shiny-python`, and click **Deploy**.

You will be taken to the deployment page where you can follow the build of your Shiny for Python application. Once the build is completed, your application will be deployed and you will be able to access it via `<YOUR_APP_NAME>-<YOUR_ORG_NAME>.koyeb.app`.

## Contributing

If you have any questions, ideas or suggestions regarding this application sample, feel free to open an [issue](https://github.com/koyeb/example-shiny-python/issues) or fork this repository and open a [pull request](https://github.com/koyeb/example-shiny-python/pulls).

## Contact

[Koyeb](https://www.koyeb.com) - [@gokoyeb](https://twitter.com/gokoyeb) - [Slack](http://slack.koyeb.com/)
Loading

0 comments on commit 2af996a

Please sign in to comment.