Merge pull request #360 from ngxson/main

Fix docker not running / not preserving bindings in volume
This commit is contained in:
Saifeddine ALOUI 2023-08-31 01:24:43 +02:00 committed by GitHub
commit 19ed121aa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 10 deletions

View File

@ -3,16 +3,28 @@ 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
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 (1): because "binding_zoo" install the packets inside venv, we cannot do pip install on build time
# Monkey-patch (2): send a "enter" keystroke to python to confirm the first launch process
CMD ["/bin/bash", "-c", " \
python -m venv /data/venv; \
source /data/venv/bin/activate; \
python -m pip install --no-cache-dir -r requirements.txt --upgrade pip; \
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

@ -2009,6 +2009,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"