From e028344b97f779d46295cd246d16ea0fa228e26e Mon Sep 17 00:00:00 2001 From: Luka Date: Wed, 10 Jan 2024 11:45:21 +0100 Subject: [PATCH] updated plugins dir location --- Dockerfile | 8 +++++--- README.md | 2 +- docker-compose.yml | 2 +- plugin-server.py | 2 ++ start.sh | 4 ---- 5 files changed, 9 insertions(+), 9 deletions(-) delete mode 100644 start.sh diff --git a/Dockerfile b/Dockerfile index c613636..736a570 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,12 +8,14 @@ RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python RUN python3 -m ensurepip RUN pip3 install --no-cache --upgrade pip setuptools -ADD . /var/www/plugin-server +ADD ./plugin-server.py /var/www/plugin-server/plugin-server.py +ADD ./plugin-loader.js /var/www/plugin-server/plugin-loader.js +ADD ./requirements.txt /var/www/plugin-server/requirements.txt WORKDIR /var/www/plugin-server/ RUN pip install -r requirements.txt -RUN ln -s /var/www/plugins ./plugins +RUN ln -s /var/www/plugins/ ./ -CMD sh start.sh \ No newline at end of file +CMD /usr/bin/redis-server & python plugin-server.py \ No newline at end of file diff --git a/README.md b/README.md index a0b54db..d527b17 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Then you can run [flask server](plugin-server.py) on a server. ## Example -Let's say you are hosting plugins on lexonomyplugins.example.com and that there is a plugin (a folder) called myplugin in `CWD` of the server python process. You need to set: +Let's say you are hosting plugins on lexonomyplugins.example.com and that there is a plugin (a folder) called myplugin in `CWD/plugins/` of the server python process. You need to set: * `plugin: "//lexonomyplugins.example.com/myplugin"` in javascript loader, * `URL = "//lexonomyplugins.example.com/myplugin"` in python server, diff --git a/docker-compose.yml b/docker-compose.yml index 670e31a..f921a82 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,6 +7,6 @@ services: dockerfile: Dockerfile restart: always volumes: - - /home/ozbolt/plugins:/var/www/plugins + - ./plugins:/var/www/plugins ports: - "8085:5000" diff --git a/plugin-server.py b/plugin-server.py index e98e30f..3c6d026 100644 --- a/plugin-server.py +++ b/plugin-server.py @@ -25,6 +25,7 @@ redis = redis.Redis(host='localhost', port=6379, db=0) URL = "https://plugins.lexonomy.cjvt.si" REPLACE_STRING = "$LOCATION$" +PLUGINS_DIR = os.environ.get("PLUGINS_DIR_PATH", "plugins") def check_cache(full_path): @@ -49,6 +50,7 @@ def generate_etag(N=12): def return_file(path, plugin=None): full_path = path if plugin is None else"{}/{}".format(plugin, path) + full_path = f"{PLUGINS_DIR}/{full_path}" if not os.path.isfile(full_path): return "File not found", 404 diff --git a/start.sh b/start.sh deleted file mode 100644 index bb12751..0000000 --- a/start.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -/usr/bin/redis-server & -python plugin-server.py \ No newline at end of file