High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
Improve Docker setup and reduce memory usage of production containers (#338)
Fynn Petersen-Freybece6253d5a0
diff --git a/server/apps/immich/src/main.ts b/server/apps/immich/src/main.tsindex 770e3c2e2d..51afa4288f 100644--- a/server/apps/immich/src/main.ts+++ b/server/apps/immich/src/main.ts@@ -46,12 +46,12 @@ async function bootstrap() {customSiteTitle: 'Immich API Documentation',});- // Generate API Documentation- const outputPath = path.resolve(process.cwd(), 'immich-openapi-specs.json');- writeFileSync(outputPath, JSON.stringify(apiDocument), { encoding: 'utf8' });-+await app.listen(3001, () => {if (process.env.NODE_ENV == 'development') {+ // Generate API Documentation only in development mode+ const outputPath = path.resolve(process.cwd(), 'immich-openapi-specs.json');+ writeFileSync(outputPath, JSON.stringify(apiDocument), { encoding: 'utf8' });Logger.log('Running Immich Server in DEVELOPMENT environment', 'ImmichServer');}diff --git a/server/package.json b/server/package.jsonindex 7eccabdd05..0f6349b982 100644--- a/server/package.json+++ b/server/package.json@@ -7,7 +7,7 @@"license": "UNLICENSED","scripts": {"prebuild": "rimraf dist",- "build": "nest build",+ "build": "nest build immich && nest build microservices","format": "prettier --write \"apps/**/*.ts\" \"libs/**/*.ts\"","start": "nest start","start:dev": "nest start --watch",diff --git a/server/start-microservices.sh b/server/start-microservices.shindex 4e1f9c12eb..d76065712e 100644--- a/server/start-microservices.sh+++ b/server/start-microservices.sh@@ -1 +1 @@-npm start microservices\ No newline at end of file+node dist/apps/microservices/apps/microservices/src/main\ No newline at end of filediff --git a/server/start-server.sh b/server/start-server.shindex 9f35169bf6..5bbc6dd3cc 100644--- a/server/start-server.sh+++ b/server/start-server.sh@@ -1 +1 @@-npm start immich\ No newline at end of file+node dist/apps/immich/apps/immich/src/main\ No newline at end of filediff --git a/web/Dockerfile b/web/Dockerfileindex 8d3c500ed3..b5db9c9e81 100644--- a/web/Dockerfile+++ b/web/Dockerfile@@ -5,35 +5,23 @@ WORKDIR /usr/src/appRUN chown node:node /usr/src/app-COPY --chown=node:node package*.json ./+RUN apk add --no-cache setpriv-RUN apk add --update-cache build-base python3+COPY --chown=node:node package*.json ./RUN npm ciCOPY --chown=node:node . .EXPOSE 3000-EXPOSE 24678FROM base AS devENV CHOKIDAR_USEPOLLING=true+EXPOSE 24678CMD ["npm", "run", "dev"]-FROM node:16-alpine3.14 as prod--WORKDIR /usr/src/app--RUN chown node:node /usr/src/app--COPY --chown=node:node package*.json ./-COPY --chown=node:node . .--RUN apk add --update-cache build-base python3--RUN npm ci--EXPOSE 3000+FROM base as prod+ENV NODE_ENV=production# Issue build command in entrypoint.sh to capture user .env file instead of the builder .env file.diff --git a/web/entrypoint.sh b/web/entrypoint.shindex 291964f828..dc06f9b738 100644--- a/web/entrypoint.sh+++ b/web/entrypoint.sh@@ -1 +1,6 @@-npm run build && node /usr/src/app/build/index.js\ No newline at end of file+npm run build+if [ `id -u` -eq 0 ] && [ -n "$PUID" ] && [ -n "$PGID" ]; then+ exec setpriv --reuid $PUID --regid $PGID --clear-groups node /usr/src/app/build/index.js+else+ node /usr/src/app/build/index.js+fi\ No newline at end of filediff --git a/web/src/hooks.ts b/web/src/hooks.tsindex 17f4647b75..afb4181647 100644--- a/web/src/hooks.ts+++ b/web/src/hooks.ts@@ -1,7 +1,7 @@import type { GetSession, Handle } from '@sveltejs/kit';import * as cookie from 'cookie';import { api } from '@api';-import { AxiosError } from 'axios';+import AxiosError from 'axios';export const handle: Handle = async ({ event, resolve }) => {const cookies = cookie.parse(event.request.headers.get('cookie') || '');