diff --git a/Dockerfile b/Dockerfile index e798ef5..c6da045 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,8 @@ WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt -COPY . . +COPY src/ . + RUN mkdir -p /data VOLUME ["/data"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..343368a --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# queue.hswro.org website - a simple queue managemet system: + +- People receive physical tokens with numbers on them. +- Operator: + - Adds numbers to the list of tokens issued. + - Selects numbers from the list to be called. + - Removes the called number from the list or moves it back to the queue. + +## Common tasks + +### Testing the website locally + +In the repo directory: + +``` +docker build -t queue-app:latest . +docker run -p="5000:5000" --volume="$PWD:/data:" -it queue-app:latest +``` + +Preview should be available on: + `http://localhost:5000` - end user access + `http://localhost:5000/admin` - operator access + diff --git a/docker-compose.yml b/docker-compose.yml index 7136e9a..83686e7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,16 +2,40 @@ version: "3.8" services: queue: - image: "queue-app:latest" # zmień na registry/name:tag jeśli pobierasz z rejestru - ports: 5000 + image: "queue-app:latest" + ports: + - 5000 volumes: - queue_data:/data environment: - DB_PATH=/data/queue.db - - ADMIN_URL=admin-panel - restart: always + - ADMIN_URL=secret-admin-panel + restart: unless-stopped + networks: + - web deploy: + resources: + limits: + cpus: '2.0' + memory: 512M + mode: replicated replicas: 1 + placement: + constraints: [node.role == manager] + labels: + - "traefik.enable=true" + - "traefik.docker.network=web" + - "traefik.http.routers.queue.rule=Host(`domain.tld`)" + - "traefik.http.routers.queue.entrypoints=websecure" + - "traefik.http.services.queue.loadbalancer.server.port=5000" + - "traefik.http.routers.queue.tls=true" + - "traefik.http.routers.queue.tls.certresolver=myresolver" + volumes: queue_data: + +networks: + web: + external: + name: web diff --git a/app.py b/src/app.py similarity index 99% rename from app.py rename to src/app.py index 52ffffb..c6daa40 100644 --- a/app.py +++ b/src/app.py @@ -2,6 +2,7 @@ from flask import Flask, render_template, request, redirect, url_for, g, jsonify import sqlite3 import os + DB = os.environ.get("DB_PATH", "queue.db") ADMIN_SUFFIX = os.environ.get("ADMIN_URL", "admin").strip("/") ADMIN_PATH = f"/{ADMIN_SUFFIX}" if ADMIN_SUFFIX else "/admin" diff --git a/templates/admin.html b/src/templates/admin.html similarity index 100% rename from templates/admin.html rename to src/templates/admin.html diff --git a/templates/index.html b/src/templates/index.html similarity index 90% rename from templates/index.html rename to src/templates/index.html index 510054a..8f33a9d 100644 --- a/templates/index.html +++ b/src/templates/index.html @@ -38,11 +38,11 @@
-