fix docker

This commit is contained in:
ngxson 2023-08-29 22:39:37 +02:00
parent 9305887970
commit aea0c74648
3 changed files with 23 additions and 9 deletions

View File

@ -3,16 +3,26 @@ FROM python:3.10
WORKDIR /srv
COPY ./requirements.txt .
RUN python3 -m venv venv && . venv/bin/activate
RUN python3 -m pip install --no-cache-dir -r requirements.txt --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
COPY ./app.py /srv/app.py
COPY ./api /srv/api
COPY ./static /srv/static
COPY ./templates /srv/templates
COPY ./web /srv/web
COPY ./configs /srv/configs
COPY ./assets /srv/assets
# COPY ./models /srv/models # Mounting model is more efficient
CMD ["python", "app.py", "--host", "0.0.0.0", "--port", "9600", "--db_path", "data/database.db"]
# TODO: this is monkey-patch for check_update() function, should be disabled in Docker
COPY ./.git /srv/.git
VOLUME [ "/data" ]
# Monkey-patch: send a "enter" keystroke to python to confirm the first launch process
CMD ["/bin/bash", "-c", " \
echo -ne '\n' | \
python app.py \
--host 0.0.0.0 \
--port 9600 \
--db_path /data/Documents/databases/database.db \
--config /configs/config.yaml \
"]

4
app.py
View File

@ -1998,6 +1998,8 @@ if __name__ == "__main__":
else:
print(f"Please open your browser and go to {url} to view the ui")
socketio.run(app, host=config["host"], port=config["port"])
socketio.run(app, host=config["host"], port=config["port"],
# prevent error: The Werkzeug web server is not designed to run in production
allow_unsafe_werkzeug=True)
# http_server = WSGIServer((config["host"], config["port"]), app, handler_class=WebSocketHandler)
# http_server.serve_forever()

View File

@ -6,10 +6,12 @@ services:
context: .
dockerfile: Dockerfile
volumes:
- ./data:/srv/help
- ./data:/srv/data
- ./data:/data
- ./data/.parisneo:/root/.parisneo/
- ./configs:/srv/configs
- ./web:/srv/web
environment:
- HOME=/data
tty: true
stdin_open: true
ports:
- "9600:9600"