Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): dockerize #6858

Merged
merged 33 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a7f17a7
import dockerfile from old cli
etnoy Feb 2, 2024
2ee5b45
build works
etnoy Feb 2, 2024
e7ef7a7
rename login command
etnoy Feb 2, 2024
c774c82
bump packages
etnoy Feb 2, 2024
6a3a165
fix login command
etnoy Feb 3, 2024
e0201ba
Merge branch 'main' of https://github.com/immich-app/immich into cli/…
etnoy Feb 3, 2024
28301bf
chore: remove axios dependency from CLI
benmccann Feb 4, 2024
c05254b
move immich script path
etnoy Feb 5, 2024
cd86480
Merge branch 'main' of https://github.com/immich-app/immich into cli/…
etnoy Feb 5, 2024
b79a9fa
can build docker
etnoy Feb 5, 2024
c45632d
Merge branch 'rm-axios-cli' of https://github.com/benmccann/immich in…
etnoy Feb 5, 2024
3d7bb1b
wip
etnoy Feb 5, 2024
33c477a
wip
etnoy Feb 5, 2024
45f675e
don't externalize sdk
etnoy Feb 5, 2024
58b5824
can run docker
etnoy Feb 5, 2024
42bea69
Merge branch 'main' of https://github.com/immich-app/immich into cli/…
etnoy Feb 5, 2024
3c5cafd
Merge branch 'main' of https://github.com/immich-app/immich into cli/…
etnoy Feb 5, 2024
4a176b7
improve entrypoint
etnoy Feb 5, 2024
4793f9a
can save auth state between runs
etnoy Feb 5, 2024
2aa4337
add docs
etnoy Feb 5, 2024
7b656fd
clarify reqs
etnoy Feb 5, 2024
5cb2fad
fix lint
etnoy Feb 5, 2024
653cbb1
bump alpine to 3.19
etnoy Feb 5, 2024
4bb8202
add env files for api key
etnoy Feb 5, 2024
dc9078e
Merge branch 'main' of https://github.com/immich-app/immich into cli/…
etnoy Feb 5, 2024
11e4dc6
Merge branch 'main' of https://github.com/immich-app/immich into cli/…
etnoy Feb 6, 2024
e74b2c3
remove immich cli GHA for now
etnoy Feb 6, 2024
987aa5b
Merge branch 'main' of https://github.com/immich-app/immich into cli/…
etnoy Feb 6, 2024
870f824
Update docs/docs/features/command-line-interface.md
etnoy Feb 6, 2024
3eaf097
remove redundant env variable check
etnoy Feb 6, 2024
1a0515b
Merge branch 'cli/dockerize' of https://github.com/immich-app/immich …
etnoy Feb 6, 2024
82b44ea
cleanup
etnoy Feb 6, 2024
99a0403
speling
etnoy Feb 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
platforms: linux/amd64
device: openvino
suffix: -openvino

- image: immich-machine-learning
context: machine-learning
file: machine-learning/Dockerfile
Expand All @@ -57,6 +57,7 @@ jobs:
file: server/Dockerfile
platforms: linux/amd64,linux/arm64
device: cpu

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
22 changes: 11 additions & 11 deletions cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
COPY server/package.json server/package-lock.json ./
WORKDIR /usr/src/open-api/typescript-sdk
COPY open-api/typescript-sdk/package*.json open-api/typescript-sdk/tsconfig*.json ./
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 ./
RUN npm ci
COPY ./cli/ .

FROM ghcr.io/immich-app/base-server-prod:20240130@sha256:ce23a32154540b906df3c971766bcd991561c60331794e0ebb780947ac48113f

VOLUME /usr/src/app/upload
COPY cli .
RUN npm run build

EXPOSE 3001
WORKDIR /import

ENTRYPOINT ["tini", "--", "/bin/sh"]
ENTRYPOINT ["node", "/usr/src/app/dist"]
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"exports": "./dist/index.js",
"bin": {
"immich": "./dist/src/index.js"
"immich": "./dist/index.js"
},
"license": "MIT",
"keywords": [
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { Command, Option } from 'commander';
import path from 'node:path';
import os from 'node:os';
import { version } from '../package.json';
import { LoginCommand } from './commands/login';
import { LogoutCommand } from './commands/logout.command';
import { ServerInfoCommand } from './commands/server-info.command';
import { UploadCommand } from './commands/upload.command';
import { LoginCommand } from './commands/login.command';
import { LogoutCommand } from './commands/logout.command';

const homeDirectory = os.homedir();
const configDirectory = path.join(homeDirectory, '.config/immich/');
Expand Down
5 changes: 3 additions & 2 deletions cli/src/services/session.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ export class SessionService {
readonly authPath!: string;

constructor(configDirectory: string) {
this.configDirectory = configDirectory;
this.authPath = path.join(configDirectory, '/auth.yml');
const environmentDirectory = process.env.IMMICH_CONFIG_DIR;
etnoy marked this conversation as resolved.
Show resolved Hide resolved
this.configDirectory = environmentDirectory ?? configDirectory;
this.authPath = path.join(this.configDirectory, '/auth.yml');
}

async connect(): Promise<ImmichApi> {
Expand Down
3 changes: 1 addition & 2 deletions cli/test/e2e/login-key.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { restoreTempFolder, testApp } from '@test-utils';
import { LoginCommand } from '../../src/commands/login.command';
import { CLI_BASE_OPTIONS, TEST_AUTH_FILE, deleteAuthFile, setup, spyOnConsole } from 'test/cli-test-utils';
import { readFile, stat } from 'node:fs/promises';
import { LoginCommand } from '../../src/commands/login';
import yaml from 'yaml';

describe(`login-key (e2e)`, () => {
Expand Down Expand Up @@ -58,7 +58,6 @@ describe(`login-key (e2e)`, () => {
await new LoginCommand(CLI_BASE_OPTIONS).run(instanceUrl, apiKey);

const stats = await stat(TEST_AUTH_FILE);

const mode = (stats.mode & 0o777).toString(8);

expect(mode).toEqual('600');
Expand Down
16 changes: 14 additions & 2 deletions docs/docs/features/command-line-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ If you are looking to import your Google Photos takeout, we recommend this commu

## Requirements

- Node.js 20.0 or above
- Node.js 20 or above
- Npm

## Installation
If you can't install node, there is also a docker version available.

## Installation (NPM)

```bash
npm i -g @immich/cli
Expand All @@ -30,6 +32,16 @@ NOTE: if you previously installed the legacy CLI, you will need to uninstall it
npm uninstall -g immich
```

## Installation (Docker)

If npm is not available on your system you can try the docker version
etnoy marked this conversation as resolved.
Show resolved Hide resolved

```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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The environment variable for the server should be IMMICH_INSTANCE_URL

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has already been fixed in a separate pr

```

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

```
Expand Down
Loading