From 69d88fa84906798368bc0267fbe007352e2f7765 Mon Sep 17 00:00:00 2001 From: Alan Grainger Date: Sat, 2 Nov 2024 22:18:04 +0100 Subject: [PATCH] Consolidate app files --- .dockerignore | 2 +- .gitignore | 9 +++++---- Dockerfile | 11 ++++++++--- .env.example => app/.env.example | 0 config.json => app/config.json | 0 healthcheck.js => app/healthcheck.js | 0 package.json => app/package.json | 2 +- {public => app/public}/favicon.ico | Bin {public => app/public}/fonts/lg.svg | 0 {public => app/public}/fonts/lg.ttf | Bin {public => app/public}/fonts/lg.woff | Bin {public => app/public}/fonts/lg.woff2 | Bin {public => app/public}/images/loading.gif | Bin {public => app/public}/images/play.png | Bin {public => app/public}/lg-fullscreen.min.js | 0 {public => app/public}/lg-thumbnail.min.js | 0 {public => app/public}/lg-video.min.js | 0 {public => app/public}/lg-zoom.min.js | 0 {public => app/public}/lightgallery-bundle.min.css | 0 {public => app/public}/lightgallery.min.js | 0 {public => app/public}/pico.min.css | 0 {public => app/public}/robots.txt | 0 {public => app/public}/style.css | 0 {public => app/public}/web.js | 0 {src => app/src}/encrypt.ts | 0 {src => app/src}/immich.ts | 0 {src => app/src}/index.ts | 4 ---- {src => app/src}/render.ts | 0 {src => app/src}/types.ts | 0 tsconfig.json => app/tsconfig.json | 0 {views => app/views}/gallery.ejs | 0 {views => app/views}/password.ejs | 0 32 files changed, 15 insertions(+), 13 deletions(-) rename .env.example => app/.env.example (100%) rename config.json => app/config.json (100%) rename healthcheck.js => app/healthcheck.js (100%) rename package.json => app/package.json (88%) rename {public => app/public}/favicon.ico (100%) rename {public => app/public}/fonts/lg.svg (100%) rename {public => app/public}/fonts/lg.ttf (100%) rename {public => app/public}/fonts/lg.woff (100%) rename {public => app/public}/fonts/lg.woff2 (100%) rename {public => app/public}/images/loading.gif (100%) rename {public => app/public}/images/play.png (100%) rename {public => app/public}/lg-fullscreen.min.js (100%) rename {public => app/public}/lg-thumbnail.min.js (100%) rename {public => app/public}/lg-video.min.js (100%) rename {public => app/public}/lg-zoom.min.js (100%) rename {public => app/public}/lightgallery-bundle.min.css (100%) rename {public => app/public}/lightgallery.min.js (100%) rename {public => app/public}/pico.min.css (100%) rename {public => app/public}/robots.txt (100%) rename {public => app/public}/style.css (100%) rename {public => app/public}/web.js (100%) rename {src => app/src}/encrypt.ts (100%) rename {src => app/src}/immich.ts (100%) rename {src => app/src}/index.ts (94%) rename {src => app/src}/render.ts (100%) rename {src => app/src}/types.ts (100%) rename tsconfig.json => app/tsconfig.json (100%) rename {views => app/views}/gallery.ejs (100%) rename {views => app/views}/password.ejs (100%) diff --git a/.dockerignore b/.dockerignore index 04c01ba..b947077 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,2 @@ node_modules/ -dist/ \ No newline at end of file +dist/ diff --git a/.gitignore b/.gitignore index 93a3f94..0beeaa9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ -/node_modules/ -/dist/ -/.idea/ +node_modules/ +dist/ +.idea .env -/package-lock.json +.directory +package-lock.json diff --git a/Dockerfile b/Dockerfile index fcf4452..5d495ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,11 +2,12 @@ FROM node:lts-slim WORKDIR /app -COPY package.json ./ +COPY app/package.json ./ RUN npm install --omit=dev +RUN npm install pm2 -g -COPY . . +COPY app/ ./ ENV NODE_ENV=production @@ -14,4 +15,8 @@ ENV NODE_ENV=production # dev-dependencies above to save space in the final build RUN npx tsc --noCheck -CMD [ "node", "dist/index.js" ] +RUN chown -R node:node /app + +USER node + +CMD ["pm2-runtime", "dist/index.js" ] diff --git a/.env.example b/app/.env.example similarity index 100% rename from .env.example rename to app/.env.example diff --git a/config.json b/app/config.json similarity index 100% rename from config.json rename to app/config.json diff --git a/healthcheck.js b/app/healthcheck.js similarity index 100% rename from healthcheck.js rename to app/healthcheck.js diff --git a/package.json b/app/package.json similarity index 88% rename from package.json rename to app/package.json index 1e0a548..50f61f4 100644 --- a/package.json +++ b/app/package.json @@ -4,7 +4,7 @@ "scripts": { "dev": "ts-node src/index.ts", "build": "npx tsc", - "test": "podman build -t immich-proxy-test . && podman run --init -it -p=3000:3000 immich-proxy-test", + "test": "podman build -t immich-proxy-test .. && podman run --init -it -p=3000:3000 --env-file .env immich-proxy-test", "start": "node dist/index.js" }, "author": "Alan Grainger", diff --git a/public/favicon.ico b/app/public/favicon.ico similarity index 100% rename from public/favicon.ico rename to app/public/favicon.ico diff --git a/public/fonts/lg.svg b/app/public/fonts/lg.svg similarity index 100% rename from public/fonts/lg.svg rename to app/public/fonts/lg.svg diff --git a/public/fonts/lg.ttf b/app/public/fonts/lg.ttf similarity index 100% rename from public/fonts/lg.ttf rename to app/public/fonts/lg.ttf diff --git a/public/fonts/lg.woff b/app/public/fonts/lg.woff similarity index 100% rename from public/fonts/lg.woff rename to app/public/fonts/lg.woff diff --git a/public/fonts/lg.woff2 b/app/public/fonts/lg.woff2 similarity index 100% rename from public/fonts/lg.woff2 rename to app/public/fonts/lg.woff2 diff --git a/public/images/loading.gif b/app/public/images/loading.gif similarity index 100% rename from public/images/loading.gif rename to app/public/images/loading.gif diff --git a/public/images/play.png b/app/public/images/play.png similarity index 100% rename from public/images/play.png rename to app/public/images/play.png diff --git a/public/lg-fullscreen.min.js b/app/public/lg-fullscreen.min.js similarity index 100% rename from public/lg-fullscreen.min.js rename to app/public/lg-fullscreen.min.js diff --git a/public/lg-thumbnail.min.js b/app/public/lg-thumbnail.min.js similarity index 100% rename from public/lg-thumbnail.min.js rename to app/public/lg-thumbnail.min.js diff --git a/public/lg-video.min.js b/app/public/lg-video.min.js similarity index 100% rename from public/lg-video.min.js rename to app/public/lg-video.min.js diff --git a/public/lg-zoom.min.js b/app/public/lg-zoom.min.js similarity index 100% rename from public/lg-zoom.min.js rename to app/public/lg-zoom.min.js diff --git a/public/lightgallery-bundle.min.css b/app/public/lightgallery-bundle.min.css similarity index 100% rename from public/lightgallery-bundle.min.css rename to app/public/lightgallery-bundle.min.css diff --git a/public/lightgallery.min.js b/app/public/lightgallery.min.js similarity index 100% rename from public/lightgallery.min.js rename to app/public/lightgallery.min.js diff --git a/public/pico.min.css b/app/public/pico.min.css similarity index 100% rename from public/pico.min.css rename to app/public/pico.min.css diff --git a/public/robots.txt b/app/public/robots.txt similarity index 100% rename from public/robots.txt rename to app/public/robots.txt diff --git a/public/style.css b/app/public/style.css similarity index 100% rename from public/style.css rename to app/public/style.css diff --git a/public/web.js b/app/public/web.js similarity index 100% rename from public/web.js rename to app/public/web.js diff --git a/src/encrypt.ts b/app/src/encrypt.ts similarity index 100% rename from src/encrypt.ts rename to app/src/encrypt.ts diff --git a/src/immich.ts b/app/src/immich.ts similarity index 100% rename from src/immich.ts rename to app/src/immich.ts diff --git a/src/index.ts b/app/src/index.ts similarity index 94% rename from src/index.ts rename to app/src/index.ts index 04b844d..2ee37b8 100644 --- a/src/index.ts +++ b/app/src/index.ts @@ -89,10 +89,6 @@ const toString = (value: unknown) => { return typeof value === 'string' ? value : '' } -// Handle process termination requests (e.g. Ctrl+C) -process.on('SIGTERM', () => { process.exit(0) }) -process.on('SIGINT', () => { process.exit(0) }) - app.listen(3000, () => { console.log(dayjs().format() + ' Server started') }) diff --git a/src/render.ts b/app/src/render.ts similarity index 100% rename from src/render.ts rename to app/src/render.ts diff --git a/src/types.ts b/app/src/types.ts similarity index 100% rename from src/types.ts rename to app/src/types.ts diff --git a/tsconfig.json b/app/tsconfig.json similarity index 100% rename from tsconfig.json rename to app/tsconfig.json diff --git a/views/gallery.ejs b/app/views/gallery.ejs similarity index 100% rename from views/gallery.ejs rename to app/views/gallery.ejs diff --git a/views/password.ejs b/app/views/password.ejs similarity index 100% rename from views/password.ejs rename to app/views/password.ejs