This is an automated email from the ASF dual-hosted git repository.
soenkeliebau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-training.git
The following commit(s) were added to refs/heads/master by this push:
new 28deebd TRAINING-24: Add a Dockerfile with diagram tools. (#57)
28deebd is described below
commit 28deebd1c56137b52ef59d86fc9659cc61b3bc8a
Author: RyanSkraba <[email protected]>
AuthorDate: Wed Oct 23 23:08:05 2019 +0200
TRAINING-24: Add a Dockerfile with diagram tools. (#57)
Add a Dockerfile with instructions that can be used to build the
maven-revealjs-asciidocker-template presentation, containing all of the tools
used to generate diagrams.
https://issues.apache.org/jira/browse/TRAINING-24
Removed the iris.json data (MIT-licensed) and created a new Vega example
based on the C3 graph in the presentation.
---
tools/Dockerfile | 143 +++++++++++++++++++
.../src/main/asciidoc/index.adoc | 152 +++++----------------
2 files changed, 179 insertions(+), 116 deletions(-)
diff --git a/tools/Dockerfile b/tools/Dockerfile
new file mode 100644
index 0000000..06e7365
--- /dev/null
+++ b/tools/Dockerfile
@@ -0,0 +1,143 @@
+# 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
+#
+# https://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.
+
+#############################################################################
+# Dockerfile with many of the tools necessary for diagram generation
+#
+# A comprehensive list of asciidoctor diagramming tools and their
+# requirements can be found at:
+# - https://github.com/asciidoctor/asciidoctor-diagram
+#
+# You can find examples in the tools/maven-revealjs-asciidocter-template/
+# presentation. A typical presentation will not use ALL of these tools.
+#
+# To build this image:
+#
+# docker image build --build-arg USER_ID=$(id -u ${USER}) --build-arg
GROUP_ID=$(id -g ${USER}) -t training-build .
+#
+# (Passing the `USER_ID` and `GROUP_ID` is useful to build presentations with
+# the same user and permissions inside the docker container.)
+#
+# To build a presentation using this image:
+#
+# cd incubator-training/tools/maven-revealjs-asciidoctor-template/
+# docker run -it --rm --volume $PWD:/opt/workdir training-build:latest -c "mvn
clean package"
+#
+# Alternatively, you can include a reference to your local .m2 to speed up the
build:
+#
+# docker run -it --rm --volume $HOME/.m2:/home/docker-user/.m2 --volume
$PWD:/opt/workdir training-build:latest
+#
+# To run the presentation using jetty:
+#
+# docker run -it --rm --publish 58080:8080/tcp --volume
$HOME/.m2:/home/docker-user/.m2 --volume $PWD:/opt/workdir
training-build:latest -c "mvn jetty:run-exploded"
+#
+# Alternatively, you can serve the pages in the target/generated-slides/
+# directory using any web server:
+#
+# docker run -d --name my-tmp-httpd -p 58080:80 -v
$PWD/target/generated-slides/:/usr/local/apache2/htdocs/:ro httpd:2.4
+#
+
+# Start bt building some tools using a multistage docker.
+# ===========================================================================
+
+FROM haskell:8 as tool-haskell-builder
+RUN cabal update && cabal install --allow-newer erd
+
+FROM rust:1.38.0 as tool-rust-builder
+RUN cargo install svgbob_cli
+
+# Build a docker image containing every tool necessary to build the template
+# ===========================================================================
+
+FROM centos:8
+
+# System tools --------------------------------------------------------------
+
+RUN dnf install -y git wget bzip2
+
+# Maven build tool ----------------------------------------------------------
+
+# asciidocter, revealjs, c3 and d3 javascript libraries are installed
+# during the maven build.
+
+# automatically included: meme generator, plantuml
+
+RUN dnf install -y maven
+
+# http://www.graphviz.org/ graph visualisation tools ------------------------
+
+RUN dnf install -y graphviz
+
+# http://blockdiag.com/en/ family of diagramming tools ----------------------
+# Requires: python
+
+RUN dnf install -y python36
+RUN python3 -m pip install --upgrade pip setuptools seqdiag blockdiag \
+ actdiag nwdiag
+
+# Meme generator ------------------------------------------------------------
+# Requires: ImageMagick (for convert and
+RUN dnf install -y epel-release
+RUN dnf install -y ImageMagick
+
+# https://github.com/BurntSushi/erd entity-relationship diagrams ------------
+# Requires: graphviz
+
+COPY --from=tool-haskell-builder /root/.cabal/bin/erd /usr/local/bin/erd
+
+# https://kevinpt.github.io/syntrax/ railroad diagrams ----------------------
+
+RUN dnf install -y gcc cairo-devel redhat-rpm-config python3-devel pango-devel
python3-gobject gtk3
+RUN python3 -m pip install --upgrade syntrax
+
+# https://github.com/ivanceras/svgbob ascii diagrams to SVG -----------------
+
+COPY --from=tool-rust-builder /usr/local/cargo/bin/svgbob /usr/local/bin/svgbob
+
+# https://vega.github.io/vega/ Vega visualisation tools ---------------------
+
+RUN dnf install -y nodejs
+RUN dnf install -y python2
+RUN PYTHON=/usr/bin/python2 npm install --unsafe-perm --global vega-cli pango
+
+# https://mermaidjs.github.io/#/ Mermaid markdownish charts -----------------
+# Requires: npm
+
+# This provides the mmdc command, but it looks like asciidoctor still
+# requires the mermaid command. Version issue?
+
+RUN npm install --unsafe-perm --global mermaid.cli
+
+## Run as current user, inspired by:
+##
https://jtreminio.com/blog/running-docker-containers-as-current-host-user/#ok-so-what-actually-works
+ARG USER_ID
+ARG GROUP_ID
+
+RUN if [ ${USER_ID:-0} -ne 0 ] && [ ${GROUP_ID:-0} -ne 0 ]; then \
+ if getent passwd docker-user ; then userdel -f docker-user; fi && \
+ if getent group docker-user ; then groupdel docker-user; fi &&\
+ groupadd -g ${GROUP_ID} docker-user &&\
+ useradd -l -u ${USER_ID} -g docker-user docker-user &&\
+ install -d -m 0755 -o docker-user -g docker-user /home/docker-user\
+ && chown --changes --silent --no-dereference --recursive \
+ ${USER_ID}:${GROUP_ID} \
+ /usr/local/ \
+;fi
+
+USER docker-user
+WORKDIR /opt/workdir
+
+ENTRYPOINT [ "bash" ]
diff --git
a/tools/maven-revealjs-asciidoctor-template/src/main/asciidoc/index.adoc
b/tools/maven-revealjs-asciidoctor-template/src/main/asciidoc/index.adoc
index 4e9d6a5..07c7456 100644
--- a/tools/maven-revealjs-asciidoctor-template/src/main/asciidoc/index.adoc
+++ b/tools/maven-revealjs-asciidoctor-template/src/main/asciidoc/index.adoc
@@ -211,7 +211,7 @@ digraph g {
}
----
-=== Seqdag Diagram
+=== Seqdiag Diagram
[seqdiag,s7-communication,svg]
....
@@ -528,145 +528,65 @@
validity</panel_attributes><additional_attributes>transparentSelection=false</ad
=== Vega
-[vega,vega-test, svg]
+[vega,vega-test,svg]
....
{
- "$schema": "https://vega.github.io/schema/vega/v4.json",
- "width": 500,
+ "$schema": "https://vega.github.io/schema/vega/v5.json",
+ "width": 1000,
+ "height": 500,
"padding": 5,
- "config": {
- "axisBand": {
- "bandPosition": 1,
- "tickExtra": true,
- "tickOffset": 0
- }
- },
-
- "signals": [
- { "name": "fields",
- "value": ["petalWidth", "petalLength", "sepalWidth", "sepalLength"] },
- { "name": "plotWidth", "value": 60 },
- { "name": "height", "update": "(plotWidth + 10) * length(fields)"}
- ],
-
"data": [
{
- "name": "iris",
- "url": "data/iris.json",
- "transform": [
- {
- "type": "fold",
- "fields": {"signal": "fields"},
- "as": ["organ", "value"]
- }
+ "name": "iot-riskks1",
+ "values": [
+ {"cheese": "Security", "amount": 43},
+ {"cheese": "IT/OT Integration", "amount": 30},
+ {"cheese": "Unclear ROI", "amount": 28},
+ {"cheese": "Technical Expertise", "amount": 26},
+ {"cheese": "Interoperability", "amount": 26},
+ {"cheese": "Data Portability", "amount": 24},
+ {"cheese": "Vendor Risk", "amount": 22},
+ {"cheese": "Transition Risk", "amount": 22},
+ {"cheese": "Legal/regulatory issues", "amount": 22},
+ {"cheese": "Network constraints", "amount": 21},
+ {"cheese": "Vendor lock-in", "amount": 18}
]
}
],
"scales": [
{
- "name": "layout",
+ "name": "xscale",
"type": "band",
- "range": "height",
- "domain": {"data": "iris", "field": "organ"}
+ "domain": {"data": "iot-riskks1", "field": "cheese"},
+ "range": "width",
+ "padding": 0.05,
+ "round": true
},
{
- "name": "xscale",
- "type": "linear",
- "range": "width", "round": true,
- "domain": {"data": "iris", "field": "value"},
- "zero": true, "nice": true
+ "name": "yscale",
+ "domain": {"data": "iot-riskks1", "field": "amount"},
+ "nice": true,
+ "range": "height"
}
],
- "axes": [
- {"orient": "bottom", "scale": "xscale", "zindex": 1},
- {"orient": "left", "scale": "layout", "tickCount": 5, "zindex": 1}
- ],
-
"marks": [
{
- "type": "group",
- "from": {
- "facet": {
- "data": "iris",
- "name": "organs",
- "groupby": "organ"
- }
- },
-
+ "type": "rect",
+ "from": {"data":"iot-riskks1"},
"encode": {
"enter": {
- "yc": {"scale": "layout", "field": "organ", "band": 0.5},
- "height": {"signal": "plotWidth"},
- "width": {"signal": "width"}
- }
- },
-
- "data": [
- {
- "name": "summary",
- "source": "organs",
- "transform": [
- {
- "type": "aggregate",
- "fields": ["value", "value", "value", "value", "value"],
- "ops": ["min", "q1", "median", "q3", "max"],
- "as": ["min", "q1", "median", "q3", "max"]
- }
- ]
- }
- ],
-
- "marks": [
- {
- "type": "rect",
- "from": {"data": "summary"},
- "encode": {
- "enter": {
- "fill": {"value": "black"},
- "height": {"value": 1}
- },
- "update": {
- "yc": {"signal": "plotWidth / 2", "offset": -0.5},
- "x": {"scale": "xscale", "field": "min"},
- "x2": {"scale": "xscale", "field": "max"}
- }
- }
- },
- {
- "type": "rect",
- "from": {"data": "summary"},
- "encode": {
- "enter": {
- "fill": {"value": "steelblue"},
- "cornerRadius": {"value": 4}
- },
- "update": {
- "yc": {"signal": "plotWidth / 2"},
- "height": {"signal": "plotWidth / 2"},
- "x": {"scale": "xscale", "field": "q1"},
- "x2": {"scale": "xscale", "field": "q3"}
- }
- }
+ "x": {"scale": "xscale", "field": "cheese"},
+ "width": {"scale": "xscale", "band": 1},
+ "y": {"scale": "yscale", "field": "amount"},
+ "y2": {"scale": "yscale", "value": 0}
},
- {
- "type": "rect",
- "from": {"data": "summary"},
- "encode": {
- "enter": {
- "fill": {"value": "aliceblue"},
- "width": {"value": 2}
- },
- "update": {
- "yc": {"signal": "plotWidth / 2"},
- "height": {"signal": "plotWidth / 2"},
- "x": {"scale": "xscale", "field": "median"}
- }
- }
+ "update": {
+ "fill": {"value": "steelblue"}
}
- ]
+ }
}
]
}