From b0ece0637c47c49cddfdda32f0b8dc8c46a4beb8 Mon Sep 17 00:00:00 2001 From: Tobias Stein Date: Fri, 28 Jun 2019 11:24:08 +0200 Subject: [PATCH] Add rename URL script to update nginx config with prefix path ENV --- Dockerfile | 3 +++ image/etc/RenameURL.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 image/etc/RenameURL.py diff --git a/Dockerfile b/Dockerfile index 030542a..aa7f9ec 120000 --- a/Dockerfile +++ b/Dockerfile @@ -112,6 +112,9 @@ RUN cp -R /src/web/dist/. /usr/local/lib/web/frontend/ COPY image / +# This has to be called in deriving images +RUN python /etc/RenameURL.py + EXPOSE 80 WORKDIR /root ENV HOME=/home/ubuntu \ diff --git a/image/etc/RenameURL.py b/image/etc/RenameURL.py new file mode 100644 index 0000000..a16f79b --- /dev/null +++ b/image/etc/RenameURL.py @@ -0,0 +1,19 @@ +import os, fnmatch + +toFind = "/app" +toReplace = os.getenv("PREFIX_PATH", "/app") + +print("using path {0} ...".format(toReplace)) + +def findReplace(directory, find, replace): + print("Rename {0} into {1} at {2}".format(toFind, toReplace, directory)) + for path, dirs, files in os.walk(os.path.abspath(directory)): + for filename in files: + filepath = os.path.join(path, filename) + with open(filepath) as f: + s = f.read() + s = s.replace(find, replace) + with open(filepath, "w") as f: + f.write(s) + +findReplace("/etc/nginx/sites-enabled/", toFind, toReplace) \ No newline at end of file