Skip to content

Commit

Permalink
Add web interface with admin functionality (immich-app#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
alextran1502 authored May 21, 2022
1 parent 79dea50 commit a779c38
Show file tree
Hide file tree
Showing 76 changed files with 8,252 additions and 87 deletions.
79 changes: 53 additions & 26 deletions .github/workflows/build_push_docker_latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
branches: [main]

jobs:

build_and_push_server_latest:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -37,28 +36,56 @@ jobs:
altran1502/immich-server:latest
build_and_push_microservice_latest:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: "main" # branch
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push Microservices
uses: docker/[email protected]
with:
context: ./microservices
file: ./microservices/Dockerfile
platforms: linux/arm/v7,linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: |
altran1502/immich-microservices:latest
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: "main" # branch
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push Microservices
uses: docker/[email protected]
with:
context: ./microservices
file: ./microservices/Dockerfile
platforms: linux/arm/v7,linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: |
altran1502/immich-microservices:latest
build_and_push_web_latest:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: "main" # branch
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push Web
uses: docker/[email protected]
with:
context: ./web
file: ./web/Dockerfile
platforms: linux/arm/v7,linux/amd64,linux/arm64
target: prod
push: ${{ github.event_name != 'pull_request' }}
tags: |
altran1502/immich-web:latest
55 changes: 47 additions & 8 deletions .github/workflows/build_push_server_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
with:
ref: "main"
ref: "main"
fetch-depth: 0
- name: 'Get Previous tag'

- name: "Get Previous tag"
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: latest
fallback: latest

- name: Set up QEMU
uses: docker/[email protected]
Expand Down Expand Up @@ -50,14 +50,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
with:
ref: "main"
ref: "main"
fetch-depth: 0

- name: 'Get Previous tag'
- name: "Get Previous tag"
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: latest
fallback: latest

- name: Set up QEMU
uses: docker/[email protected]
Expand All @@ -80,4 +80,43 @@ jobs:
platforms: linux/arm/v7,linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: |
altran1502/immich-microservices:${{ steps.previoustag.outputs.tag }}
altran1502/immich-microservices:${{ steps.previoustag.outputs.tag }}
build_and_push_web_release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: "main"
fetch-depth: 0

- name: "Get Previous tag"
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: latest

- name: Set up QEMU
uses: docker/[email protected]

- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push immich-web release
uses: docker/[email protected]
with:
context: ./web
file: ./web/Dockerfile
platforms: linux/arm/v7,linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
target: prod
tags: |
altran1502/immich-web:${{ steps.previoustag.outputs.tag }}
9 changes: 9 additions & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# TODO

Server scenario with web

[ ] 1 user exist without admin right -> make admin on first check

[ ] 2 users exist without admin right -> ask user to choose which account will be the admin

[ X ] No users exist -> prompt signup form for Admin
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ I haven't tested with `Docker for Windows` as well as `WSL` on Windows
You can use docker compose for development and testing out the application, there are several services that compose Immich:

1. **NestJs** - Backend of the application
2. **PostgreSQL** - Main database of the application
3. **Redis** - For sharing websocket instance between docker instances and background tasks message queue.
4. **Nginx** - Load balancing and optimized file uploading.
5. **TensorFlow** - Object Detection and Image Classification.
2. **SvelteKit** - Web frontend of the application
3. **PostgreSQL** - Main database of the application
4. **Redis** - For sharing websocket instance between docker instances and background tasks message queue.
5. **Nginx** - Load balancing and optimized file uploading.
6. **TensorFlow** - Object Detection and Image Classification.

## Step 1: Populate .env file

Expand Down Expand Up @@ -133,7 +134,7 @@ To start, run
docker-compose -f ./docker/docker-compose.yml up
```

If you have a few thousand photos/videos, I suggest running docker-compose with scaling option for the `immich_server` container to handle high I/O load when using fast scrolling.
If you have a few thousand photos/videos, I suggest running docker-compose with scaling option for the `immich_-erver` container to handle high I/O load when using fast scrolling.

```bash
docker-compose -f ./docker/docker-compose.yml up --scale immich-server=5
Expand All @@ -144,17 +145,17 @@ The server will be running at `http://your-ip:2283` through `Nginx`

## Step 3: Register User

Use the command below on your terminal to create user as we don't have user interface for this function yet.
Access the web interface at `http://your-ip:2285` to register an admin account.

```bash
curl --location --request POST 'http://your-server-ip:2283/auth/signUp' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "[email protected]",
"password": "password"
}'
```
<p align="left">
<img src="design/admin-registration-form.png" width="300" title="Admin Registration">
<p/>

Additional accounts on the server can be created by the admin account.

<p align="left">
<img src="design/admin-interface.png" width="500" title="Admin User Management">
<p/>
## Step 4: Run mobile app

The app is distributed on several platforms below.
Expand Down
Binary file added design/admin-interface.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added design/admin-registration-form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 38 additions & 2 deletions docker/.env.example
Original file line number Diff line number Diff line change
@@ -1,15 +1,51 @@
###################################################################################
# Database
###################################################################################

DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_DATABASE_NAME=immich





###################################################################################
# Upload File Config
###################################################################################

UPLOAD_LOCATION=absolute_location_on_your_machine_where_you_want_to_store_the_backup




###################################################################################
# JWT SECRET
###################################################################################

JWT_SECRET=randomstringthatissolongandpowerfulthatnoonecanguess




###################################################################################
# MAPBOX
## ENABLE_MAPBOX is either true of false -> if true, you have to provide MAPBOX_KEY
####################################################################################

# ENABLE_MAPBOX is either true of false -> if true, you have to provide MAPBOX_KEY
ENABLE_MAPBOX=false
MAPBOX_KEY=
MAPBOX_KEY=




###################################################################################
# WEB
###################################################################################

# This is the URL of your vm/server where you host Immich, so that the web frontend
# know where can it make the request to.
# For example: If your server IP address is 10.1.11.50, the environment variable will
# be VITE_SERVER_ENDPOINT=http://10.1.11.50:2283

VITE_SERVER_ENDPOINT=
18 changes: 18 additions & 0 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ services:
networks:
- immich-network

immich-web:
image: immich-web-dev:1.9.0
build:
context: ../web
dockerfile: Dockerfile
target: dev
command: npm run dev --host
env_file:
- .env
ports:
- 3002:3002
- 24678:24678
volumes:
- ../web:/usr/src/app
- /usr/src/app/node_modules
networks:
- immich-network
restart: always

redis:
container_name: immich_redis
Expand Down
19 changes: 17 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
- database
networks:
- immich-network
restart: unless-stopped
restart: always

immich-microservices:
image: altran1502/immich-microservices:latest
Expand All @@ -34,13 +34,27 @@ services:
- database
networks:
- immich-network
restart: unless-stopped
restart: always

immich-web:
image: altran1502/immich-web:latest
entrypoint: ["/bin/sh", "./entrypoint.sh"]
env_file:
- .env
ports:
- 2285:3000
networks:
- immich-network
restart: always


redis:
container_name: immich_redis
image: redis:6.2
networks:
- immich-network
restart: always


database:
container_name: immich_postgres
Expand Down Expand Up @@ -73,6 +87,7 @@ services:
- immich-network
depends_on:
- immich-server
restart: always

networks:
immich-network:
Expand Down
3 changes: 2 additions & 1 deletion server/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"singleQuote": true,
"trailingComma": "all",
"printWidth": 120
"printWidth": 120,
"semi": true
}
8 changes: 4 additions & 4 deletions server/src/api-v1/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import { SignUpDto } from './dto/sign-up.dto';

@Controller('auth')
export class AuthController {
constructor(private readonly authService: AuthService) {}
constructor(private readonly authService: AuthService) { }

@Post('/login')
async login(@Body(ValidationPipe) loginCredential: LoginCredentialDto) {
return await this.authService.login(loginCredential);
}

@Post('/signUp')
async signUp(@Body(ValidationPipe) signUpCrendential: SignUpDto) {
return await this.authService.signUp(signUpCrendential);
@Post('/admin-sign-up')
async adminSignUp(@Body(ValidationPipe) signUpCrendential: SignUpDto) {
return await this.authService.adminSignUp(signUpCrendential);
}

@UseGuards(JwtAuthGuard)
Expand Down
Loading

0 comments on commit a779c38

Please sign in to comment.