From cd7a5431e9fc5786de4998719a40907533bd4cb4 Mon Sep 17 00:00:00 2001 From: sam Date: Thu, 14 Mar 2024 02:35:59 +0100 Subject: [PATCH] add (non-working so far) dockerfile --- Dockerfile | 30 ++++++++++++++++++++++++++++++ README.md | 11 +++++++++++ docker-compose.yml | 36 ++++++++++++++++++++++++++++++++++++ entry.sh | 5 +++++ 4 files changed, 82 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 entry.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9e1f06c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM docker.io/python:3.11-alpine as python-base + +ENV POETRY_VERSION=1.3.2 +ENV POETRY_HOME=/opt/poetry +ENV POETRY_VENV=/opt/poetry-venv +ENV POETRY_CACHE_DIR=/opt/.cache + +RUN apk add --no-cache tini libmagic libpq vips vips-dev + +FROM python-base as poetry-base + +RUN python3 -m venv $POETRY_VENV \ + && $POETRY_VENV/bin/pip install -U pip setuptools \ + && $POETRY_VENV/bin/pip install poetry==${POETRY_VERSION} \ + && $POETRY_VENV/bin/pip install poethepoet + +FROM python-base as app + +COPY --from=poetry-base ${POETRY_VENV} ${POETRY_VENV} +ENV PATH="${PATH}:${POETRY_VENV}/bin" + +WORKDIR /app + +COPY poetry.lock pyproject.toml ./ +RUN poetry install --no-interaction --no-cache --without dev + +COPY . /app + +ENTRYPOINT ["/sbin/tini", "--"] +CMD ["sh", "./entry.sh"] diff --git a/README.md b/README.md index e6e83d7..23d37b3 100644 --- a/README.md +++ b/README.md @@ -1 +1,12 @@ # pronouns.cc + +pronouns.cc rewrite in Python, using Quart for routing, SQLAlchemy for the database, and Celery for background tasks. + +## Running + +This isn't anywhere *near* complete yet. For now, you can install [`poe`](https://github.com/nat-n/poethepoet), +run `poe migrate`, and then `poe server`. + +For configuration, a `.env` file is used. See `foxnouns/settings.py`--all keys are required unless specified otherwise. + +(Note that the docker-compose file doesn't work yet) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c12bfb8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,36 @@ +version: "3" + +services: + app: + image: foxnouns + build: . + environment: + - DATABASE_USER=postgres + - DATABASE_PASSWORD=postgres + - DATABASE_HOST=postgres + - DATABASE_NAME=postgres + volumes: + - "./.env:/app/.env" + ports: + - "8000:8000" + networks: + - default + + postgres: + image: docker.io/postgres:15-alpine + volumes: + - "postgres_data:/var/lib/postgresql/data" + command: ["postgres", + "-c", "max-connections=1000", + "-c", "timezone=Etc/UTC", + "-c", "max_wal_size=1GB", + "-c", "min_wal_size=80MB", + "-c", "shared_buffers=128MB"] + environment: + - "POSTGRES_PASSWORD=postgres" + restart: unless-stopped + networks: + - default + +volumes: + postgres_data: diff --git a/entry.sh b/entry.sh new file mode 100644 index 0000000..caede61 --- /dev/null +++ b/entry.sh @@ -0,0 +1,5 @@ +#!/bin/sh +source .env +# poetry run alembic upgrade head +# poetry run uvicorn --workers=${WORKERS:-2} --host=0.0.0.0 --port=8000 'foxnouns.app:app' +poe migrate && poe server