Commit 5c56d434 authored by chimekkoo's avatar chimekkoo
Browse files

Add production-ready OCI container and example compose.yaml, add postgres to...

Add production-ready OCI container and example compose.yaml, add postgres to prerequisites in readme
parent 94fde5cd
Loading
Loading
Loading
Loading

.containerignore

0 → 100644
+6 −0
Changes for .containerignore: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
.venv
**/__pycache__
db.sqlite3
.vscode
.env
deployment/
+1 −0
Changes for .gitignore: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,3 +3,4 @@
db.sqlite3
.vscode
.env
deployment

Containerfile

0 → 100644
+11 −0
Changes for Containerfile: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
FROM docker.io/library/alpine:3.23

RUN apk add --no-cache uv

COPY . /app
WORKDIR /app

RUN uv --no-cache venv --python 3.12
RUN uv --no-cache sync --no-dev --frozen

ENTRYPOINT ["uv", "--no-cache", "run", "./entrypoint.sh"]
+8 −0
Changes for README.md: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

## Prerequisites
- [Redis](https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/) instance running
- for production, a PostgreSQL server is strongly advised (any relatively recent version should work, we tested v17)

## Run for development
- clone the repo
@@ -11,3 +12,10 @@
- run migrations: `uv run manage.py migrate`
- create superuser: `uv run manage.py createsuperuser`
- run development server and worker `uv run honcho start`

## Deploy for production

### OCI + Compose (Podman/Docker)
- build the image (e.g. `buildah build -t wybory:latest .`)
- review and edit `compose.yaml` to your needs, you can mount a custom gunicorn config
- run the stack (e.g. `podman compose up -d`)

compose.yaml

0 → 100644
+49 −0
Changes for compose.yaml: 49 added lines, 0 removed lines.
Original line number Diff line number Diff line
services:

  app:
    image: wybory
    command: web
    ports:
    - "8000:8000"
    environment: &env
      EMAIL_URL: "smtp+tls://wybory:changeme@smtp.example.com:587"
      DEFAULT_FROM_EMAIL: "Wybory <wybory@example.com>"
      VOTERS_EMAIL_DOMAIN: "example.com"
      SITE_URL: "http://localhost:8000"
      RQ_URL: "redis://valkey:6379/0"
      TIME_ZONE: "Europe/Warsaw"
      DATABASE_URL: "postgres://wybory:wybory@db:5432/wybory"
      DJANGO_SUPERUSER_USERNAME: "admin"
      DJANGO_SUPERUSER_EMAIL: "admin@localhost"
      DJANGO_SUPERUSER_PASSWORD: "admin"
    # volumes:
    # - ./deployment/gunicorn.conf.py:/app/gunicorn.conf.py:ro
    depends_on: &dep
      db:
        condition: service_started
      queue:
        condition: service_started

  worker:
    image: wybory
    command: worker
    environment: *env
    depends_on: *dep

  db:
    image: docker.io/library/postgres:17-alpine
    # ports:
    # - "5432:5432"
    environment:
      POSTGRES_USER: wybory
      POSTGRES_PASSWORD: wybory
      POSTGRES_DATABASE: wybory
    volumes:
    - "./deployment/db:/var/lib/postgresql/data"

  valkey:
    image: docker.io/valkey/valkey:8.1-alpine
    # ports:
    # - "6379:6379"
    volumes:
    - "./deployment/valkey:/data"
Loading