immich-app / immich

High performance self-hosted photo and video management solution.
https://immich.app
GNU Affero General Public License v3.0
51.08k stars 2.7k forks source link

Issue syncing with the CLI tool. #2992

Closed mandraid closed 1 year ago

mandraid commented 1 year ago

The bug

I am following the instructions here: https://immich.app/docs/features/read-only-gallery. This is the output I get: Error asset: { file: '/shared/20160424_131540065.jpg', reason: Error: Request failed with status code 400 at createError (/usr/lib/node_modules/immich/node_modules/axios/lib/core/createError.js:16:15) at settle (/usr/lib/node_modules/immich/node_modules/axios/lib/core/settle.js:17:12) at IncomingMessage.handleStreamEnd (/usr/lib/node_modules/immich/node_modules/axios/lib/adapters/http.js:322:11) at IncomingMessage.emit (node:events:525:35) at endReadableNT (node:internal/streams/readable:1358:12) at processTicksAndRejections (node:internal/process/task_queues:83:21) { config: { transitional: [Object], adapter: [Function: httpAdapter], transformRequest: [Array], transformResponse: [Array], timeout: 0, xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: Infinity, maxBodyLength: Infinity, validateStatus: [Function: validateStatus], headers: [Object], method: 'post', maxRedirects: 0, url: 'http://192.168.1.130:2283/api/asset/import', data: '{"deviceAssetId":"20160424_131540065.jpg-1099257","deviceId":"426749e253ef44b3b72ac1cfb71f1824","assetType":"IMAGE","fileCreatedAt":"2016-04-24T17:15:40.000Z","fileModifiedAt":"2016-04-24T17:15:40.000Z","isFavorite":"false","fileExtension":".jpg","duration":"0:00:00.000000","isReadOnly":"true","assetPath":"/shared/20160424_131540065.jpg"}' }, request: ClientRequest { _events: [Object: null prototype], _eventsCount: 3, _maxListeners: undefined, outputData: [], outputSize: 0, writable: true, destroyed: false, _last: true, chunkedEncoding: false, shouldKeepAlive: false, maxRequestsOnConnectionReached: false, _defaultKeepAlive: true, useChunkedEncodingByDefault: true, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, strictContentLength: false, _contentLength: 340, _hasBody: true, _trailer: '', finished: true, _headerSent: true, _closed: false, socket: [Socket], _header: 'POST /api/asset/import HTTP/1.1\r\n' + 'Accept: application/json, text/plain, /\r\n' + 'Content-Type: application/json\r\n' + 'x-api-key: \r\n' + 'User-Agent: axios/0.26.1\r\n' + 'Content-Length: 340\r\n' + 'Host: 192.168.1.130:2283\r\n' + 'Connection: close\r\n' + '\r\n', _keepAliveTimeout: 0, _onPendingData: [Function: nop], agent: [Agent], socketPath: undefined, method: 'POST', maxHeaderSize: undefined, insecureHTTPParser: undefined, path: '/api/asset/import', _ended: true, res: [IncomingMessage], aborted: false, timeoutCb: null, upgradeOrConnect: false, parser: null, maxHeadersCount: null, reusedSocket: false, host: '192.168.1.130', protocol: 'http:',

  [Symbol(kBytesWritten)]: 0,
  [Symbol(kEndCalled)]: true,
  [Symbol(kNeedDrain)]: false,
  [Symbol(corked)]: 0,
  [Symbol(kOutHeaders)]: [Object: null prototype],
  [Symbol(kUniqueHeaders)]: null
},
response: {
  status: 400,
  statusText: 'Bad Request',
  headers: [Object],
  config: [Object],
  request: [ClientRequest],
  data: [Object]
},
isAxiosError: true,
toJSON: [Function: toJSON]

}, response: { statusCode: 400, message: 'File does not exist', error: 'Bad Request' } }

The OS that Immich Server is running on

Ubuntu 22.04

Version of Immich Server

1.64.0

