diff --git a/README.md b/README.md index 831429f..9a72f9f 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,11 @@ The endpoint serves the 10 upcoming screenings for the day. The frontend automat ## Run -`poetry run uvicorn fdhview.main:app --reload` +For development run the application locally: + +```sh +poetry run uvicorn fdhview.main:app --reload +``` ## Endpoints @@ -21,3 +25,11 @@ The endpoint serves the 10 upcoming screenings for the day. The frontend automat * GET `/info` - serves desk info endpoint * GET `/api/screenings` - serves JSON with upcoming 10 films for today * GET `/api/screenings/prices` - serves JSON with pricing data + +## Docker + +Run the container with docker-compose: + +```sh +docker compose -f docker/docker-compose.yml up +``` diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..2246fb0 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,36 @@ +FROM python:3.14-slim AS builder + +ENV POETRY_NO_INTERACTION=1 \ + POETRY_VIRTUALENVS_IN_PROJECT=true + +RUN pip install --upgrade pip +RUN pip install poetry + +WORKDIR /app + +COPY poetry.lock pyproject.toml ./ + +RUN poetry install --only main --no-root + + +FROM python:3.14-slim AS runtime + +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 + +RUN adduser --disabled-password --gecos "" appuser + +WORKDIR /app + +COPY --from=builder /app/.venv /app/.venv +COPY --from=builder /app/pyproject.toml /app/poetry.lock ./ +COPY . /app + +RUN mkdir -p /data && chown appuser:appuser /data + +ENV PATH="/app/.venv/bin:$PATH" + +USER appuser + +EXPOSE 8000 +CMD ["uvicorn", "fdhview.main:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..65b151e --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,9 @@ +services: + app: + build: + context: .. + dockerfile: docker/Dockerfile + ports: + - "8000:8000" + environment: + SQL_FILE_NAME: ${SQL_FILE_NAME:-/data/app.db}