Skip to content

Commit

Permalink
basic robyn
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmajestic committed Apr 4, 2024
1 parent 3fe529c commit 965dc12
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 2 deletions.
Empty file added .github/FUNDING.yml
Empty file.
27 changes: 27 additions & 0 deletions .github/workflows/robyn-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# .github/workflows/publish-dockerhub.yml
name: Publish Docker image to Docker Hub

on:
push:
branches: [ main ]

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ github.repository_owner }}/robyn-docker:latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.11-bookworm

WORKDIR /workspace

COPY . .

RUN pip install --no-cache-dir --upgrade -r requirements.txt


EXPOSE 8080

CMD ["python3", "app.py", "--log-level=DEBUG"]
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
# robyn-docker
Robyn, a Rust based API in Python, with Docker
Robyn with Docker πŸ³πŸ¦€
Welcome to robyn-docker, a project showcasing the power of Robyn, a Rust-based asynchronous web framework, through Python. This project demonstrates how to containerize a Robyn application using Docker, making deployment smooth and scalable across any environment.

Robyn brings together Rust's performance and safety with Python's simplicity and flexibility, offering an excellent choice for building high-performance web applications.

πŸš€ Getting Started
To get started with robyn-docker, you'll need to have Python and Docker installed on your machine. The following instructions will guide you through setting up a basic Robyn project and containerizing it with Docker.

Getting Started: https://robyn.tech/documentation/example_app

```
$ python3 -m robyn --create
? Directory Path: .
? Need Docker? (Y/N) Y
? Please select project type (Mongo/Postgres/Sqlalchemy/Prisma):
❯ No DB
Sqlite
Postgres
MongoDB
SqlAlchemy
Prisma
```
21 changes: 21 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from robyn import Robyn
import sqlite3

app = Robyn(__file__)


@app.get("/")
def index():
# your db name
conn = sqlite3.connect("example.db")
cur = conn.cursor()
cur.execute("DROP TABLE IF EXISTS test")
cur.execute("CREATE TABLE test(column_1, column_2)")
res = cur.execute("SELECT name FROM sqlite_master")
th = res.fetchone()
table_name = th[0]
return f"Welcome to Robyn, This is a rust based Python package utilzing the effciency of Rust with simplicity of Python. Here is an example fo the SQLtable create by default in this framework {table_name}"


if __name__ == "__main__":
app.start(host="0.0.0.0", port=8080)
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

services:
app:
build: .
ports:
- "8080:8080"
40 changes: 40 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Robyn with Docker 🐳</title>
<style>
body {
margin: 0;
padding: 0;
font-family: 'Arial', sans-serif;
background-color: #f0f0f0;
text-align: center;
padding-top: 50px;
}
h1, p {
color: #333;
}
.container {
width: 80%;
margin: auto;
background-color: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.emoji {
font-size: 48px;
}
</style>
</head>
<body>
<div class="container">
<h1>Welcome to Robyn with Docker 🐳</h1>
<p class="emoji">πŸ¦€ + 🐍 + 🐳 = ❀️</p>
<p>Robyn is a fast and asynchronous web framework, built with the power of Rust πŸ¦€ and the simplicity of Python 🐍. This unique combination allows for high-performance web applications that are easy to develop.</p>
<p>And what's even better? We're running it in a Docker 🐳 container! This means our Robyn application is encapsulated in a lightweight, portable environment that can run almost anywhere - from your local dev machine to the cloud ☁️ - consistently and efficiently.</p>
<p>So, whether you're developing microservices, APIs, or web apps, Robyn with Docker offers a robust, scalable, and enjoyable development experience. Let's dive in! πŸš€</p>
</div>
</body>
</html>
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
robyn

0 comments on commit 965dc12

Please sign in to comment.