Dockerize

This commit is contained in:
Neale Pickett 2017-09-11 03:08:18 +00:00
parent ed3022780a
commit af963a71e8
3 changed files with 46 additions and 1 deletions

20
Dockerfile Normal file
View File

@ -0,0 +1,20 @@
FROM neale/eris
RUN apk --no-cache add lua5.2
RUN apk --no-cache add lua5.3
# Install MOTH. This could be less obtuse.
COPY www /moth/www
COPY bin /moth/bin
RUN mkdir -p /moth/state/teams /moth/state/points.new /moth/state/points.tmp
RUN chown www:www /moth/state/teams /moth/state/points.new /moth/state/points.tmp
RUN mkdir -p /moth/packages
RUN touch /moth/state/points.log
RUN ln -s ../state/puzzles.json /moth/www/puzzles.json
RUN ln -s ../state/points.json /moth/www/points.json
COPY src/moth-init /usr/sbin/moth-init
WORKDIR /
CMD ["/usr/sbin/moth-init"]

View File

@ -7,20 +7,36 @@ else
fi
basedir=$(pwd)
[ -n "$DEBUG" ] && printf "Updating moth instance in %s\n" $(pwd)
log () {
echo "moth: $@" 1>&2
}
# Do nothing if `disabled` is present
if [ -f disabled ]; then
log "Instance disabled: doing nothing"
exit
fi
# Reset to initial state if `reset` is present
if [ -f reset ]; then
log "Resetting state"
rm -f state/teams/* state/points.new/* state/points.tmp/*
: > state/points.log
rm -f reset
fi
# Create some team names if needed
if [ ! -f state/assigned.txt ]; then
log "Generating team names"
hd </dev/urandom | awk '{print $3 $4 $5 $6;}' | head -n 100 > state/assigned.txt
fi
# Helpful error message
if [ $(ls packages | wc -l) -eq 0 ]; then
log "error: No packages installed"
exit
fi
# Create a list of currently-active categories
: > state/categories.txt.new
for dn in packages/*; do

9
src/moth-init Executable file
View File

@ -0,0 +1,9 @@
#! /bin/sh
while true; do
/moth/bin/once
sleep 20
done &
cd /moth/www
s6-tcpserver -u $(id -u www) -g $(id -g www) 0.0.0.0 80 /usr/bin/eris -c -d -.