Version of Immich Mobile App

1.64.0

Platform with the issue

Your docker-compose.yml content

version: "3.8"

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    command: ["start-server.sh"]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /shared:/mnt/media/shared
    env_file:
      - .env
    depends_on:
      - redis
      - database
      - typesense
    restart: always

  immich-microservices:
    container_name: immich_microservices
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    command: ["start-microservices.sh"]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /shared:/mnt/media/shared
    env_file:
      - .env
    depends_on:
      - redis
      - database
      - typesense
    restart: always

  immich-machine-learning:
    container_name: immich_machine_learning
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - model-cache:/cache
    env_file:
      - .env
    restart: always

  immich-web:
    container_name: immich_web
    image: ghcr.io/immich-app/immich-web:${IMMICH_VERSION:-release}
    env_file:
      - .env
    restart: always

  typesense:
    container_name: immich_typesense
    image: typesense/typesense:0.24.0
    environment:
      - TYPESENSE_API_KEY=${TYPESENSE_API_KEY}
      - TYPESENSE_DATA_DIR=/data
    logging:
      driver: none
    volumes:
      - tsdata:/data
    restart: always

  redis:
    container_name: immich_redis
    image: redis:6.2
    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
    restart: always

  immich-proxy:
    container_name: immich_proxy
    image: ghcr.io/immich-app/immich-proxy:${IMMICH_VERSION:-release}
    environment:
      # Make sure these values get passed through from the env file
      - IMMICH_SERVER_URL
      - IMMICH_WEB_URL
    ports:
      - 2283:8080
    depends_on:
      - immich-server
    restart: always

volumes:
  pgdata:
  model-cache:
  tsdata:

Your .env content

###################################################################################
# Database
###################################################################################

# NOTE: The following four database variables support Docker secrets by adding a *_FILE suffix to the variable name
# See the docker-compose documentation on secrets for additional details: https://docs.docker.com/compose/compose-file/compose-file-v3/#secrets
DB_HOSTNAME=immich_postgres
DB_USERNAME=postgres
DB_PASSWORD=<redacted>
DB_DATABASE_NAME=immich

# Optional Database settings:
# DB_PORT=5432

###################################################################################
# Redis
###################################################################################

REDIS_HOSTNAME=immich_redis

# REDIS_URL will be used to pass custom options to ioredis.
# Example for Sentinel
# {"sentinels":[{"host":"redis-sentinel-node-0","port":26379},{"host":"redis-sentinel-node-1","port":26379},{"host":"redis-sentinel-node-2","port":26379}],"name":"redis-sentinel"}
# REDIS_URL=ioredis://<redacted>=

# Optional Redis settings:

# Note: these parameters are not automatically passed to the Redis Container
# to do so, please edit the docker-compose.yml file as well. Redis is not configured
# via environment variables, only redis.conf or the command line

# REDIS_PORT=6379
# REDIS_DBINDEX=0
# REDIS_USERNAME=
# REDIS_PASSWORD=
# REDIS_SOCKET=

###################################################################################
# Upload File Location
#
# This is the location where uploaded files are stored.
###################################################################################

UPLOAD_LOCATION=/home/<redacted>/immich-images

###################################################################################
# Typesense
###################################################################################
TYPESENSE_API_KEY=some-random-text
# TYPESENSE_ENABLED=false
# TYPESENSE_URL uses base64 encoding for the nodes json.
# Example JSON that was used:
# [
#      { 'host': 'typesense-1.example.net', 'port': '443', 'protocol': 'https' },
#      { 'host': 'typesense-2.example.net', 'port': '443', 'protocol': 'https' },
#      { 'host': 'typesense-3.example.net', 'port': '443', 'protocol': 'https' },
#  ]
# TYPESENSE_URL=ha:/<redacted>

