From 1a48f0eae60974d23322bc8f72a8f09384f940b0 Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Fri, 20 Jan 2023 15:14:20 -0800 Subject: [PATCH] Fully builds... Signed-off-by: James Ketrenos --- .dockerignore | 3 ++- Dockerfile | 22 ++++++++++++++-------- scripts/kill-server.sh | 2 +- server/app.js | 4 ++-- server/package.json | 7 ++----- server/routes/basepath.js | 2 +- server/routes/index.js | 2 +- 7 files changed, 23 insertions(+), 19 deletions(-) diff --git a/.dockerignore b/.dockerignore index fe218a2..1f7655b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,10 +6,11 @@ !*.sh !*.md !config +config/local.json !client client/node_modules !frontend -frontend/bower_modules +frontend/bower_components !server server/node_modules !scanner diff --git a/Dockerfile b/Dockerfile index 0b2cb93..539d7d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,17 +30,17 @@ RUN DEBIAN_FRONTEND=NONINTERACTIVE apt-get install -y \ git WORKDIR /website -COPY /*.json /website/ -RUN npm upgrade && npm install +COPY /package.json /website/ +RUN npm install COPY /.babelrc /*.html /*.js /website/ COPY /src /website/src COPY /frontend /website/frontend -RUN cat package.json RUN npm run build WORKDIR /website/client -COPY /client/*.json /website/client/ -RUN npm upgrade && npm install +COPY /client/package.json /website/client/ +RUN npm install +COPY /client/tsconfig.json /website/client/ COPY /client/*.js /website/client/ COPY /client/public /website/client/public COPY /client/src /website/client/src @@ -77,10 +77,16 @@ RUN pip install piexif # install <1.24 RUN pip install "numpy<1.24" -COPY /server /website/server WORKDIR /website/server +COPY /server/package.json /website/server/ RUN npm install +COPY /config /website/config +COPY /server/*.js /website/server/ +COPY /server/db /website/server/db +COPY /server/routes /website/server/routes +COPY /server/lib /website/server/lib + # Copy the Python face management scripts COPY /ketrface /website/ketrface @@ -88,7 +94,7 @@ COPY /ketrface /website/ketrface # 'website' is used if DEVELOPMENT is not set (PRODUCTION) # FROM runtime AS website -RUN "Building PRODUCTION" +RUN echo "Building PRODUCTION" COPY /server/production.location /etc/nginx/snippets/active.location COPY --from=production /website/dist /website/dist COPY --from=production /website/*.html /website/ @@ -112,7 +118,7 @@ COPY /config/default.json /website/config/default.json # Switch to bash instead of sh SHELL [ "/bin/bash", "-c" ] -RUN cp /website/server/nginx.conf /etc/nginx/sites-enabled/default +COPY /server/nginx.conf /etc/nginx/sites-enabled/default COPY /scripts /opt/scripts ENV PATH="${PATH}:/opt/scripts" diff --git a/scripts/kill-server.sh b/scripts/kill-server.sh index c4101fb..1ab0afc 100755 --- a/scripts/kill-server.sh +++ b/scripts/kill-server.sh @@ -1,6 +1,6 @@ #!/bin/bash pid=$(ps aux | - grep -E '[0-9] (/usr/bin/)?node .*server/app.js' | + grep -E '[0-9] (/usr/bin/)?node app.js' | while read user pid rest; do echo $pid; done) diff --git a/server/app.js b/server/app.js index 2e6b388..071257b 100755 --- a/server/app.js +++ b/server/app.js @@ -41,8 +41,8 @@ app.set("trust proxy", true); app.use(basePath, require("./routes/basepath.js")); /* Handle static files first so excessive logging doesn't occur */ -app.use(basePath, express.static("frontend", { index: false })); -app.use(basePath + "dist", express.static("dist", { index: false })); +app.use(basePath, express.static("../frontend", { index: false })); +app.use(basePath + "dist", express.static("../dist", { index: false })); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ diff --git a/server/package.json b/server/package.json index 492d81e..84daf25 100644 --- a/server/package.json +++ b/server/package.json @@ -4,11 +4,8 @@ "description": "Self hosting photo", "main": "server/app.js", "scripts": { - "start": "node app.js", - "start-devel": "concurrently \"npm:server\" \"npm:dev\"", - "server": "node ./app.js", - "debug": "node --inspect --debug-brk ./app.js", - "backend": "NODE_CONFIG_ENV='production' node app.js" + "start": "NODE_CONFIG_DIR=../config node app.js", + "debug": "node --inspect --debug-brk ./app.js" }, "repository": { "type": "git", diff --git a/server/routes/basepath.js b/server/routes/basepath.js index a8fb0bb..1635e19 100644 --- a/server/routes/basepath.js +++ b/server/routes/basepath.js @@ -20,7 +20,7 @@ router.get("/*", function(req, res, next) { /* Replace in index.html with * the basePath */ - fs.readFile("frontend" + parts.pathname, "utf8", function(error, content) { + fs.readFile("../frontend" + parts.pathname, "utf8", function(error, content) { if (error) { return next(); } diff --git a/server/routes/index.js b/server/routes/index.js index a5b19a3..caf41fd 100755 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -51,7 +51,7 @@ router.get("/*", function(req, res, next) { console.log(JSON.stringify(parts, null, 2)); switch (parts.pathname) { case "/": - source = "frontend/index.html"; + source = "../frontend/index.html"; break; case "/identities": source = "./index.html";