diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000000..ad1e331bd50e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3.8' + +services: + datafusion-docs: + build: + context: . + dockerfile: ./docs/Dockerfile + container_name: datafusion-docs + volumes: + - .:/datafusion + - rust-cache:/usr/local/cargo + - rust-target:/datafusion/target + working_dir: /datafusion + +volumes: + rust-cache: + rust-target: diff --git a/docs/Dockerfile b/docs/Dockerfile new file mode 100644 index 000000000000..3d218fced1ea --- /dev/null +++ b/docs/Dockerfile @@ -0,0 +1,39 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +FROM rust:bookworm + +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3 \ + python3-pip \ + graphviz \ + make \ + dos2unix \ + && rm -rf /var/lib/apt/lists/* + +# Install Rust tools with persistent caching +# These are cached in docker volumes when using docker-compose +RUN --mount=type=cache,target=/usr/local/cargo/registry \ + --mount=type=cache,target=/usr/local/cargo/git \ + cargo install cargo-depgraph --version ^1.6 --locked + +WORKDIR /datafusion + +COPY docs/requirements.txt /datafusion/docs/ +RUN python3 -m pip install --break-system-packages -r /datafusion/docs/requirements.txt + +CMD ["sh", "-c", "cd /datafusion/docs && dos2unix build.sh scripts/*.sh 2>/dev/null || true; bash build.sh"] diff --git a/docs/README.md b/docs/README.md index 0340a3b8bf63..9bf8d2550663 100644 --- a/docs/README.md +++ b/docs/README.md @@ -25,11 +25,49 @@ https://datafusion.apache.org/ as part of the release process. ## Dependencies +### Option 1: Docker with Docker Compose (Recommended for iterative builds) + +If you have Docker and Docker Compose installed, you can build the docs without installing any dependencies on your system. This method uses persistent volumes to cache Rust dependencies, making subsequent builds much faster: + +```sh +# Run the docs build with Docker Compose (from repository root) +docker-compose run --rm datafusion-docs +``` + +The built documentation will be available in `docs/build/html/`. + +**Benefits of this approach:** +- Rust toolchain and dependencies are cached between builds (no re-downloading on each run) +- Cross-platform compatibility (works on Windows, macOS, Linux) +- Simple one-command build process + +### Option 1b: Docker without Compose (Quick single build) + +If you prefer a quick build without Docker Compose: + +```sh +# Build the Docker image (from repository root) +docker build -t datafusion-docs ./docs + +# Run the docs build (POSIX shells: bash, zsh, etc.) +docker run --rm -v $(pwd):/datafusion datafusion-docs + +# On Windows PowerShell, use: +# docker run --rm -v ${PWD}:/datafusion datafusion-docs +``` + +**Note:** This method re-downloads Rust dependencies on each run. For iterative development, use Option 1 (Docker Compose) instead. + +The built documentation will be available in `docs/build/html/`. + +### Option 2: Local Installation + It's recommended to install build dependencies and build the documentation inside a Python virtualenv. ```sh python3 -m venv venv +source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt ```