Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
depocoder committed Sep 21, 2024
2 parents 791f2f0 + 7cb907a commit 6457d22
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
venv
12 changes: 12 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.10-slim-bullseye

RUN pip install poetry==1.8.3

WORKDIR /app
COPY poetry.lock pyproject.toml /app

RUN POETRY_VIRTUALENVS_CREATE=false poetry install
COPY . /app

ENTRYPOINT ["python3"]
CMD ["prod.py"]
12 changes: 12 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,16 @@ poetry install
poetry run python dev.py
```

### Running with Docker Compose

```bash
docker compose up -d
```

If code was changed, rebuild images:

```bash
docker compose up --build -d
```

### Open [OpenAPI](http://localhost:44777/docs)
32 changes: 32 additions & 0 deletions backend/prod.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Runs the application for production development.
"""
import os

import uvicorn
from rich.console import Console

try:
import uvloop
except ModuleNotFoundError:
pass
else:
uvloop.install()

if __name__ == "__main__":
os.environ["APP_ENV"] = "prod"
host = os.environ.get("APP_HOST", "0.0.0.0")
port = int(os.environ.get("APP_PORT", 8000))

console = Console()
console.rule("[bold yellow]Running for production", align="left")
console.print(f"[bold yellow]Visit http://{host}:{port}/")

uvicorn.run(
"app.main:app",
host=host,
port=port,
lifespan="on",
log_level="info",
reload=True,
)
13 changes: 13 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
backend:
build:
context: ./backend
container_name: calendar-backend
restart: always
environment:
APP_HOST: "0.0.0.0"
APP_PORT: "8000"
volumes:
- ./backend:/app/
ports:
- 8000:8000

0 comments on commit 6457d22

Please sign in to comment.