mirror of
https://github.com/immich-app/immich.git
synced 2025-05-24 01:12:58 -04:00
feat(cli): dockerize (#6858)
* import dockerfile from old cli * build works * rename login command * bump packages * fix login command * chore: remove axios dependency from CLI * move immich script path * can build docker * wip * wip * don't externalize sdk * can run docker * improve entrypoint * can save auth state between runs * add docs * clarify reqs * fix lint * bump alpine to 3.19 * add env files for api key * remove immich cli GHA for now * Update docs/docs/features/command-line-interface.md Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> * remove redundant env variable check * cleanup * speling --------- Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
This commit is contained in:
parent
9b3764dbcf
commit
31eb4790dc
3
.github/workflows/docker.yml
vendored
3
.github/workflows/docker.yml
vendored
@ -44,7 +44,7 @@ jobs:
|
|||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
device: openvino
|
device: openvino
|
||||||
suffix: -openvino
|
suffix: -openvino
|
||||||
|
|
||||||
- image: immich-machine-learning
|
- image: immich-machine-learning
|
||||||
context: machine-learning
|
context: machine-learning
|
||||||
file: machine-learning/Dockerfile
|
file: machine-learning/Dockerfile
|
||||||
@ -57,6 +57,7 @@ jobs:
|
|||||||
file: server/Dockerfile
|
file: server/Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
device: cpu
|
device: cpu
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
FROM ghcr.io/immich-app/base-server-dev:20240130@sha256:a11ac5c56f0ccce1f218954c07c43caadf489557252ba5b9ca1c5977aaa25999 as test
|
FROM node:20-alpine3.19 as core
|
||||||
|
|
||||||
WORKDIR /usr/src/app/server
|
WORKDIR /usr/src/open-api/typescript-sdk
|
||||||
COPY server/package.json server/package-lock.json ./
|
COPY open-api/typescript-sdk/package*.json open-api/typescript-sdk/tsconfig*.json ./
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
COPY ./server/ .
|
COPY open-api/typescript-sdk/ ./
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
WORKDIR /usr/src/app/cli
|
|
||||||
COPY cli/package.json cli/package-lock.json ./
|
COPY cli/package.json cli/package-lock.json ./
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
COPY ./cli/ .
|
|
||||||
|
|
||||||
FROM ghcr.io/immich-app/base-server-prod:20240130@sha256:ce23a32154540b906df3c971766bcd991561c60331794e0ebb780947ac48113f
|
COPY cli .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
VOLUME /usr/src/app/upload
|
WORKDIR /import
|
||||||
|
|
||||||
EXPOSE 3001
|
ENTRYPOINT ["node", "/usr/src/app/dist"]
|
||||||
|
|
||||||
ENTRYPOINT ["tini", "--", "/bin/sh"]
|
|
18
cli/package-lock.json
generated
18
cli/package-lock.json
generated
@ -9,7 +9,7 @@
|
|||||||
"version": "2.0.7",
|
"version": "2.0.7",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
"immich": "dist/src/index.js"
|
"immich": "dist/index.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@immich/sdk": "file:../open-api/typescript-sdk",
|
"@immich/sdk": "file:../open-api/typescript-sdk",
|
||||||
@ -23,7 +23,7 @@
|
|||||||
"@vitest/coverage-v8": "^1.2.2",
|
"@vitest/coverage-v8": "^1.2.2",
|
||||||
"byte-size": "^8.1.1",
|
"byte-size": "^8.1.1",
|
||||||
"cli-progress": "^3.12.0",
|
"cli-progress": "^3.12.0",
|
||||||
"commander": "^11.0.0",
|
"commander": "^12.0.0",
|
||||||
"eslint": "^8.56.0",
|
"eslint": "^8.56.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-prettier": "^5.1.3",
|
"eslint-plugin-prettier": "^5.1.3",
|
||||||
@ -2229,12 +2229,12 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/commander": {
|
"node_modules/commander": {
|
||||||
"version": "11.1.0",
|
"version": "12.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/commander/-/commander-12.0.0.tgz",
|
||||||
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
|
"integrity": "sha512-MwVNWlYjDTtOjX5PiD7o5pK0UrFU/OYgcJfjjK4RaHZETNtjJqrZa9Y9ds88+A+f+d5lv+561eZ+yCKoS3gbAA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16"
|
"node": ">=18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/compress-commons": {
|
"node_modules/compress-commons": {
|
||||||
@ -7078,9 +7078,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"commander": {
|
"commander": {
|
||||||
"version": "11.1.0",
|
"version": "12.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/commander/-/commander-12.0.0.tgz",
|
||||||
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
|
"integrity": "sha512-MwVNWlYjDTtOjX5PiD7o5pK0UrFU/OYgcJfjjK4RaHZETNtjJqrZa9Y9ds88+A+f+d5lv+561eZ+yCKoS3gbAA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"compress-commons": {
|
"compress-commons": {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": "./dist/index.js",
|
"exports": "./dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"immich": "./dist/src/index.js"
|
"immich": "./dist/index.js"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@ -24,7 +24,7 @@
|
|||||||
"@vitest/coverage-v8": "^1.2.2",
|
"@vitest/coverage-v8": "^1.2.2",
|
||||||
"byte-size": "^8.1.1",
|
"byte-size": "^8.1.1",
|
||||||
"cli-progress": "^3.12.0",
|
"cli-progress": "^3.12.0",
|
||||||
"commander": "^11.0.0",
|
"commander": "^12.0.0",
|
||||||
"eslint": "^8.56.0",
|
"eslint": "^8.56.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-prettier": "^5.1.3",
|
"eslint-plugin-prettier": "^5.1.3",
|
||||||
|
@ -3,19 +3,22 @@ import { Command, Option } from 'commander';
|
|||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import os from 'node:os';
|
import os from 'node:os';
|
||||||
import { version } from '../package.json';
|
import { version } from '../package.json';
|
||||||
import { LoginCommand } from './commands/login';
|
import { LoginCommand } from './commands/login.command';
|
||||||
import { LogoutCommand } from './commands/logout.command';
|
import { LogoutCommand } from './commands/logout.command';
|
||||||
import { ServerInfoCommand } from './commands/server-info.command';
|
import { ServerInfoCommand } from './commands/server-info.command';
|
||||||
import { UploadCommand } from './commands/upload.command';
|
import { UploadCommand } from './commands/upload.command';
|
||||||
|
|
||||||
const homeDirectory = os.homedir();
|
const defaultConfigDirectory = path.join(os.homedir(), '.config/immich/');
|
||||||
const configDirectory = path.join(homeDirectory, '.config/immich/');
|
|
||||||
|
|
||||||
const program = new Command()
|
const program = new Command()
|
||||||
.name('immich')
|
.name('immich')
|
||||||
.version(version)
|
.version(version)
|
||||||
.description('Command line interface for Immich')
|
.description('Command line interface for Immich')
|
||||||
.addOption(new Option('-d, --config', 'Configuration directory').env('IMMICH_CONFIG_DIR').default(configDirectory));
|
.addOption(
|
||||||
|
new Option('-d, --config-directory', 'Configuration directory where auth.yml will be stored')
|
||||||
|
.env('IMMICH_CONFIG_DIR')
|
||||||
|
.default(defaultConfigDirectory),
|
||||||
|
);
|
||||||
|
|
||||||
program
|
program
|
||||||
.command('upload')
|
.command('upload')
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { restoreTempFolder, testApp } from '@test-utils';
|
import { restoreTempFolder, testApp } from '@test-utils';
|
||||||
import { CLI_BASE_OPTIONS, TEST_AUTH_FILE, deleteAuthFile, setup, spyOnConsole } from 'test/cli-test-utils';
|
import { CLI_BASE_OPTIONS, TEST_AUTH_FILE, deleteAuthFile, setup, spyOnConsole } from 'test/cli-test-utils';
|
||||||
import { readFile, stat } from 'node:fs/promises';
|
import { readFile, stat } from 'node:fs/promises';
|
||||||
import { LoginCommand } from '../../src/commands/login';
|
import { LoginCommand } from '../../src/commands/login.command';
|
||||||
import yaml from 'yaml';
|
import yaml from 'yaml';
|
||||||
|
|
||||||
describe(`login-key (e2e)`, () => {
|
describe(`login-key (e2e)`, () => {
|
||||||
@ -58,7 +58,6 @@ describe(`login-key (e2e)`, () => {
|
|||||||
await new LoginCommand(CLI_BASE_OPTIONS).run(instanceUrl, apiKey);
|
await new LoginCommand(CLI_BASE_OPTIONS).run(instanceUrl, apiKey);
|
||||||
|
|
||||||
const stats = await stat(TEST_AUTH_FILE);
|
const stats = await stat(TEST_AUTH_FILE);
|
||||||
|
|
||||||
const mode = (stats.mode & 0o777).toString(8);
|
const mode = (stats.mode & 0o777).toString(8);
|
||||||
|
|
||||||
expect(mode).toEqual('600');
|
expect(mode).toEqual('600');
|
||||||
|
@ -15,10 +15,12 @@ If you are looking to import your Google Photos takeout, we recommend this commu
|
|||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- Node.js 20.0 or above
|
- Node.js 20 or above
|
||||||
- Npm
|
- Npm
|
||||||
|
|
||||||
## Installation
|
If you can't install node/npm, there is also a Docker version available below.
|
||||||
|
|
||||||
|
## Installation (NPM)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm i -g @immich/cli
|
npm i -g @immich/cli
|
||||||
@ -30,6 +32,16 @@ NOTE: if you previously installed the legacy CLI, you will need to uninstall it
|
|||||||
npm uninstall -g immich
|
npm uninstall -g immich
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Installation (Docker)
|
||||||
|
|
||||||
|
If npm is not available on your system you can try the Docker version
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -it -v "$(pwd)":/import:ro -e IMMICH_API_KEY=https://your-immich-instance/api -e IMMICH_API_KEY=your-api-key ghcr.io/immich-app/immich-cli:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
Please modify the `IMMICH_INSTANCE_URL` and `IMMICH_API_KEY` environment variables as suitable. You can also use a Docker env file to store your sensitive API key.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user