Add Dockerfile

Tue, 10 Jul 2018 11:09:56 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Tue, 10 Jul 2018 11:09:56 +0100
changeset 94
1b3e848b4394
parent 93
3f9bda0887d5
child 95
a1e7ad9336db

Add Dockerfile

Dockerfile file | annotate | diff | comparison | revisions
misc/docker-entrypoint.sh file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Dockerfile	Tue Jul 10 11:09:56 2018 +0100
@@ -0,0 +1,42 @@
+FROM ubuntu:xenial
+
+MAINTAINER Matthew Wild <mwild1@gmail.com>
+
+RUN apt-get update \
+    && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
+        lua5.2 \
+        lua-cjson \
+        lua-expat \
+        lua-sec \
+        lua-socket \
+        make \
+    && rm -rf /var/lib/apt/lists/*
+
+RUN ln -s /usr/bin/lua5.2 /usr/local/bin/lua
+
+RUN mkdir -p /tmp/build
+
+ADD . /tmp/build
+
+WORKDIR /tmp/build
+
+RUN ./configure && make && install build/scansion /usr/local/bin/scansion && rm -rf /tmp/build
+
+ADD verse.lua /usr/local/share/lua/5.2/verse.lua
+
+ADD misc/docker-entrypoint.sh /entrypoint.sh
+
+RUN chmod a=rx /entrypoint.sh
+
+ENTRYPOINT ["/entrypoint.sh"]
+
+USER nobody
+
+ADD scripts /scripts
+
+VOLUME ["/scripts"]
+
+WORKDIR /scripts
+
+CMD ["basic.scs"]
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/misc/docker-entrypoint.sh	Tue Jul 10 11:09:56 2018 +0100
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+ARGS=""
+
+if [[ "$SERVER_HOST" ]]; then
+	ARGS="$ARGS -h $SERVER_HOST";
+else
+	# In the interests of sane convenient defaults, discover the host
+	# IP address (only possible in bridged networks), and default to that
+	GATEWAY_IP=$(printf "%d.%d.%d.%d" $(awk '$2 == 00000000 { for (i = 8; i >= 2; i=i-2) { print "0x" substr($3, i-1, 2) } }' /proc/net/route))
+
+	if [[ "$GATEWAY_IP" != "0.0.0.0" ]]; then
+		ARGS="$ARGS -h $GATEWAY_IP"
+	fi
+fi
+if [[ "$SERVER_PORT" ]]; then
+	ARGS="$ARGS -p $SERVER_PORT";
+fi
+
+exec /usr/local/bin/scansion $ARGS "$@"

mercurial