This is an automated email from the ASF dual-hosted git repository.

tombentley pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/kafka-site.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new cb762fb7 KAFKA-13882 Use docker to preview docs locally (#410)
cb762fb7 is described below

commit cb762fb78b399b0fa3725fbc7d894df7c1772ba0
Author: Qing <[email protected]>
AuthorDate: Wed Sep 27 21:02:21 2023 +0100

    KAFKA-13882 Use docker to preview docs locally (#410)
    
    Adds a Dockerfile and ./start-preview.sh to encapsulate the httpd setup 
needed to serve the website locally.
    
    Reviewers: Mickael Maison <[email protected]>, Federico Valeri 
<[email protected]>, Tom Bentley <[email protected]>
---
 Dockerfile       | 22 ++++++++++++++++++++++
 README.md        | 13 +++++++++++++
 start-preview.sh |  7 +++++++
 3 files changed, 42 insertions(+)

diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..37e2f470
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,22 @@
+FROM httpd:2.4
+
+# This follows the steps documented here: 
https://cwiki.apache.org/confluence/display/KAFKA/Setup+Kafka+Website+on+Local+Apache+Server
+RUN sed -i \
+  -e 's/#LoadModule include_module modules\/mod_include.so/LoadModule 
include_module modules\/mod_include.so/g' \
+  -e 's/#LoadModule rewrite_module modules\/mod_rewrite.so/LoadModule 
rewrite_module modules\/mod_rewrite.so/g' \
+  -e 's/Options Indexes FollowSymLinks/Options +Includes/g' \
+  -e '/<Directory "\/usr\/local\/apache2\/htdocs">/a\    RewriteEngine On\
+      AddType text/html .html\n\
+      AddHandler server-parsed .html\n\
+      Redirect 301 /design.html /documentation#design\n\
+      RewriteRule ^/?(\d+)/generated/ - [S=4]\n\
+      RewriteRule ^/?(\d+)/documentation(\.html)? - [S=3]\n\
+      RewriteRule ^/?(\d+)/javadoc - [S=2]\n\
+      RewriteRule ^/?(\d+)/images/ - [S=1]\n\
+      RewriteCond $2 !=protocol\n\
+      RewriteRule ^/?(\d+)/([a-z]+)(\.html)? /$1/documentation#$2 
[R=302,L,NE]\n\
+      RewriteCond %{REQUEST_FILENAME}.html -f\n\
+      RewriteRule ^(.*)$ %{REQUEST_FILENAME}.html' \
+  "/usr/local/apache2/conf/httpd.conf"
+
+CMD ["httpd-foreground"]
diff --git a/README.md b/README.md
new file mode 100644
index 00000000..91f69ed0
--- /dev/null
+++ b/README.md
@@ -0,0 +1,13 @@
+# How to preview documentation changes locally?
+
+The documentation can be hosted on a local webserver via httpd.
+
+You can run it with the following command, note that it requires docker:
+
+```shell
+./start-preview.sh
+```
+
+Then you can open [localhost:8080](http://localhost:8080) on your browser and 
browse the documentation.
+
+To kill the process, just type ctrl + c
\ No newline at end of file
diff --git a/start-preview.sh b/start-preview.sh
new file mode 100755
index 00000000..5d57854d
--- /dev/null
+++ b/start-preview.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+set -euxo pipefail
+
+docker build -t kafka-site-preview .
+
+docker run -it --rm --name mypreview -p 8080:80 -v 
"$PWD":/usr/local/apache2/htdocs/:z kafka-site-preview

Reply via email to