diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..ebaef00c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM python:3.11-slim + +WORKDIR /docs + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + git \ + libcairo2-dev \ + libgdk-pixbuf2.0-dev \ + libpango1.0-dev \ + && rm -rf /var/lib/apt/lists/* + +# Copy requirements and install dependencies +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the docs content +COPY . . + +# Expose the port MkDocs runs on +EXPOSE 8000 + +# Command to run MkDocs +CMD ["mkdocs", "serve", "--no-directory-urls", "--dev-addr=0.0.0.0:8000"] \ No newline at end of file diff --git a/RUNNING-DOCS-LOCALLY.md b/RUNNING-DOCS-LOCALLY.md index 01d68825..6551aecc 100644 --- a/RUNNING-DOCS-LOCALLY.md +++ b/RUNNING-DOCS-LOCALLY.md @@ -1,43 +1,119 @@ -# Running docs locally +# Running Docs with Docker -The following is only required if you are part of the Quix technical writing team, or you contribute frequently, and want to check your docs PR locally before pushing up to the docs repo. Otherwise, the simplest approach is to refer to the [docs preview site](./README.md#docs-preview-site) that is created automatically for you, when you push up a PR on the `dev` branch. +This guide explains how to run the Quix documentation locally using Docker Compose. This is an alternative to the native installation method described in [RUNNING-DOCS-LOCALLY.md](./RUNNING-DOCS-LOCALLY.md). ## Prerequisites -To run these docs locally you'll need: +- [Docker](https://docs.docker.com/get-docker/) installed on your system +- [Docker Compose](https://docs.docker.com/compose/install/) installed on your system +- Git client (for cloning the repository) -* [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) -* Sign up to the [Insiders Programme](https://squidfunk.github.io/mkdocs-material/insiders/), if you want to see all features rendered locally. -* A Git client (the command line is fine). +## Quick Start -## Plugins used +1. Clone the repository: + ```bash + git clone https://github.com/quixio/quix-docs.git + cd quix-docs + ``` + +2. Make the browser script executable: + ```bash + chmod +x open-browser.sh + ``` + +3. Start the documentation server: + ```bash + docker compose up --build & ./open-browser.sh + ``` + + Or to run in detached mode: + ```bash + docker compose up -d --build && ./open-browser.sh + ``` + +4. The documentation will automatically open in your default browser at `http://localhost:8000/docs/` -If you want to fully render all documentation locally you need to install the following plugins with `pip install`: +## Service Management -* [mkdocs-glightbox](https://pypi.org/project/mkdocs-glightbox/0.1.0/) -* [mkdocs-multirepo-plugin](https://github.com/jdoiro3/mkdocs-multirepo-plugin) -* [mkdocs-redirects](https://pypi.org/project/mkdocs-redirects/) +- Start in detached mode (runs in background): + ```bash + docker compose up -d --build && ./open-browser.sh + ``` -You also need to sign up to the [Insiders Programme](https://squidfunk.github.io/mkdocs-material/insiders/). +- Stop the service: + ```bash + docker compose down + ``` -The [social plugin](https://squidfunk.github.io/mkdocs-material/setup/setting-up-social-cards/) is also used to automatically provide metadata. See the [social plugin documentation](https://squidfunk.github.io/mkdocs-material/setup/setting-up-social-cards/) for details on how to install the dependencies of the plugin. You might also need to first install `cffi` with `pip install cffi`, if not present on your system. +- View logs: + ```bash + docker compose logs -f + ``` -## Linked repositories +- Rebuild the service: + ```bash + docker compose build + ``` -This repo uses the `multirepo` plugin to pull in client library content from the [Quix Streams repo](https://github.com/quixio/quix-streams). +- Force rebuild and start: + ```bash + docker compose up --build + ``` -You can read more about Quix Streams [here](https://github.com/quixio/quix-streams/blob/main/README.md). +## Features -## Viewing the docs +- Live reload: Changes to documentation are reflected in real-time +- Automatic restart: Service restarts automatically on failure +- Volume mounting: Local directory is mounted for immediate updates +- Log streaming: View logs in real-time with `docker compose logs -f` +- Automatic browser opening: Documentation opens in your default browser -To view the docs locally: +## Troubleshooting -1. Follow the install guide for Material [here](https://squidfunk.github.io/mkdocs-material/getting-started/). -2. Clone the repo as follows: +If you encounter issues: +1. Port conflicts: + ```bash + # Check if port 8000 is in use + lsof -i :8000 + # Or on Windows: + netstat -ano | findstr :8000 ``` - git clone https://github.com/quixio/quix-docs.git + +2. Docker resource issues: + ```bash + # Check Docker system resources + docker system df + docker system prune # Clean up unused resources ``` -3. Change into the docs directory you cloned (there will be a `mkdocs.yml` file there). -4. Run `mkdocs serve --no-directory-urls`. -5. Navigate your browser to `localhost:8000` to view the docs. + +3. Build issues: + ```bash + # Clean build with no cache + docker compose build --no-cache + # Remove all containers and images + docker compose down --rmi all + ``` + +4. Permission issues: + ```bash + # Ensure Docker has proper permissions + sudo usermod -aG docker $USER + # Log out and back in for changes to take effect + ``` + +5. Network issues: + ```bash + # Check Docker network + docker network ls + # Inspect network configuration + docker network inspect quix-docs_default + ``` + +6. Service health: + ```bash + # Check service status + docker compose ps + # View service logs + docker compose logs + ``` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..54810424 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3.8' + +services: + docs: + build: + context: . + dockerfile: Dockerfile + ports: + - "8000:8000" + volumes: + - .:/docs + environment: + - PYTHONUNBUFFERED=1 + restart: unless-stopped \ No newline at end of file diff --git a/docs/get-started/quix-start.md b/docs/get-started/quix-start.md deleted file mode 100644 index fcf08ea0..00000000 --- a/docs/get-started/quix-start.md +++ /dev/null @@ -1,93 +0,0 @@ -# Install Quix Streams using pip - -You'll now install the Quix Streams client library using `pip`. - -You'll need to make sure your system has Python 3.8+ available: - -``` -python3 --version -``` - -## Step 1: Install Quix Streams - -To install Quix Streams with `pip`: - -``` -python3 -m pip install quixstreams -``` - -!!! tip - - If you already have Quix Streams installed, make sure you are using the latest version with `python -m pip install quixstreams -U` or `python3 -m pip install quixstreams -U`, depending on how your system is set up. - -## Step 2: Create a simple app - -You'll now create a simple app to test your installation. You'll connect to a Quix public Kafka broker and consume and print messages. - -Create a new file containing the following code: - -``` python -from quixstreams import Application -import uuid - -# Connect to the public Quix hosted broker to consume data -app = Application( - broker_address="publickafka.quix.io:9092", # Kafka broker address - consumer_group=str(uuid.uuid4()), # Kafka consumer group - producer_extra_config={'enable.idempotence': False} -) - -input_topic = app.topic("demo-onboarding-prod-chat", value_deserializer='json') - -sdf = app.dataframe(input_topic) - -sdf["tokens_count"] = sdf["message"].apply(lambda message: len(message.split(" "))) -sdf = sdf[["role", "tokens_count"]] - -sdf = sdf.update(lambda row: print(row)) - -app.run() -``` - -Save the code in a file named `qs.py`. - -## Step 3: Run the code - -Now run the code: - -``` -python3 qs.py -``` - -You are now consuming data from the `demo-onboarding-prod-chat` topic and processing it in real time. - -You have installed Quix and tested that it's working. - -## Next steps - -