Ubuntu Server 24.04 に immich を入れてみる備忘録 その2
この記事について
この記事は
この記事の続きです
マルチユーザーテスト
2つ目のユーザーを作成
# Web UIで2つ目のユーザーを作成 # Administration → Users → Create User # ユーザー情報: # - Email: user2@test.local # - Name: Test User 2 # - Password: (任意) # icrdyptsa6yd9t4u

ユーザーを作った
管理者ならこんな画面も見えるらしい

データベースで確認
# ユーザー数を確認 docker exec -i immich_postgres psql -U postgres immich << EOF SELECT id, email, name FROM "user"; EOF # 期待される結果: # 2行表示される(admin@example.com, user2@example.com)
結果
ope@feeld0:~/immich$ docker exec -i immich_postgres psql -U postgres immich << EOF SELECT id, email, name FROM "user"; EOF id | email | name --------------------------------------+-------------------+------------- 87aeec34-156f-4f21-838e-50bd66240c08 | admin@example.com | testAdmin ca276223-8ccb-461f-bcbb-de498b420b9c | user2@test.local | Test User 2 (2 rows) ope@feeld0:~/immich$
ユーザーごとのデータ分離確認
# 1. user2でログイン # 2. 写真をアップロード # 3. ディレクトリを確認 ls -lh ~/immich/library/upload/ # 期待される結果: # ~/immich/library/upload/<admin-uuid>/ # ~/immich/library/upload/<user2-uuid>/ # → ユーザーごとにディレクトリが分離されている

適当にファイルをアップロード

ope@feeld0:~/immich$ ls -lh ~/immich/library/upload/ total 0 drwxr-xr-x 1 root root 44 Feb 9 22:13 87aeec34-156f-4f21-838e-50bd66240c08 drwxr-xr-x 1 root root 8 Feb 15 19:16 ca276223-8ccb-461f-bcbb-de498b420b9c ope@feeld0:~/immich$
id でディレクトリができるんだね
# ユーザーごとのasset数を確認 docker exec -i immich_postgres psql -U postgres immich << EOF SELECT u.email, u.name, COUNT(a.id) as asset_count FROM "user" u LEFT JOIN asset a ON u.id = a."ownerId" GROUP BY u.id, u.email, u.name ORDER BY u.email; EOF
期待される結果:
email | name | asset_count -------------------+-------------+------------- admin@example.com | testAdmin | 8 user2@test.local | Test User 2 | 2-3
アセット数
ope@feeld0:~/immich$ docker exec -i immich_postgres psql -U postgres immich << EOF SELECT u.email, u.name, COUNT(a.id) as asset_count FROM "user" u LEFT JOIN asset a ON u.id = a."ownerId" GROUP BY u.id, u.email, u.name ORDER BY u.email; EOF email | name | asset_count -------------------+-------------+------------- admin@example.com | testAdmin | 8 user2@test.local | Test User 2 | 2 (2 rows) ope@feeld0:~/immich$

使用量の変化が見て取れる
ファイルシステムレベルの確認
# user2のファイルを確認 ls -lh ~/immich/library/upload/ca276223-8ccb-461f-bcbb-de498b420b9c/ # adminのファイルと比較 ls -lh ~/immich/library/upload/87aeec34-156f-4f21-838e-50bd66240c08/ | wc -l ls -lh ~/immich/library/upload/ca276223-8ccb-461f-bcbb-de498b420b9c/ | wc -l # thumbsディレクトリも確認 ls ~/immich/library/thumbs/
結果
ope@feeld0:~/immich$ ls -lh ~/immich/library/upload/ca276223-8ccb-461f-bcbb-de498b420b9c/ total 0 drwxr-xr-x 1 root root 4 Feb 15 19:16 0a drwxr-xr-x 1 root root 4 Feb 15 19:16 77 ope@feeld0:~/immich$ ope@feeld0:~/immich$ ls -lh ~/immich/library/upload/87aeec34-156f-4f21-838e-50bd66240c08/ | wc -l 12 ope@feeld0:~/immich$ ope@feeld0:~/immich$ ls -lh ~/immich/library/upload/ca276223-8ccb-461f-bcbb-de498b420b9c/ | wc -l 3 ope@feeld0:~/immich$ ope@feeld0:~/immich$ ls ~/immich/library/thumbs/ 87aeec34-156f-4f21-838e-50bd66240c08 ca276223-8ccb-461f-bcbb-de498b420b9c ope@feeld0:~/immich$
ユーザーごとに分離されているね
アルバム共有のテスト
# 1. adminでログイン # http://<VMのIPアドレス>:2283 # 2. アルバムを作成 # Albums → Create Album # 名前: "Shared Album" # 写真を2-3枚追加 # 3. アルバムを共有 # アルバムを開く → 右上の共有アイコン → Add User # user2@test.local を選択 # 4. user2でログイン # Albums を確認 → "Shared Album" が表示されるか? # 5. データベースで確認 docker exec -i immich_postgres psql -U postgres immich << EOF SELECT a.id, a."albumName", u.email as owner_email, au."userId" as shared_with_user FROM album a JOIN "user" u ON a."ownerId" = u.id LEFT JOIN album_user au ON a.id = au."albumId" ORDER BY a."createdAt"; EOF

ope@feeld0:~/immich$ docker exec -i immich_postgres psql -U postgres immich << EOF SELECT a.id, a."albumName", u.email as owner_email, au."userId" as shared_with_user FROM album a JOIN "user" u ON a."ownerId" = u.id LEFT JOIN album_user au ON a.id = au."albumId" ORDER BY a."createdAt"; EOF id | albumName | owner_email | shared_with_user --------------------------------------+------------+-------------------+-------------------------------------- e093fb38-7f66-4acf-81c9-22768de5109c | test album | admin@example.com | ca276223-8ccb-461f-bcbb-de498b420b9c (1 row) ope@feeld0:~/immich$
データベース上でもシェアされていることが分かった。
調査はこのあたりで切り上げていいかな?