###################################################################################
# Reverse Geocoding
#
# Reverse geocoding is done locally which has a small impact on memory usage
# This memory usage can be altered by changing the REVERSE_GEOCODING_PRECISION variable
# This ranges from 0-3 with 3 being the most precise
# 3 - Cities > 500 population: ~200MB RAM
# 2 - Cities > 1000 population: ~150MB RAM
# 1 - Cities > 5000 population: ~80MB RAM
# 0 - Cities > 15000 population: ~40MB RAM
####################################################################################

# DISABLE_REVERSE_GEOCODING=false
# REVERSE_GEOCODING_PRECISION=3

####################################################################################
# WEB - Optional
#
# Custom message on the login page, should be written in HTML form.
# For example:
# PUBLIC_LOGIN_PAGE_MESSAGE="This is a demo instance of Immich.<br><br>Email: <i>demo@demo.de</i><br>Password: <i>demo</i>"
####################################################################################

PUBLIC_LOGIN_PAGE_MESSAGE=

####################################################################################
# Alternative Service Addresses - Optional
#
# This is an advanced feature for users who may be running their immich services on different hosts.
# It will not change which address or port that services bind to within their containers, but it will change where other services look for their peers.
# Note: immich-microservices is bound to 3002, but no references are made
####################################################################################

IMMICH_WEB_URL=http://immich-web:3000
IMMICH_SERVER_URL=http://immich-server:3001
IMMICH_MACHINE_LEARNING_URL=http://immich-machine-learning:3003

####################################################################################
# Alternative API's External Address - Optional
#
# This is an advanced feature used to control the public server endpoint returned to clients during Well-known discovery.
# You should only use this if you want mobile apps to access the immich API over a custom URL. Do not include trailing slash.
# NOTE: At this time, the web app will not be affected by this setting and will continue to use the relative path: /api
# Examples: http://localhost:3001, http://immich-api.example.com, etc
####################################################################################

#IMMICH_API_URL_EXTERNAL=http://localhost:3001

###################################################################################
# Immich Version - Optional
#
# This allows all immich docker images to be pinned to a specific version. By default,
# the version is "release" but could be a specific version, like "v1.59.0".
###################################################################################

#IMMICH_VERSION=

Reproduction steps

1. Run this command:  immich upload --key <key> --server http://192.168.1.130:2283/api /shared --recursive --import

Additional information

No response

alextran1502 commented 1 year ago

Hello image

So the mount point has to be - /shared:/shared

mandraid commented 1 year ago

I'm not sure why this was closed. It was never confirmed to fix the issue, as is the case.

jrasm91 commented 1 year ago

Your volume mount is wrong and the error you are getting is expected given your setup.

If you updated it to /shared:/shared and get the same issue, please post update details after reading through the docs on the feature again.

mandraid commented 1 year ago

