Dockerization, yay!

This commit is contained in:
Neale Pickett 2017-08-06 04:12:34 +00:00
parent 631d1d800c
commit b8c1d9f4a8
2 changed files with 54 additions and 0 deletions

44
tools/dockerfile Normal file
View File

@ -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 </dev/urandom | awk '{print $3 $4 $5 $6;}' | head -n 100 > $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

10
tools/run-moth Executable file
View File

@ -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