diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..76bb50f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3-alpine + +WORKDIR /catask +COPY . . +RUN pip install --no-cache-dir -r requirements.txt + +ENTRYPOINT [ "gunicorn", "-w", "4", "app:app", "--bind", "0.0.0.0:8000" ] \ No newline at end of file diff --git a/README.md b/README.md index d79faf1..3f9e4e1 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ a simple & easy to use Q&A software that makes answering questions easier ## Install Clone this repository: `git clone https://git.gay/mst/catask.git` - +### Docker +See [docker.md](https://git.gay/mst/catask/src/branch/main/docker.md) ### VPS-specific Go into the cloned repository, create a virtual environment and activate it: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ed98985 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,45 @@ +name: catask + +services: + postgres: + environment: + POSTGRES_DB: catask + POSTGRES_USER: catask + POSTGRES_PASSWORD: catask + healthcheck: + test: ["CMD", "pg_isready", "-U", "catask"] + interval: 1s + timeout: 5s + retries: 10 + image: postgres:alpine + networks: + - catask + restart: always + volumes: + - ./schema.sql:/docker-entrypoint-initdb.d/catask.sql + - db-data:/var/lib/postgresql/data + + catask: + build: + dockerfile: Dockerfile + depends_on: + postgres: + condition: service_healthy + networks: + - catask + ports: + - "8000:8000" + restart: always + volumes: + - catask-data:/catask/static/emojis + - catask-data:/catask/static/icons/favicon + - ./config.json:/catask/config.json + - ./.env:/catask/.env + +networks: + catask: + driver: bridge + +volumes: + db-data: + catask-data: diff --git a/docker.md b/docker.md new file mode 100644 index 0000000..452cdec --- /dev/null +++ b/docker.md @@ -0,0 +1,33 @@ +# CatAsk on Docker (or Podman) + +## Prerequisites +- Docker + `docker-compose` (or Podman + `podman-compose`) + +## Steps +Before starting CatAsk, you must copy the configuration files to their proper places first: + +```sh +cp config.example.json config.json +cp .env.example .env +``` + +Then, paste this into the `.env` file, and replace sections that are marked with `[CHANGE THIS]`. + +```env +DB_HOST = postgres +DB_NAME = catask +DB_USER = catask +DB_PASS = catask +DB_PORT = 5432 +ADMIN_PASSWORD = [CHANGE THIS] +APP_SECRET = [CHANGE THIS] +``` + +You may now start CatAsk: + +```sh +docker compose up +``` + +If you have done everything correctly, going to `http://localhost:8000` in your browser should show a question box screen. You may now log in with your admin password, and configure the instance. + \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index ad13b40..55fbc88 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ flask python-dotenv -psycopg +psycopg[binary,pool] humanize mistune bleach