Skip to content

Commit

Permalink
Add docker image and build
Browse files Browse the repository at this point in the history
  • Loading branch information
birchb1024 committed May 4, 2019
1 parent a1a82fb commit e19a7a0
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 1 deletion.
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# Yamp Dockerfile
#
# Usage:
#
# $ docker run --rm -u $(id -u):$(id -g) -v "$PWD":/work docker.io/birchb1024/yamp /work/path/to/your.yaml
#
# using stdin:
#
# $ echo env | docker run -i --rm -u $(id -u):$(id -g) -v "$PWD":/work docker.io/birchb1024/yamp -
#
# Build:
#
# $ git clone https://github.com/birchb1024/yamp.git
# $ cd yamp
# $ docker build -t yamp .
#
# Debug in the container:
#
# $ docker run -it --entrypoint /bin/bash --rm -u $(id -u):$(id -g) -v "$PWD":/work docker.io/birchb1024/yamp
#
FROM python:2.7-slim-stretch

# Install pre-requisites
RUN pip install pyyaml

# Install the application
ADD doc/*.html /yamp/doc/
ADD src/*.py /yamp/src/
ADD examples /yamp/examples/
ADD test /yamp/test/

# Run a few tests
RUN python /yamp/test/test_expand_01.py

# Specify the runtime
ENTRYPOINT ["/usr/local/bin/python", "/yamp/src/yamp.py"]
21 changes: 21 additions & 0 deletions README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ YAML is human friendly data serialization standard. footnote:[YAML stands for YA
- Hello: World
----

=== Quick Start

You just want to run it already? OK, use the docker image. Put your first Yamp file in `hello.yamp`:

.hello.yamp
[source, YAML]
----
"Hello {{argv.2}}"
----

And run it

[source, bash]
----
$ docker run --rm -u $(id -u):$(id -g) -v "$HOME":/work docker.io/birchb1024/yamp /work/hello.yamp $USER
----

== Get Started

Yamp is a Python 2.7 program contained in a single file. Hence one has to install https://www.python.org/:[Python] and the https://pypi.org/project/PyYAML/:[pyyaml] module.
Expand Down Expand Up @@ -151,6 +168,10 @@ Any other file suffix can be used - it is assumed to be YAML. A warning is print

In practice `yaml` will be recognised by most text editors' YAML editting mode. You will need to configure your text editor if you use a non-standard suffix.

==== Docker

$ echo env | docker run -i --rm -u $(id -u):$(id -g) -v "$PWD":/work docker.io/birchb1024/yamp -

=== Processing


Expand Down
19 changes: 19 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
#
# Build Script for Yamp
#
# Requires
#
# python, pyyaml,
# asciidoc, `source-highlight` and the YAML syntax module.
# docker
#
set -u
set -e

python test/test_expand_01.py
asciidoc README.asciidoc && mv README.html doc
docker build -t docker.io/birchb1024/yamp .

echo "Now 'docker push docker.io/birchb1024/yamp'"

24 changes: 23 additions & 1 deletion doc/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,24 @@ <h2 id="_tl_dr">TL;DR</h2>
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #990000">- </span><span style="color: #009900">Hello</span><span style="color: #990000">:</span> World</tt></pre></div></div>
<div class="sect2">
<h3 id="_quick_start">Quick Start</h3>
<div class="paragraph"><p>You just want to run it already? OK, use the docker image. Put your first Yamp file in <code>hello.yamp</code>:</p></div>
<div class="listingblock">
<div class="title">hello.yamp</div>
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #FF0000">"Hello {{argv.2}}"</span></tt></pre></div></div>
<div class="paragraph"><p>And run it</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt>$ docker run --rm -u <span style="color: #009900">$(</span>id -u<span style="color: #990000">):</span><span style="color: #009900">$(</span>id -g<span style="color: #990000">)</span> -v <span style="color: #FF0000">"$HOME"</span><span style="color: #990000">:</span>/work docker<span style="color: #990000">.</span>io/birchb<span style="color: #993399">1024</span>/yamp /work/hello<span style="color: #990000">.</span>yamp <span style="color: #009900">$USER</span></tt></pre></div></div>
</div>
</div>
</div>
<div class="sect1">
Expand Down Expand Up @@ -943,6 +961,10 @@ <h4 id="_file_suffixes">File Suffixes</h4>
<div class="paragraph"><p>Any other file suffix can be used - it is assumed to be YAML. A warning is printed to alert you of a possible input mistake.</p></div>
<div class="paragraph"><p>In practice &#8216;yaml` will be recognised by most text editors&#8217; YAML editting mode. You will need to configure your text editor if you use a non-standard suffix.</p></div>
</div>
<div class="sect3">
<h4 id="_docker">Docker</h4>
<div class="paragraph"><p>$ echo env | docker run -i --rm -u $(id -u):$(id -g) -v "$PWD":/work docker.io/birchb1024/yamp -</p></div>
</div>
</div>
<div class="sect2">
<h3 id="_processing">Processing</h3>
Expand Down Expand Up @@ -1768,7 +1790,7 @@ <h3 id="_updating_this_document">Updating This Document</h3>
<div id="footer-text">
Version 0.2<br />
Last updated
2019-05-04 16:29:58 AEST
2019-05-04 17:43:08 AEST
</div>
</div>
</body>
Expand Down

0 comments on commit e19a7a0

Please sign in to comment.