Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM python:3
RUN apt-get update
FROM python:3-slim
RUN pip3 install nltk
RUN python3 -c "import nltk; nltk.download('words'); nltk.download('stopwords')"
WORKDIR /var/www
Expand Down
18 changes: 18 additions & 0 deletions Dockerfile-alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM alpine:3.23.5 as builder

RUN apk --no-cache add binutils python3 git py3-pip
RUN python -m pip install --break-system-packages nltk pyinstaller==6.18.0

RUN python3 -c "import nltk; nltk.download('words'); nltk.download('stopwords')"
COPY / ./
RUN python -m PyInstaller src/server.py

FROM alpine:3.23.5

WORKDIR /var/www
COPY --from=builder dist/server/_internal ./_internal
COPY --from=builder dist/server/server .
COPY --from=builder assets assets
COPY --from=builder config config

CMD ["./server"]
2 changes: 1 addition & 1 deletion config/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"port": 80,
"port": 8080,
"random-seed": 0,
"document-root": "/",

Expand Down
3 changes: 3 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ def port(self):
def random_seed(self):
return self.opts["random-seed"]

def random_seed_override(self, new_seed):
self.opts["random-seed"] = new_seed

@property
def spacing(self):
return self.opts["spacing-characters"]
Expand Down
3 changes: 3 additions & 0 deletions src/server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from http.server import HTTPServer
from handler import Handler
from config import Config
import os

def run(config:Config):
print("Listening on port {}".format(config.port))
Expand All @@ -12,6 +13,8 @@ def run(config:Config):

def main():
config = Config()
seed = os.environ.get("PYISON_SEED", config.random_seed)
config.random_seed_override(seed)
if config.random_seed == 0:
print("Please update the random seed value in the config file!")
run(config)
Expand Down