diff --git a/robyn/scaffold/mongo/Dockerfile b/robyn/scaffold/mongo/Dockerfile index af40ae7f2..41fbec1db 100644 --- a/robyn/scaffold/mongo/Dockerfile +++ b/robyn/scaffold/mongo/Dockerfile @@ -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"] \ No newline at end of file +CMD ["python3", "app.py", "--log-level=DEBUG"] diff --git a/robyn/scaffold/mongo/app.py b/robyn/scaffold/mongo/app.py index c95ed43ce..8dc31bbce 100644 --- a/robyn/scaffold/mongo/app.py +++ b/robyn/scaffold/mongo/app.py @@ -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("/") @@ -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) diff --git a/robyn/scaffold/mongo/requirements.txt b/robyn/scaffold/mongo/requirements.txt new file mode 100644 index 000000000..78af56bc2 --- /dev/null +++ b/robyn/scaffold/mongo/requirements.txt @@ -0,0 +1,2 @@ +robyn +pymongo diff --git a/robyn/scaffold/no-db/Dockerfile b/robyn/scaffold/no-db/Dockerfile index af40ae7f2..41fbec1db 100644 --- a/robyn/scaffold/no-db/Dockerfile +++ b/robyn/scaffold/no-db/Dockerfile @@ -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"] \ No newline at end of file +CMD ["python3", "app.py", "--log-level=DEBUG"] diff --git a/robyn/scaffold/no-db/app.py b/robyn/scaffold/no-db/app.py index 9c1b31168..b809c11e8 100644 --- a/robyn/scaffold/no-db/app.py +++ b/robyn/scaffold/no-db/app.py @@ -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) diff --git a/robyn/scaffold/no-db/requirements.txt b/robyn/scaffold/no-db/requirements.txt new file mode 100644 index 000000000..3fab9165e --- /dev/null +++ b/robyn/scaffold/no-db/requirements.txt @@ -0,0 +1 @@ +robyn diff --git a/robyn/scaffold/postgres/Dockerfile b/robyn/scaffold/postgres/Dockerfile index af40ae7f2..1100b16ff 100644 --- a/robyn/scaffold/postgres/Dockerfile +++ b/robyn/scaffold/postgres/Dockerfile @@ -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"] \ No newline at end of file +CMD ["/usr/bin/supervisord"] diff --git a/robyn/scaffold/postgres/README.md b/robyn/scaffold/postgres/README.md deleted file mode 100644 index 697f13dda..000000000 --- a/robyn/scaffold/postgres/README.md +++ /dev/null @@ -1,8 +0,0 @@ -docker run - --name some-postgres - -p 5455:5432 - -e POSTGRES_USER=postgres - -e POSTGRES_PASSWORD=password - -e POSTGRES_DB=postgresDB - -d - postgres diff --git a/robyn/scaffold/postgres/app.py b/robyn/scaffold/postgres/app.py index a47697e50..eb23114e1 100644 --- a/robyn/scaffold/postgres/app.py +++ b/robyn/scaffold/postgres/app.py @@ -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 ) diff --git a/robyn/scaffold/postgres/requirements.txt b/robyn/scaffold/postgres/requirements.txt index 31d6c664b..0bb990a81 100644 --- a/robyn/scaffold/postgres/requirements.txt +++ b/robyn/scaffold/postgres/requirements.txt @@ -1 +1,2 @@ -psycopg2==2.9.9 \ No newline at end of file +robyn +psycopg2 diff --git a/robyn/scaffold/postgres/supervisord.conf b/robyn/scaffold/postgres/supervisord.conf new file mode 100644 index 000000000..0e6d88d12 --- /dev/null +++ b/robyn/scaffold/postgres/supervisord.conf @@ -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 diff --git a/robyn/scaffold/prisma/Dockerfile b/robyn/scaffold/prisma/Dockerfile index af40ae7f2..0b4995640 100644 --- a/robyn/scaffold/prisma/Dockerfile +++ b/robyn/scaffold/prisma/Dockerfile @@ -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"] \ No newline at end of file +CMD ["python3", "app.py", "--log-level=DEBUG"] diff --git a/robyn/scaffold/prisma/README.md b/robyn/scaffold/prisma/README.md deleted file mode 100644 index 323984e5e..000000000 --- a/robyn/scaffold/prisma/README.md +++ /dev/null @@ -1,15 +0,0 @@ - -Instructions for using prisma - -1. Install the python package -`` -pip install prisma cli -`` -2. initialize prisma with -`` -prisma generate -`` -3. create the prisma migration -`` -prisma migrate dev -`` diff --git a/robyn/scaffold/prisma/app.py b/robyn/scaffold/prisma/app.py index b7ca37109..81fa8a622 100644 --- a/robyn/scaffold/prisma/app.py +++ b/robyn/scaffold/prisma/app.py @@ -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) diff --git a/robyn/scaffold/prisma/requirements.txt b/robyn/scaffold/prisma/requirements.txt new file mode 100644 index 000000000..0e5a9a7ba --- /dev/null +++ b/robyn/scaffold/prisma/requirements.txt @@ -0,0 +1,2 @@ +robyn +prisma diff --git a/robyn/scaffold/sqlalchemy/Dockerfile b/robyn/scaffold/sqlalchemy/Dockerfile index af40ae7f2..41fbec1db 100644 --- a/robyn/scaffold/sqlalchemy/Dockerfile +++ b/robyn/scaffold/sqlalchemy/Dockerfile @@ -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"] \ No newline at end of file +CMD ["python3", "app.py", "--log-level=DEBUG"] diff --git a/robyn/scaffold/sqlalchemy/app.py b/robyn/scaffold/sqlalchemy/app.py index bbaa1f760..07bc38760 100644 --- a/robyn/scaffold/sqlalchemy/app.py +++ b/robyn/scaffold/sqlalchemy/app.py @@ -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__) @@ -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) diff --git a/robyn/scaffold/sqlalchemy/requirements.txt b/robyn/scaffold/sqlalchemy/requirements.txt new file mode 100644 index 000000000..4a625de61 --- /dev/null +++ b/robyn/scaffold/sqlalchemy/requirements.txt @@ -0,0 +1,2 @@ +robyn +SQLAlchemy diff --git a/robyn/scaffold/sqlite/Dockerfile b/robyn/scaffold/sqlite/Dockerfile index af40ae7f2..41fbec1db 100644 --- a/robyn/scaffold/sqlite/Dockerfile +++ b/robyn/scaffold/sqlite/Dockerfile @@ -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"] \ No newline at end of file +CMD ["python3", "app.py", "--log-level=DEBUG"] diff --git a/robyn/scaffold/sqlite/app.py b/robyn/scaffold/sqlite/app.py index 93c27a640..e0399e44a 100644 --- a/robyn/scaffold/sqlite/app.py +++ b/robyn/scaffold/sqlite/app.py @@ -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) diff --git a/robyn/scaffold/sqlite/requirements.txt b/robyn/scaffold/sqlite/requirements.txt new file mode 100644 index 000000000..3fab9165e --- /dev/null +++ b/robyn/scaffold/sqlite/requirements.txt @@ -0,0 +1 @@ +robyn