More dockering

This commit is contained in:
Neale Pickett 2017-09-11 16:12:22 +00:00
parent dbfea686f8
commit 552c9baff1
6 changed files with 58 additions and 37 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
.git

View File

@ -1,8 +0,0 @@
FROM python:3
COPY tools/devel-server.py /pp/
COPY tools/moth.py /pp/
COPY tools/mistune.py /pp/
COPY tools/answer_words.txt /pp/
ENTRYPOINT ["python3", "/pp/devel-server.py"]

12
Dockerfile.moth-devel Normal file
View File

@ -0,0 +1,12 @@
FROM python:3-alpine
COPY tools/devel-server.py /moth/
COPY tools/moth.py /moth/
COPY tools/mistune.py /moth/
COPY tools/answer_words.txt /moth/
COPY www /moth/src/www
COPY example-puzzles /moth/puzzles
COPY docs /moth/docs
WORKDIR /moth/
ENTRYPOINT ["python3", "/moth/devel-server.py"]

View File

@ -1,4 +1,4 @@
FROM python:3 FROM python:3-alpine
COPY tools/package-puzzles.py /pp/ COPY tools/package-puzzles.py /pp/
COPY tools/moth.py /pp/ COPY tools/moth.py /pp/

View File

@ -9,27 +9,33 @@ It even works in Windows,
because that is what my career has become. because that is what my career has become.
Starting It Up Getting It Going
----------------- ----------------
Just run `devel-server.py` in the top-level MOTH directory. ### With Docker
If you can use docker, you are in luck:
docker run --rm -t -p 8080:8080 dirtbags/moth-devel
Gets you a development puzzle server running on port 8080,
with the sample puzzle directory set up.
### Without Docker
If you can't use docker,
try this:
apt install python3
git clone https://github.com/dirtbags/moth/
cd moth
./devel-server.py --puzzles example-puzzles
Installing New Puzzles Installing New Puzzles
----------------------------- -----------------------------
You are meant to have your puzzles checked out into a `puzzles`
directory off the main MOTH directory.
You can do most of your development on this living copy.
In the directory containing `devel-server.py`, you would run something like:
git clone /path/to/my/puzzles-repository puzzles
or on Unix:
ln -s /path/to/my/puzzles-repository puzzles
The development server wants to see category directories under `puzzles`, The development server wants to see category directories under `puzzles`,
like this: like this:
@ -44,3 +50,13 @@ like this:
puzzles/category2/200/ puzzles/category2/200/
puzzles/category2/300/ puzzles/category2/300/
### With Docker
docker run --rm -t -v /path/to/my/puzzles:/moth/puzzles:ro -p 8080:8080 dirtbags/moth-devel
### Without Docker
You can use the `--puzzles` argument to `devel-server.py`
to specify a path to your puzzles directory.

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3 #o/usr/bin/env python3
# To pick up any changes to this file without restarting anything: # To pick up any changes to this file without restarting anything:
# while true; do ./tools/devel-server.py --once; done # while true; do ./tools/devel-server.py --once; done
@ -36,7 +36,7 @@ def page(title, body):
<html> <html>
<head> <head>
<title>{title}</title> <title>{title}</title>
<link rel="stylesheet" href="/files/www/res/style.css"> <link rel="stylesheet" href="/files/src/www/res/style.css">
</head> </head>
<body> <body>
<h1>{title}</h1> <h1>{title}</h1>
@ -242,7 +242,7 @@ you are a fool.
self.wfile.write(payload) self.wfile.write(payload)
def run(address=('localhost', 8080), once=False): def run(address=('0.0.0.0', 8080), once=False):
httpd = ThreadingServer(address, MothHandler) httpd = ThreadingServer(address, MothHandler)
print("=== Listening on http://{}:{}/".format(address[0], address[1])) print("=== Listening on http://{}:{}/".format(address[0], address[1]))
if once: if once: