diff --git a/.drone.yml b/.drone.yml index dc5b96a..9dfbfbe 100644 --- a/.drone.yml +++ b/.drone.yml @@ -21,7 +21,7 @@ steps: image: python:3 commands: - pip3 install jinja2 - - ./scripts/translate_templates.py --lang-dir lang/ --template-dir templates/ + - ./scripts/translate_templates.py --lang-dir lang/ --template-dir web/templates/ when: event: - push @@ -101,7 +101,7 @@ steps: image: python:3 commands: - pip3 install jinja2 - - ./scripts/translate_templates.py --lang-dir lang/ --template-dir templates/ + - ./scripts/translate_templates.py --lang-dir lang/ --template-dir web/templates/ when: event: - push diff --git a/Dockerfile b/Dockerfile index 329abb6..4989b05 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ +ARG ARCH= FROM python:3-slim-bullseye AS python-builder ENV DEBIAN_FRONTEND=noninteractive WORKDIR /botamusique @@ -6,11 +7,23 @@ RUN apt-get update \ && apt-get install --no-install-recommends -y gcc g++ ffmpeg libjpeg-dev libmagic-dev opus-tools zlib1g-dev \ && rm -rf /var/lib/apt/lists/* COPY . /botamusique - RUN python3 -m venv venv \ && venv/bin/pip install wheel \ && venv/bin/pip install -r requirements.txt +FROM ${ARCH}node:14-bullseye-slim AS node-builder +ENV DEBIAN_FRONTEND=noninteractive +WORKDIR /botamusique/web +COPY --from=python-builder /botamusique /botamusique +RUN npm install +RUN npm run build + +FROM ${ARCH}python:3-slim-bullseye AS template-builder +ENV DEBIAN_FRONTEND=noninteractive +WORKDIR /botamusique +COPY --from=node-builder /botamusique /botamusique +RUN venv/bin/python scripts/translate_templates.py --lang-dir /botamusique/lang --template-dir /botamusique/web/templates + FROM python:3.11-slim-bullseye ENV DEBIAN_FRONTEND noninteractive @@ -18,7 +31,7 @@ EXPOSE 8181 RUN apt update && \ apt install --no-install-recommends -y opus-tools ffmpeg libmagic-dev curl tar && \ rm -rf /var/lib/apt/lists/* -COPY --from=python-builder /botamusique /botamusique +COPY --from=template-builder /botamusique /botamusique WORKDIR /botamusique RUN chmod +x entrypoint.sh diff --git a/Dockerfile.local b/Dockerfile.local index f068dce..4eb40be 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -33,7 +33,7 @@ ENV DEBIAN_FRONTEND=noninteractive WORKDIR /botamusique COPY --from=python-builder /botamusique . COPY --from=node-builder /botamusique/templates templates -RUN venv/bin/python scripts/translate_templates.py --lang-dir /botamusique/lang --template-dir /botamusique/templates +RUN venv/bin/python scripts/translate_templates.py --lang-dir /botamusique/lang --template-dir /botamusique/web/templates FROM ${ARCH}python:3-slim-bullseye diff --git a/README.md b/README.md index e881faf..1d80bb9 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ python3 -m venv venv venv/bin/pip install wheel venv/bin/pip install -r requirements.txt (cd web && npm install && npm run build) -venv/bin/python3 ./scripts/translate_templates.py --lang-dir lang/ --template-dir templates/ +venv/bin/python3 ./scripts/translate_templates.py --lang-dir lang/ --template-dir web/templates/ ``` diff --git a/interface.py b/interface.py index 2229ed6..0dec6a4 100644 --- a/interface.py +++ b/interface.py @@ -64,7 +64,7 @@ class ReverseProxied(object): root_dir = os.path.dirname(__file__) -web = Flask(__name__, template_folder=os.path.join(root_dir, "templates")) +web = Flask(__name__, template_folder=os.path.join(root_dir, "web/templates")) #web.config['TEMPLATES_AUTO_RELOAD'] = True log = logging.getLogger("bot") user = 'Remote Control' @@ -227,7 +227,7 @@ def get_all_dirs(): @web.route("/", methods=['GET']) @requires_auth def index(): - return open(os.path.join(root_dir, f"templates/index.{var.language}.html"), "r").read() + return open(os.path.join(root_dir, f"web/templates/index.{var.language}.html"), "r").read() @web.route("/playlist", methods=['GET'])