diff --git a/tools/dockerfile b/tools/dockerfile new file mode 100644 index 0000000..9a748dd --- /dev/null +++ b/tools/dockerfile @@ -0,0 +1,44 @@ +FROM alpine + +ENV base /srv/moth/default +ENV user ftp + +# Get all packages +RUN apk --no-cache add git build-base +RUN apk --no-cache add lua5.3 +RUN apk --no-cache add s6-networking + +# Get source code +WORKDIR /usr/local/src +RUN git clone --branch master https://github.com/dirtbags/moth +RUN git clone https://github.com/nealey/eris + +# Set up moth +WORKDIR /usr/local/src/moth +RUN mkdir -p $base +RUN cp tools/mothd /srv/moth +RUN cp -r www $base/www +RUN cp -r bin $base/bin +RUN mkdir $base/packages +RUN hd $base/assigned.txt +RUN ln -s ../state/points.json $base/www/points.json +RUN ln -s ../state/puzzles.json $base/www/puzzles.json +RUN mkdir $base/state +RUN mkdir $base/state/teams +RUN touch $base/state/points.log +RUN mkdir -p $base/state/points.new +RUN mkdir -p $base/state/points.tmp +RUN chown -R $user $base/state +RUN ln -s lua5.3 /usr/bin/lua + +# Set up eris +WORKDIR /usr/local/src/eris +RUN make +RUN cp eris /usr/local/bin + +# Now, go +WORKDIR / +COPY run-moth /usr/local/bin +EXPOSE 80 +CMD /usr/local/bin/run-moth $user + diff --git a/tools/run-moth b/tools/run-moth new file mode 100755 index 0000000..ed6a85d --- /dev/null +++ b/tools/run-moth @@ -0,0 +1,10 @@ +#! /bin/sh + +user=$1 +uid=$(id -u $user) + +su -s /srv/moth/mothd $user & + +cd /srv/moth/default/www +exec s6-tcpserver -u $uid 0.0.0.0 80 /usr/local/bin/eris -. -c +