From ce06af0c9be0e7fc46fffe8f947dc33eca0a55d6 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 22 May 2022 04:48:38 -0500 Subject: [PATCH] Fixed lodash library not invoking in production build (#171) * Added staging docker-compose file * Use lodash-es and remove hydration option on photos page fixed the problem --- Makefile | 3 + docker/docker-compose.staging.yml | 105 +++++++++++++++++++++++++++++ web/package-lock.json | 30 +++++++++ web/package.json | 2 + web/src/lib/stores/assets.ts | 15 +++-- web/src/routes/__layout.svelte | 27 ++++---- web/src/routes/photos/index.svelte | 1 - web/svelte.config.js | 2 - 8 files changed, 163 insertions(+), 22 deletions(-) create mode 100644 docker/docker-compose.staging.yml diff --git a/Makefile b/Makefile index ee0a7ea309..ae56b3b464 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,9 @@ dev-update: dev-scale: docker-compose -f ./docker/docker-compose.dev.yml up --build -V --scale immich_server=3 --remove-orphans +stage: + docker-compose -f ./docker/docker-compose.staging.yml up --build -V --remove-orphans + test-e2e: docker-compose -f ./docker/docker-compose.test.yml --env-file ./docker/.env.test up --abort-on-container-exit --exit-code-from immich_server_test diff --git a/docker/docker-compose.staging.yml b/docker/docker-compose.staging.yml new file mode 100644 index 0000000000..0e02e5ad0b --- /dev/null +++ b/docker/docker-compose.staging.yml @@ -0,0 +1,105 @@ +version: "3.8" + +services: + immich-server: + image: immich-server-staging:latest + build: + context: ../server + dockerfile: Dockerfile + entrypoint: ["/bin/sh", "./entrypoint.sh"] + expose: + - "3000" + volumes: + - ${UPLOAD_LOCATION}:/usr/src/app/upload + env_file: + - .env + environment: + - NODE_ENV=production + depends_on: + - redis + - database + networks: + - immich-network + restart: always + + immich-microservices: + image: immich-microservices-staging:latest + build: + context: ../microservices + dockerfile: Dockerfile + entrypoint: ["/bin/sh", "./entrypoint.sh"] + expose: + - "3001" + volumes: + - ${UPLOAD_LOCATION}:/usr/src/app/upload + env_file: + - .env + environment: + - NODE_ENV=production + depends_on: + - database + networks: + - immich-network + restart: always + + immich-web: + image: immich-web-staging:latest + entrypoint: ["/bin/sh", "./entrypoint.sh"] + build: + context: ../web + dockerfile: Dockerfile + target: prod + env_file: + - .env + ports: + - 2285:3000 + networks: + - immich-network + restart: always + + + redis: + container_name: immich_redis + image: redis:6.2 + networks: + - immich-network + restart: always + + + database: + container_name: immich_postgres + image: postgres:14 + env_file: + - .env + environment: + POSTGRES_PASSWORD: ${DB_PASSWORD} + POSTGRES_USER: ${DB_USERNAME} + POSTGRES_DB: ${DB_DATABASE_NAME} + PG_DATA: /var/lib/postgresql/data + volumes: + - pgdata:/var/lib/postgresql/data + ports: + - 5432:5432 + networks: + - immich-network + + nginx: + container_name: proxy_nginx + image: nginx:latest + volumes: + - ./settings/nginx-conf:/etc/nginx/conf.d + ports: + - 2283:80 + - 2284:443 + logging: + driver: none + networks: + - immich-network + depends_on: + - immich-server + restart: always + +networks: + immich-network: +volumes: + pgdata: \ No newline at end of file diff --git a/web/package-lock.json b/web/package-lock.json index d4d7af5eac..abb58313e6 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -10,6 +10,7 @@ "dependencies": { "cookie": "^0.4.2", "lodash": "^4.17.21", + "lodash-es": "^4.17.21", "moment": "^2.29.3", "svelte-material-icons": "^2.0.2" }, @@ -20,6 +21,7 @@ "@types/bcrypt": "^5.0.0", "@types/cookie": "^0.4.1", "@types/lodash": "^4.14.182", + "@types/lodash-es": "^4.17.6", "@typescript-eslint/eslint-plugin": "^5.10.1", "@typescript-eslint/parser": "^5.10.1", "autoprefixer": "^10.4.7", @@ -256,6 +258,15 @@ "integrity": "sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q==", "dev": true }, + "node_modules/@types/lodash-es": { + "version": "4.17.6", + "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.6.tgz", + "integrity": "sha512-R+zTeVUKDdfoRxpAryaQNRKk3105Rrgx2CFRClIgRGaqDTdjsm8h6IYA8ir584W3ePzkZfst5xIgDwYrlh9HLg==", + "dev": true, + "dependencies": { + "@types/lodash": "*" + } + }, "node_modules/@types/node": { "version": "17.0.32", "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.32.tgz", @@ -1963,6 +1974,11 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "node_modules/lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==" + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -3287,6 +3303,15 @@ "integrity": "sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q==", "dev": true }, + "@types/lodash-es": { + "version": "4.17.6", + "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.6.tgz", + "integrity": "sha512-R+zTeVUKDdfoRxpAryaQNRKk3105Rrgx2CFRClIgRGaqDTdjsm8h6IYA8ir584W3ePzkZfst5xIgDwYrlh9HLg==", + "dev": true, + "requires": { + "@types/lodash": "*" + } + }, "@types/node": { "version": "17.0.32", "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.32.tgz", @@ -4408,6 +4433,11 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==" + }, "lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", diff --git a/web/package.json b/web/package.json index e2f03ed5fc..014e2de157 100644 --- a/web/package.json +++ b/web/package.json @@ -19,6 +19,7 @@ "@types/bcrypt": "^5.0.0", "@types/cookie": "^0.4.1", "@types/lodash": "^4.14.182", + "@types/lodash-es": "^4.17.6", "@typescript-eslint/eslint-plugin": "^5.10.1", "@typescript-eslint/parser": "^5.10.1", "autoprefixer": "^10.4.7", @@ -39,6 +40,7 @@ "dependencies": { "cookie": "^0.4.2", "lodash": "^4.17.21", + "lodash-es": "^4.17.21", "moment": "^2.29.3", "svelte-material-icons": "^2.0.2" } diff --git a/web/src/lib/stores/assets.ts b/web/src/lib/stores/assets.ts index 0e23e4c915..a9d922d8b9 100644 --- a/web/src/lib/stores/assets.ts +++ b/web/src/lib/stores/assets.ts @@ -1,17 +1,22 @@ import { writable, derived } from 'svelte/store'; import { getRequest } from '$lib/api'; import type { ImmichAsset } from '$lib/models/immich-asset' -import * as _ from 'lodash'; +import lodash from 'lodash-es'; import moment from 'moment'; const assets = writable([]); const assetsGroupByDate = derived(assets, ($assets) => { - return _.chain($assets) - .groupBy((a) => moment(a.createdAt).format('ddd, MMM DD')) - .sortBy((group) => $assets.indexOf(group[0])) - .value(); + try { + return lodash.chain($assets) + .groupBy((a) => moment(a.createdAt).format('ddd, MMM DD')) + .sortBy((group) => $assets.indexOf(group[0])) + .value(); + } catch (e) { + console.log("error deriving state assets", e) + return [] + } }) diff --git a/web/src/routes/__layout.svelte b/web/src/routes/__layout.svelte index e18101e3c7..c66405cb88 100644 --- a/web/src/routes/__layout.svelte +++ b/web/src/routes/__layout.svelte @@ -1,28 +1,27 @@
- + diff --git a/web/src/routes/photos/index.svelte b/web/src/routes/photos/index.svelte index 839e643f54..4cc585cb37 100644 --- a/web/src/routes/photos/index.svelte +++ b/web/src/routes/photos/index.svelte @@ -1,6 +1,5 @@