Skip to content

Commit

Permalink
Fix scaffold templates
Browse files Browse the repository at this point in the history
  • Loading branch information
sansyrox committed Oct 28, 2023
1 parent 2484988 commit 98621b7
Show file tree
Hide file tree
Showing 21 changed files with 70 additions and 46 deletions.
4 changes: 2 additions & 2 deletions robyn/scaffold/mongo/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ FROM python:3.11-bookworm

WORKDIR /workspace

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

COPY . .

EXPOSE 8080

CMD ["python3", "app.py", "--log-level=DEBUG"]
CMD ["python3", "app.py", "--log-level=DEBUG"]
6 changes: 3 additions & 3 deletions robyn/scaffold/mongo/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from robyn import Robyn

app = Robyn(__file__)
app.db = MongoClient("URL HERE")
db = MongoClient("URL HERE")

users = app.db.users # define a collection
users = db.users # define a collection


@app.get("/")
Expand Down Expand Up @@ -39,4 +39,4 @@ async def get_user(request):


if __name__ == "__main__":
app.start(url="0.0.0.0", port=8080)
app.start(host="0.0.0.0", port=8080)
2 changes: 2 additions & 0 deletions robyn/scaffold/mongo/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
robyn
pymongo
4 changes: 2 additions & 2 deletions robyn/scaffold/no-db/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ FROM python:3.11-bookworm

WORKDIR /workspace

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

COPY . .

EXPOSE 8080

CMD ["python3", "app.py", "--log-level=DEBUG"]
CMD ["python3", "app.py", "--log-level=DEBUG"]
2 changes: 1 addition & 1 deletion robyn/scaffold/no-db/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ def index():


if __name__ == "__main__":
app.start(url="0.0.0.0", port=8080)
app.start(host="0.0.0.0", port=8080)
1 change: 1 addition & 0 deletions robyn/scaffold/no-db/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
robyn
27 changes: 24 additions & 3 deletions robyn/scaffold/postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
# ---- Build the PostgreSQL Base ----
FROM postgres:latest AS postgres-base

ENV POSTGRES_USER=postgres
ENV POSTGRES_PASSWORD=password
ENV POSTGRES_DB=postgresDB

# ---- Build the Python App ----
FROM python:3.11-bookworm

# Install supervisor
RUN apt-get update && apt-get install -y supervisor

WORKDIR /workspace

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

COPY . .

EXPOSE 8080
# Copy PostgreSQL binaries from the first stage
COPY --from=postgres-base /usr/local/bin /usr/local/bin
COPY --from=postgres-base /usr/lib/postgresql /usr/lib/postgresql
COPY --from=postgres-base /usr/share/postgresql /usr/share/postgresql
COPY --from=postgres-base /var/lib/postgresql /var/lib/postgresql

# Add supervisord config
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

EXPOSE 8080 5455

CMD ["python3", "app.py", "--log-level=DEBUG"]
CMD ["/usr/bin/supervisord"]
8 changes: 0 additions & 8 deletions robyn/scaffold/postgres/README.md

This file was deleted.

1 change: 1 addition & 0 deletions robyn/scaffold/postgres/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
DB_USER = "postgres"
DB_PASS = "password"
DB_PORT = "5455"

conn = psycopg2.connect(
database=DB_NAME, host=DB_HOST, user=DB_USER, password=DB_PASS, port=DB_PORT
)
Expand Down
3 changes: 2 additions & 1 deletion robyn/scaffold/postgres/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
psycopg2==2.9.9
robyn
psycopg2
14 changes: 14 additions & 0 deletions robyn/scaffold/postgres/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[supervisord]
nodaemon=true

[program:python-app]
command=python3 /workspace/app.py --log-level=DEBUG
autostart=true
autorestart=true
redirect_stderr=true

[program:postgres]
command=postgres -c 'config_file=/etc/postgresql/postgresql.conf'
autostart=true
autorestart=true
redirect_stderr=true
7 changes: 5 additions & 2 deletions robyn/scaffold/prisma/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ FROM python:3.11-bookworm

WORKDIR /workspace

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

COPY . .

RUN python3 -m prisma generate
RUN python3 -m prisma migrate dev --name init

EXPOSE 8080

CMD ["python3", "app.py", "--log-level=DEBUG"]
CMD ["python3", "app.py", "--log-level=DEBUG"]
15 changes: 0 additions & 15 deletions robyn/scaffold/prisma/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion robyn/scaffold/prisma/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ async def h():


if __name__ == "__main__":
app.start(url="0.0.0.0", port=8080)
app.start(host="0.0.0.0", port=8080)
2 changes: 2 additions & 0 deletions robyn/scaffold/prisma/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
robyn
prisma
4 changes: 2 additions & 2 deletions robyn/scaffold/sqlalchemy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ FROM python:3.11-bookworm

WORKDIR /workspace

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

COPY . .

EXPOSE 8080

CMD ["python3", "app.py", "--log-level=DEBUG"]
CMD ["python3", "app.py", "--log-level=DEBUG"]
5 changes: 2 additions & 3 deletions robyn/scaffold/sqlalchemy/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
from sqlalchemy import create_engine, Column, Integer, String, Boolean
from sqlalchemy.orm import declarative_base, sessionmaker

DATABASE_URL = "sqlite:///./example.db"

engine = create_engine(DATABASE_URL)
engine = create_engine("sqlite+pysqlite:///:memory:", echo=True)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

app = Robyn(__file__)
Expand All @@ -30,4 +29,4 @@ class User(Base):

Base.metadata.create_all(bind=engine)

app.start(url="0.0.0.0", port=8080)
app.start(host="0.0.0.0", port=8080)
2 changes: 2 additions & 0 deletions robyn/scaffold/sqlalchemy/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
robyn
SQLAlchemy
4 changes: 2 additions & 2 deletions robyn/scaffold/sqlite/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ FROM python:3.11-bookworm

WORKDIR /workspace

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

COPY . .

EXPOSE 8080

CMD ["python3", "app.py", "--log-level=DEBUG"]
CMD ["python3", "app.py", "--log-level=DEBUG"]
2 changes: 1 addition & 1 deletion robyn/scaffold/sqlite/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ def index():


if __name__ == "__main__":
app.start(url="0.0.0.0", port=8080)
app.start(host="0.0.0.0", port=8080)
1 change: 1 addition & 0 deletions robyn/scaffold/sqlite/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
robyn

0 comments on commit 98621b7

Please sign in to comment.