mirror of https://github.com/dirtbags/moth.git
Dockerize
This commit is contained in:
parent
d7919c985b
commit
6a00d30c84
|
@ -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"]
|
||||||
|
|
18
bin/once
18
bin/once
|
@ -7,20 +7,36 @@ else
|
||||||
fi
|
fi
|
||||||
basedir=$(pwd)
|
basedir=$(pwd)
|
||||||
|
|
||||||
[ -n "$DEBUG" ] && printf "Updating moth instance in %s\n" $(pwd)
|
log () {
|
||||||
|
echo "moth: $@" 1>&2
|
||||||
|
}
|
||||||
|
|
||||||
# Do nothing if `disabled` is present
|
# Do nothing if `disabled` is present
|
||||||
if [ -f disabled ]; then
|
if [ -f disabled ]; then
|
||||||
|
log "Instance disabled: doing nothing"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Reset to initial state if `reset` is present
|
# Reset to initial state if `reset` is present
|
||||||
if [ -f reset ]; then
|
if [ -f reset ]; then
|
||||||
|
log "Resetting state"
|
||||||
rm -f state/teams/* state/points.new/* state/points.tmp/*
|
rm -f state/teams/* state/points.new/* state/points.tmp/*
|
||||||
: > state/points.log
|
: > state/points.log
|
||||||
rm -f reset
|
rm -f reset
|
||||||
fi
|
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
|
# Create a list of currently-active categories
|
||||||
: > state/categories.txt.new
|
: > state/categories.txt.new
|
||||||
for dn in packages/*; do
|
for dn in packages/*; do
|
||||||
|
|
|
@ -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 -.
|
Loading…
Reference in New Issue