diff --git a/.devcontainer/.env b/.devcontainer/.env deleted file mode 100644 index 0450dc0805..0000000000 --- a/.devcontainer/.env +++ /dev/null @@ -1,22 +0,0 @@ -# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables - -# The location where your uploaded files are stored -UPLOAD_LOCATION=./library - -# The location where your database files are stored. Network shares are not supported for the database -DB_DATA_LOCATION=./postgres - -# To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List -# TZ=Etc/UTC - -# The Immich version to use. You can pin this to a specific version like "v1.71.0" -IMMICH_VERSION=release - -# Connection secret for postgres. You should change it to a random password -# Please use only the characters `A-Za-z0-9`, without special characters or spaces -DB_PASSWORD=postgres - -# The values below this line do not need to be changed -################################################################################### -DB_USERNAME=postgres -DB_DATABASE_NAME=immich diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index cb2420dd73..d4f190353c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,16 @@ { - "name": "Immich - Backend and Frontend", - "service": "immich-devcontainer-server", - "dockerComposeFile": ["server/docker-compose.yml"], + "name": "Immich - Backend, Frontend and ML", + "service": "immich-server", + "runServices": [ + "immich-server", + "redis", + "database", + "immich-machine-learning" + ], + "dockerComposeFile": [ + "../docker/docker-compose.dev.yml", + "./server/container-compose-overrides.yml" + ], "customizations": { "vscode": { "extensions": [ @@ -43,7 +52,7 @@ "overrideCommand": true, "workspaceFolder": "/workspaces/immich", "remoteUser": "node", - "postCreateCommand": "/immich-devcontainer/postCreate.sh", + "postCreateCommand": "/immich-devcontainer/container-server-post-create.sh", "userEnvProbe": "loginInteractiveShell", "remoteEnv": { // The location where your uploaded files are stored diff --git a/.devcontainer/ml/.env b/.devcontainer/ml/.env deleted file mode 100644 index ac973c1275..0000000000 --- a/.devcontainer/ml/.env +++ /dev/null @@ -1,19 +0,0 @@ -# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables - -# The location where your uploaded files are stored -UPLOAD_LOCATION=upload-volume - -# The location where your database files are stored -DB_DATA_LOCATION=db-volume - -# To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List -# TZ=Etc/UTC - -# Connection secret for postgres. You should change it to a random password -# Please use only the characters `A-Za-z0-9`, without special characters or spaces -DB_PASSWORD=postgres - -# The values below this line do not need to be changed -################################################################################### -DB_USERNAME=postgres -DB_DATABASE_NAME=immich diff --git a/.devcontainer/ml/devcontainer.json b/.devcontainer/ml/devcontainer.json deleted file mode 100644 index 3a60264d87..0000000000 --- a/.devcontainer/ml/devcontainer.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "Immich - Machine Learning", - "service": "immich-machine-learning", - "dockerComposeFile": ["docker-compose.yml"], - "customizations": { - "vscode": { - "extensions": [ - "ms-python.python","ms-python.debugpy","KevinRose.vsc-python-indent" - ] - } - }, - "forwardPorts": [], - "overrideCommand": true, - "workspaceFolder": "/workspaces/immich", - "remoteUser": "node" - -} diff --git a/.devcontainer/ml/docker-compose.yml b/.devcontainer/ml/docker-compose.yml deleted file mode 100644 index 314705afc9..0000000000 --- a/.devcontainer/ml/docker-compose.yml +++ /dev/null @@ -1,15 +0,0 @@ -services: - immich-machine-learning: - image: immich-machine-learning-dev:latest - build: - context: ../../machine-learning - dockerfile: Dockerfile - target: devcontainer - hostname: immich-machine-learning - volumes: - # bind mount host to /workspaces/immich - - ../..:/workspaces/immich - - model-cache:/cache - -volumes: - model-cache: diff --git a/.devcontainer/mobile/.env b/.devcontainer/mobile/.env deleted file mode 100644 index ac973c1275..0000000000 --- a/.devcontainer/mobile/.env +++ /dev/null @@ -1,19 +0,0 @@ -# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables - -# The location where your uploaded files are stored -UPLOAD_LOCATION=upload-volume - -# The location where your database files are stored -DB_DATA_LOCATION=db-volume - -# To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List -# TZ=Etc/UTC - -# Connection secret for postgres. You should change it to a random password -# Please use only the characters `A-Za-z0-9`, without special characters or spaces -DB_PASSWORD=postgres - -# The values below this line do not need to be changed -################################################################################### -DB_USERNAME=postgres -DB_DATABASE_NAME=immich diff --git a/.devcontainer/mobile/Dockerfile b/.devcontainer/mobile/Dockerfile deleted file mode 100644 index 9beb29748f..0000000000 --- a/.devcontainer/mobile/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -ARG BASEIMAGE=ghcr.io/immich-app/base-server-dev:202503182202@sha256:45ae044b64a7b518f8d94fa4de718090c1c7689d516ac2ac0976a5331eaeb396 -FROM ${BASEIMAGE} AS dev - -# Flutter SDK -# https://flutter.dev/docs/development/tools/sdk/releases?tab=linux -ENV FLUTTER_CHANNEL="stable" -ENV FLUTTER_VERSION="3.29.3" -ENV FLUTTER_HOME=/flutter -ENV PATH=${PATH}:${FLUTTER_HOME}/bin - -RUN apt-get install inetutils-ping sudo -RUN usermod -aG sudo node -RUN echo "node ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers -RUN mkdir -p /workspaces/immich -RUN chown node -R /workspaces - -# Flutter SDK -RUN mkdir -p ${FLUTTER_HOME} \ - && curl -C - --output flutter.tar.xz https://storage.googleapis.com/flutter_infra_release/releases/${FLUTTER_CHANNEL}/linux/flutter_linux_${FLUTTER_VERSION}-${FLUTTER_CHANNEL}.tar.xz \ - && tar -xf flutter.tar.xz --strip-components=1 -C ${FLUTTER_HOME} \ - && rm flutter.tar.xz \ - && chown -R node ${FLUTTER_HOME} - -USER node -RUN sudo apt-get update \ - && wget -qO- https://dcm.dev/pgp-key.public | sudo gpg --dearmor -o /usr/share/keyrings/dcm.gpg \ - && echo 'deb [signed-by=/usr/share/keyrings/dcm.gpg arch=amd64] https://dcm.dev/debian stable main' | sudo tee /etc/apt/sources.list.d/dart_stable.list \ - && sudo apt-get update \ - && sudo apt-get install dcm -y - -RUN dart --disable-analytics \ No newline at end of file diff --git a/.devcontainer/mobile/container-compose-overrides.yml b/.devcontainer/mobile/container-compose-overrides.yml new file mode 100644 index 0000000000..62a97a01eb --- /dev/null +++ b/.devcontainer/mobile/container-compose-overrides.yml @@ -0,0 +1,34 @@ +services: + immich-server: + build: + target: dev-container-mobile + environment: + - IMMICH_SERVER_URL=http://127.0.0.1:2283/ + volumes: !override # bind mount host to /workspaces/immich + - ..:/workspaces/immich + - cli_node_modules:/workspaces/immich/cli/node_modules + - e2e_node_modules:/workspaces/immich/e2e/node_modules + - open_api_node_modules:/workspaces/immich/open-api/typescript-sdk/node_modules + - server_node_modules:/workspaces/immich/server/node_modules + - web_node_modules:/workspaces/immich/web/node_modules + - ${UPLOAD_LOCATION}/photos:/workspaces/immich/server/upload + - ${UPLOAD_LOCATION}/photos/upload:/workspaces/immich/server/upload/upload + - /etc/localtime:/etc/localtime:ro + + database: + volumes: + - ${UPLOAD_LOCATION}/postgres:/var/lib/postgresql/data + +volumes: + # Node modules for each service to avoid conflicts and ensure consistent dependencies + cli_node_modules: + e2e_node_modules: + open_api_node_modules: + server_node_modules: + web_node_modules: + + # UPLOAD_LOCATION must be set to a absolute path or vol-upload + vol-upload: + + # DB_DATA_LOCATION must be set to a absolute path or vol-database + vol-database: diff --git a/.devcontainer/mobile/postCreate.sh b/.devcontainer/mobile/container-mobile-post-create.sh similarity index 95% rename from .devcontainer/mobile/postCreate.sh rename to .devcontainer/mobile/container-mobile-post-create.sh index 2c479da68b..674dba2c67 100755 --- a/.devcontainer/mobile/postCreate.sh +++ b/.devcontainer/mobile/container-mobile-post-create.sh @@ -1,5 +1,7 @@ #!/bin/bash +/immich-devcontainer/container-server-post-create.sh + # Enable multiarch for arm64 if necessary if [ "$(dpkg --print-architecture)" = "arm64" ]; then sudo dpkg --add-architecture amd64 && diff --git a/.devcontainer/mobile/devcontainer.json b/.devcontainer/mobile/devcontainer.json index a7c20f6189..a261986e28 100644 --- a/.devcontainer/mobile/devcontainer.json +++ b/.devcontainer/mobile/devcontainer.json @@ -1,14 +1,35 @@ { "name": "Immich - Mobile", - "service": "immich-mobile", - "dockerComposeFile": ["docker-compose.yml"], + "service": "immich-server", + "runServices": [ + "immich-server", + "redis", + "database", + "immich-machine-learning" + ], + "dockerComposeFile": [ + "../../docker/docker-compose.dev.yml", + "./container-compose-overrides.yml" + ], "customizations": { "vscode": { "extensions": [ "Dart-Code.dart-code", "Dart-Code.flutter", "dcmdev.dcm-vscode-extension", - "esbenp.prettier-vscode" + "esbenp.prettier-vscode", + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode", + "svelte.svelte-vscode", + "ms-vscode-remote.remote-containers", + "foxundermoon.shell-format", + "timonwong.shellcheck", + "rvest.vs-code-prettier-eslint", + "bluebrown.yamlfmt", + "vkrishna04.cspell-sync", + "vitest.explorer", + "ms-playwright.playwright", + "ms-azuretools.vscode-docker" ] } }, @@ -16,5 +37,25 @@ "overrideCommand": true, "workspaceFolder": "/workspaces/immich", "remoteUser": "node", - "postCreateCommand": "/workspaces/immich/.devcontainer/mobile/postCreate.sh" + "postCreateCommand": "/immich-devcontainer/container-mobile-post-create.sh", + "userEnvProbe": "loginInteractiveShell", + "remoteEnv": { + // The location where your uploaded files are stored + // If this starts with / or ./, it is a bind mount to a path + // on host. Otherwise, it must be the value "vol-upload" + // which is also the default loaded from .env. + "UPLOAD_LOCATION": "${localEnv:UPLOAD_LOCATION}", + // The location where your database files are stored. + // If this starts with / or ./, it is a bind mount to a path + // on host. Otherwise, it must be the value "vol-database" + // which is also the default loaded from .env. + "DB_DATA_LOCATION": "${localEnv:DB_DATA_LOCATION}", + // Connection secret for postgres. You should change it to a random password + // Please use only the characters `A-Za-z0-9`, without special characters or spaces + "DB_PASSWORD": "${localEnv:DB_PASSWORD}", + // The database username + "DB_USERNAME": "${localEnv:DB_USERNAME}", + // The database name + "DB_DATABASE_NAME": "${localEnv:DB_DATABASE_NAME}" + } } diff --git a/.devcontainer/mobile/docker-compose.yml b/.devcontainer/mobile/docker-compose.yml deleted file mode 100644 index ac8970da08..0000000000 --- a/.devcontainer/mobile/docker-compose.yml +++ /dev/null @@ -1,27 +0,0 @@ -services: - immich-mobile: - build: - dockerfile: Dockerfile - hostname: immich-devcontainer-mobile - extra_hosts: - - 'host.docker.internal:host-gateway' - volumes: - # by default, bind mount host to /workspaces/immich - - ../..:/workspaces/immich - - ./vscode:/workspaces/immich/.vscode - - cli_node_modules:/workspaces/immich/cli/node_modules - - e2e_node_modules:/workspaces/immich/e2e/node_modules - - open_api_node_modules:/workspaces/immich/open-api/typescript-sdk/node_modules - - server_node_modules:/workspaces/immich/server/node_modules - - web_node_modules:/workspaces/immich/web/node_modules - - ${UPLOAD_LOCATION}:/workspaces/immich/server/upload - -volumes: - cli_node_modules: - e2e_node_modules: - open_api_node_modules: - server_node_modules: - web_node_modules: - immich: - upload-volume: - db-volume: diff --git a/.devcontainer/server/.env b/.devcontainer/server/.env deleted file mode 100644 index 2d371d8cd9..0000000000 --- a/.devcontainer/server/.env +++ /dev/null @@ -1,14 +0,0 @@ -# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables - -# The location where your uploaded files are stored -UPLOAD_LOCATION=vol-upload - -# The location where your db files are stored -DB_DATA_LOCATION=vol-database - -# Connection secret for postgres. You should change it to a random password -DB_PASSWORD=postgres - -# The values below this line do not need to be changed -DB_USERNAME=postgres -DB_DATABASE_NAME=immich diff --git a/.devcontainer/server/common.sh b/.devcontainer/server/container-common.sh similarity index 100% rename from .devcontainer/server/common.sh rename to .devcontainer/server/container-common.sh diff --git a/.devcontainer/server/container-compose-overrides.yml b/.devcontainer/server/container-compose-overrides.yml new file mode 100644 index 0000000000..2e744ec062 --- /dev/null +++ b/.devcontainer/server/container-compose-overrides.yml @@ -0,0 +1,34 @@ +services: + immich-server: + build: + target: dev-container-server + environment: + - IMMICH_SERVER_URL=http://127.0.0.1:2283/ + volumes: !override # bind mount host to /workspaces/immich + - ..:/workspaces/immich + - cli_node_modules:/workspaces/immich/cli/node_modules + - e2e_node_modules:/workspaces/immich/e2e/node_modules + - open_api_node_modules:/workspaces/immich/open-api/typescript-sdk/node_modules + - server_node_modules:/workspaces/immich/server/node_modules + - web_node_modules:/workspaces/immich/web/node_modules + - ${UPLOAD_LOCATION}/photos:/workspaces/immich/server/upload + - ${UPLOAD_LOCATION}/photos/upload:/workspaces/immich/server/upload/upload + - /etc/localtime:/etc/localtime:ro + + database: + volumes: + - ${UPLOAD_LOCATION}/postgres:/var/lib/postgresql/data + +volumes: + # Node modules for each service to avoid conflicts and ensure consistent dependencies + cli_node_modules: + e2e_node_modules: + open_api_node_modules: + server_node_modules: + web_node_modules: + + # UPLOAD_LOCATION must be set to a absolute path or vol-upload + vol-upload: + + # DB_DATA_LOCATION must be set to a absolute path or vol-database + vol-database: diff --git a/.devcontainer/server/postCreate.sh b/.devcontainer/server/container-server-post-create.sh similarity index 100% rename from .devcontainer/server/postCreate.sh rename to .devcontainer/server/container-server-post-create.sh diff --git a/.devcontainer/server/startNestApiServer.sh b/.devcontainer/server/container-start-backend.sh similarity index 78% rename from .devcontainer/server/startNestApiServer.sh rename to .devcontainer/server/container-start-backend.sh index 2fc81a8060..5a9ffaa16c 100755 --- a/.devcontainer/server/startNestApiServer.sh +++ b/.devcontainer/server/container-start-backend.sh @@ -4,6 +4,8 @@ source /immich-devcontainer/common.sh echo "Starting Nest API Server" +echo +echo "Ignore errors while the postConfigure script is running which installs the node_modules dependncies" cd "${IMMICH_WORKSPACE}/server" || ( echo workspace not found diff --git a/.devcontainer/server/startViteWebServer.sh b/.devcontainer/server/container-start-frontend.sh similarity index 100% rename from .devcontainer/server/startViteWebServer.sh rename to .devcontainer/server/container-start-frontend.sh diff --git a/.devcontainer/server/docker-compose.yml b/.devcontainer/server/docker-compose.yml deleted file mode 100644 index 0135591841..0000000000 --- a/.devcontainer/server/docker-compose.yml +++ /dev/null @@ -1,71 +0,0 @@ -services: - - immich-devcontainer-server: - build: - dockerfile: server/Dockerfile - target: dev-container - context: ../.. - hostname: immich-devcontainer-server - extra_hosts: - - 'host.docker.internal:host-gateway' - environment: - - IMMICH_SERVER_URL=http://127.0.0.1:2283/ - - REDIS_PORT=6400 - - REDIS_HOSTNAME=immich-devcontainer-redis - - DB_PORT=5500 - - DB_HOSTNAME=immich-devcontainer-database - volumes: - # bind mount host to /workspaces/immich - - ../..:/workspaces/immich - - cli_node_modules:/workspaces/immich/cli/node_modules - - e2e_node_modules:/workspaces/immich/e2e/node_modules - - open_api_node_modules:/workspaces/immich/open-api/typescript-sdk/node_modules - - server_node_modules:/workspaces/immich/server/node_modules - - web_node_modules:/workspaces/immich/web/node_modules - - ${UPLOAD_LOCATION}:/workspaces/immich/server/upload - - immich-devcontainer-redis: - extends: - file: ../../docker/docker-compose.dev.yml - service: redis - container_name: immich-devcontainer-redis - command: redis-server --port 6400 - healthcheck: - test: redis-cli -p 6400 ping || exit 1 - - immich-devcontainer-database: - extends: - file: ../../docker/docker-compose.dev.yml - service: database - container_name: immich-devcontainer-database - env_file: - - .env - environment: - PGPORT: 5500 - POSTGRES_PASSWORD: ${DB_PASSWORD} - POSTGRES_USER: ${DB_USERNAME} - POSTGRES_DB: ${DB_DATABASE_NAME} - POSTGRES_INITDB_ARGS: '--data-checksums' - volumes: - - ${DB_DATA_LOCATION}:/var/lib/postgresql/data - ports: - - 5432:5432 - healthcheck: - test: >- - pg_isready --dbname="$${POSTGRES_DB}" --username="$${POSTGRES_USER}" || exit 1; Chksum="$$(psql --dbname="$${POSTGRES_DB}" --username="$${POSTGRES_USER}" --tuples-only --no-align --command='SELECT COALESCE(SUM(checksum_failures), 0) FROM pg_stat_database')"; echo "checksum failure count is $$Chksum"; [ "$$Chksum" = '0' ] || exit 1 - interval: 5m - start_period: 5m - command: >- - postgres -c shared_preload_libraries=vectors.so -c 'search_path="$$user", public, vectors' -c logging_collector=on -c max_wal_size=2GB -c shared_buffers=512MB -c wal_compression=on - -volumes: - cli_node_modules: - e2e_node_modules: - open_api_node_modules: - server_node_modules: - web_node_modules: - immich: - # UPLOAD_LOCATION must be set to a absolute path or vol-upload - vol-upload: - # DB_DATA_LOCATION must be set to a absolute path or vol-database - vol-database: diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 0010bd3d89..aa8ff5450a 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -4,7 +4,7 @@ { "label": "Immich API Server (Nest)", "type": "shell", - "command": "[ -f /immich-devcontainer/startNestApiServer.sh ] && /immich-devcontainer/startNestApiServer.sh || exit 0", + "command": "[ -f /immich-devcontainer/container-start-backend.sh ] && /immich-devcontainer/container-start-backend.sh || exit 0", "presentation": { "echo": true, "reveal": "always", @@ -23,7 +23,7 @@ { "label": "Immich Web Server (Vite)", "type": "shell", - "command": "[ -f /immich-devcontainer/startViteWebServer.sh ] && /immich-devcontainer/startViteWebServer.sh || exit 0", + "command": "[ -f /immich-devcontainer/container-start-frontend.sh ] && /immich-devcontainer/container-start-frontend.sh || exit 0", "presentation": { "echo": true, "reveal": "always", diff --git a/server/Dockerfile b/server/Dockerfile index 29c2f73cdc..5fc12fb055 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -16,23 +16,49 @@ ENV PATH="${PATH}:/usr/src/app/bin" \ NVIDIA_VISIBLE_DEVICES=all ENTRYPOINT ["tini", "--", "/bin/sh"] -FROM dev AS dev-container +FROM dev AS dev-container-server RUN apt-get update && \ apt-get install sudo inetutils-ping openjdk-11-jre-headless \ vim nano \ -y --no-install-recommends --fix-missing + RUN usermod -aG sudo node RUN echo "node ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers RUN mkdir -p /workspaces/immich RUN chown node -R /workspaces RUN mkdir /immich-devcontainer && chown node -R /immich-devcontainer -COPY --chmod=777 ../.devcontainer/server/common.sh /immich-devcontainer/common.sh -COPY --chmod=777 ../.devcontainer/server/postCreate.sh /immich-devcontainer/postCreate.sh -COPY --chmod=777 ../.devcontainer/server/startNestApiServer.sh /immich-devcontainer/startNestApiServer.sh -COPY --chmod=777 ../.devcontainer/server/startViteWebServer.sh /immich-devcontainer/startViteWebServer.sh +COPY --chmod=777 ../.devcontainer/server/container-common.sh /immich-devcontainer/common.sh +COPY --chmod=777 ../.devcontainer/server/container-server-post-create.sh /immich-devcontainer/container-server-post-create.sh +COPY --chmod=777 ../.devcontainer/server/container-start-backend.sh /immich-devcontainer/container-start-backend.sh +COPY --chmod=777 ../.devcontainer/server/container-start-frontend.sh /immich-devcontainer/container-start-frontend.sh +FROM dev-container-server AS dev-container-mobile +# Flutter SDK +# https://flutter.dev/docs/development/tools/sdk/releases?tab=linux +ENV FLUTTER_CHANNEL="stable" +ENV FLUTTER_VERSION="3.29.3" +ENV FLUTTER_HOME=/flutter +ENV PATH=${PATH}:${FLUTTER_HOME}/bin + +# Flutter SDK +RUN mkdir -p ${FLUTTER_HOME} \ + && curl -C - --output flutter.tar.xz https://storage.googleapis.com/flutter_infra_release/releases/${FLUTTER_CHANNEL}/linux/flutter_linux_${FLUTTER_VERSION}-${FLUTTER_CHANNEL}.tar.xz \ + && tar -xf flutter.tar.xz --strip-components=1 -C ${FLUTTER_HOME} \ + && rm flutter.tar.xz \ + && chown -R node ${FLUTTER_HOME} + +USER node +RUN sudo apt-get update \ + && wget -qO- https://dcm.dev/pgp-key.public | sudo gpg --dearmor -o /usr/share/keyrings/dcm.gpg \ + && echo 'deb [signed-by=/usr/share/keyrings/dcm.gpg arch=amd64] https://dcm.dev/debian stable main' | sudo tee /etc/apt/sources.list.d/dart_stable.list \ + && sudo apt-get update \ + && sudo apt-get install dcm -y + +COPY --chmod=777 ../.devcontainer/mobile/container-mobile-post-create.sh /immich-devcontainer/container-mobile-post-create.sh + +RUN dart --disable-analytics FROM dev AS prod