diff --git a/Dockerfile b/Dockerfile index 07089d5a..0f8c5a4c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \ + "] diff --git a/app.py b/app.py index b220cbfb..a0c2b355 100644 --- a/app.py +++ b/app.py @@ -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() diff --git a/docker-compose.yml b/docker-compose.yml index e399c731..1b2ee620 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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"