Here's the error message I am receiving: `Error asset: { file: '/shared/20160424_131545905.jpg', reason: Error: Request failed with status code 400 at createError (/usr/lib/node_modules/immich/node_modules/axios/lib/core/createError.js:16:15) at settle (/usr/lib/node_modules/immich/node_modules/axios/lib/core/settle.js:17:12) at IncomingMessage.handleStreamEnd (/usr/lib/node_modules/immich/node_modules/axios/lib/adapters/http.js:322:11) at IncomingMessage.emit (node:events:525:35) at endReadableNT (node:internal/streams/readable:1358:12) at processTicksAndRejections (node:internal/process/task_queues:83:21) { config: { transitional: [Object], adapter: [Function: httpAdapter], transformRequest: [Array], transformResponse: [Array], timeout: 0, xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: Infinity, maxBodyLength: Infinity, validateStatus: [Function: validateStatus], headers: [Object], method: 'post', maxRedirects: 0, url: 'http://192.168.1.130:2283/api/asset/import', data: '{"deviceAssetId":"20160424_131545905.jpg-995328","deviceId":"426749e253ef44b3b72ac1cfb71f1824","assetType":"IMAGE","fileCreatedAt":"2016-04-24T17:15:46.000Z","fileModifiedAt":"2016-04-24T17:15:46.000Z","isFavorite":"false","fileExtension":".jpg","duration":"0:00:00.000000","isReadOnly":"true","assetPath":"/shared/20160424_131545905.jpg"}' }, request: ClientRequest { _events: [Object: null prototype], _eventsCount: 3, _maxListeners: undefined, outputData: [], outputSize: 0, writable: true, destroyed: false, _last: true, chunkedEncoding: false, shouldKeepAlive: false, maxRequestsOnConnectionReached: false, _defaultKeepAlive: true, useChunkedEncodingByDefault: true, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, strictContentLength: false, _contentLength: 339, _hasBody: true, _trailer: '', finished: true, _headerSent: true, _closed: false, socket: [Socket], _header: 'POST /api/asset/import HTTP/1.1\r\n' + 'Accept: application/json, text/plain, /\r\n' + 'Content-Type: application/json\r\n' + 'x-api-key: \r\n' + 'User-Agent: axios/0.26.1\r\n' + 'Content-Length: 339\r\n' + 'Host: 192.168.1.130:2283\r\n' + 'Connection: close\r\n' + '\r\n', _keepAliveTimeout: 0, _onPendingData: [Function: nop], agent: [Agent], socketPath: undefined, method: 'POST', maxHeaderSize: undefined, insecureHTTPParser: undefined, path: '/api/asset/import', _ended: true, res: [IncomingMessage], aborted: false, timeoutCb: null, upgradeOrConnect: false, parser: null, maxHeadersCount: null, reusedSocket: false, host: '192.168.1.130', protocol: 'http:',

  [Symbol(kBytesWritten)]: 0,
  [Symbol(kEndCalled)]: true,
  [Symbol(kNeedDrain)]: false,
  [Symbol(corked)]: 0,
  [Symbol(kOutHeaders)]: [Object: null prototype],
  [Symbol(kUniqueHeaders)]: null
},
response: {
  status: 400,
  statusText: 'Bad Request',
  headers: [Object],
  config: [Object],
  request: [ClientRequest],
  data: [Object]
},
isAxiosError: true,
toJSON: [Function: toJSON]

}, response: { statusCode: 400, message: 'File does not exist', error: 'Bad Request' } ` I've confirmed there are images in the /shared directory on the host.

jrasm91 commented 1 year ago

Please send your updated docker-compose file.

mandraid commented 1 year ago

version: "3.8"

services: immich-server: container_name: immich_server image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release} command: ["start-server.sh"] volumes:

volumes: pgdata: model-cache: tsdata:

jrasm91 commented 1 year ago

Can you post the output of ls -l /shared/20160424_131545905.jpg run from inside the immich-server container?

mandraid commented 1 year ago

It doesn't look like the shared directory is getting created there.

jrasm91 commented 1 year ago

That sounds like a problem with your volume mount not working. Or you haven't successfully applied the configuration to the running stack after changing the docker-compose file.

mandraid commented 1 year ago

I used the immich cli tool as mentioned. Also, the /shared drive is populating. I am not sure where else to look.

jrasm91 commented 1 year ago

Is /shared correctly showing in the container?

mandraid commented 1 year ago

It is not.

jrasm91 commented 1 year ago

This is not an immich problem and I'm not sure how to help you without more details about your underlying system. A docker volume not mounting more than likely implies a misconfiguration or an unsupported filesystem type. Is there something different about this mount than your upload location one?

mandraid commented 1 year ago

The underlying FS is RAID10, and mounted as read-only to the host machine.

mandraid commented 1 year ago

It's now working. After updating the docker compose file, I had to re-issue the docker compose up -d command.

Typhonragewind commented 1 year ago

I'm having this issue as well. i made sure mount paths are exactly the same and confirmed that files are appearing inside both server and microservices containers with proper permissions. Tried with both CLI docker and the embedded version inside the microservice and server containers. It sucessfully detects all the files but then generates the 400 error for each one of them.

Edit: Also made sure to properly set the external path in Immich settings for my account