mirror of
https://github.com/immich-app/immich.git
synced 2025-06-03 05:34:32 -04:00
Added successfully built docker-compose and cockerFile
This commit is contained in:
parent
568cc243f0
commit
85b83f9666
@ -88,8 +88,9 @@ class HomePage extends HookConsumerWidget {
|
|||||||
|
|
||||||
lastGroupDate = dateTitle;
|
lastGroupDate = dateTitle;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
controller: _scrollController,
|
controller: _scrollController,
|
||||||
slivers: [
|
slivers: [
|
||||||
@ -98,9 +99,6 @@ class HomePage extends HookConsumerWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
return Container();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
3
server/.dockerignore
Normal file
3
server/.dockerignore
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
node_modules/
|
||||||
|
upload/
|
||||||
|
dist/
|
@ -2,13 +2,12 @@
|
|||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
DB_HOST=
|
DB_USERNAME=postgres
|
||||||
DB_USERNAME=
|
DB_PASSWORD=postgres
|
||||||
DB_PASSWORD=
|
DB_DATABASE_NAME=
|
||||||
DB_DATABASE=
|
|
||||||
|
|
||||||
# Upload File Config
|
# Upload File Config
|
||||||
UPLOAD_LOCATION=./tmp
|
UPLOAD_LOCATION=./upload
|
||||||
|
|
||||||
# JWT SECRET
|
# JWT SECRET
|
||||||
JWT_SECRET=
|
JWT_SECRET=
|
1
server/.gitignore
vendored
1
server/.gitignore
vendored
@ -38,3 +38,4 @@ lerna-debug.log*
|
|||||||
dist/
|
dist/
|
||||||
upload/
|
upload/
|
||||||
tmp/
|
tmp/
|
||||||
|
core
|
65
server/Dockerfile
Normal file
65
server/Dockerfile
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
FROM ubuntu:20.04 AS development
|
||||||
|
|
||||||
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
COPY package.json yarn.lock ./
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --fix-missing --no-install-recommends \
|
||||||
|
build-essential \
|
||||||
|
curl \
|
||||||
|
git-core \
|
||||||
|
iputils-ping \
|
||||||
|
pkg-config \
|
||||||
|
rsync \
|
||||||
|
software-properties-common \
|
||||||
|
unzip \
|
||||||
|
wget
|
||||||
|
|
||||||
|
# Install NodeJS
|
||||||
|
RUN curl --silent --location https://deb.nodesource.com/setup_14.x | bash -
|
||||||
|
RUN apt-get install --yes nodejs
|
||||||
|
|
||||||
|
RUN npm i -g yarn
|
||||||
|
|
||||||
|
RUN yarn install
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN yarn build
|
||||||
|
|
||||||
|
|
||||||
|
FROM ubuntu:20.04 as production
|
||||||
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
ARG NODE_ENV=production
|
||||||
|
ENV NODE_ENV=${NODE_ENV}
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
COPY package.json yarn.lock ./
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --fix-missing --no-install-recommends \
|
||||||
|
build-essential \
|
||||||
|
curl \
|
||||||
|
git-core \
|
||||||
|
iputils-ping \
|
||||||
|
pkg-config \
|
||||||
|
rsync \
|
||||||
|
software-properties-common \
|
||||||
|
unzip \
|
||||||
|
wget
|
||||||
|
|
||||||
|
# Install NodeJS
|
||||||
|
RUN curl --silent --location https://deb.nodesource.com/setup_14.x | bash -
|
||||||
|
RUN apt-get install --yes nodejs
|
||||||
|
|
||||||
|
RUN npm i -g yarn
|
||||||
|
|
||||||
|
RUN yarn install --only=production
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
COPY --from=development /usr/src/app/dist ./dist
|
||||||
|
|
||||||
|
CMD ["node", "dist/main"]
|
@ -9,3 +9,17 @@ There is a tensorflow module running in the server so some package will be neede
|
|||||||
```bash
|
```bash
|
||||||
$ apt-get install make cmake gcc g++
|
$ apt-get install make cmake gcc g++
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Docker
|
||||||
|
|
||||||
|
To run application using docker compose
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose up
|
||||||
|
```
|
||||||
|
|
||||||
|
To force rebuild node module after installing new packages
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose up --build -V
|
||||||
|
```
|
||||||
|
54
server/docker-compose.yml
Normal file
54
server/docker-compose.yml
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
|
||||||
|
services:
|
||||||
|
server:
|
||||||
|
container_name: immich_server
|
||||||
|
image: immich-server-dev:1.0.0
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
target: development
|
||||||
|
dockerfile: ./Dockerfile
|
||||||
|
command: yarn start:dev
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
volumes:
|
||||||
|
- .:/usr/src/app
|
||||||
|
- userdata:/usr/src/app/upload
|
||||||
|
- /usr/src/app/node_modules
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
- database
|
||||||
|
networks:
|
||||||
|
- immich_network
|
||||||
|
|
||||||
|
redis:
|
||||||
|
container_name: immich_redis
|
||||||
|
image: redis:6.2
|
||||||
|
networks:
|
||||||
|
- immich_network
|
||||||
|
|
||||||
|
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
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
networks:
|
||||||
|
- immich_network
|
||||||
|
|
||||||
|
networks:
|
||||||
|
immich_network:
|
||||||
|
volumes:
|
||||||
|
pgdata:
|
||||||
|
userdata:
|
@ -32,6 +32,9 @@
|
|||||||
"@nestjs/platform-fastify": "^8.2.6",
|
"@nestjs/platform-fastify": "^8.2.6",
|
||||||
"@nestjs/typeorm": "^8.0.3",
|
"@nestjs/typeorm": "^8.0.3",
|
||||||
"@tensorflow-models/coco-ssd": "^2.2.2",
|
"@tensorflow-models/coco-ssd": "^2.2.2",
|
||||||
|
"@tensorflow/tfjs": "^3.13.0",
|
||||||
|
"@tensorflow/tfjs-converter": "^3.13.0",
|
||||||
|
"@tensorflow/tfjs-core": "^3.13.0",
|
||||||
"@tensorflow/tfjs-node": "^3.13.0",
|
"@tensorflow/tfjs-node": "^3.13.0",
|
||||||
"@types/sharp": "^0.29.5",
|
"@types/sharp": "^0.29.5",
|
||||||
"bcrypt": "^5.0.1",
|
"bcrypt": "^5.0.1",
|
||||||
|
@ -27,9 +27,9 @@ import { ServerInfoModule } from './api-v1/server-info/server-info.module';
|
|||||||
imports: [ConfigModule],
|
imports: [ConfigModule],
|
||||||
useFactory: async (configService: ConfigService) => ({
|
useFactory: async (configService: ConfigService) => ({
|
||||||
redis: {
|
redis: {
|
||||||
host: configService.get('REDIS_HOST'),
|
host: 'immich_redis',
|
||||||
port: configService.get('REDIS_PORT'),
|
port: 6379,
|
||||||
password: configService.get('REDIS_PASSWORD'),
|
// password: configService.get('REDIS_PASSWORD'),
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
inject: [ConfigService],
|
inject: [ConfigService],
|
||||||
@ -44,6 +44,6 @@ import { ServerInfoModule } from './api-v1/server-info/server-info.module';
|
|||||||
})
|
})
|
||||||
export class AppModule implements NestModule {
|
export class AppModule implements NestModule {
|
||||||
configure(consumer: MiddlewareConsumer): void {
|
configure(consumer: MiddlewareConsumer): void {
|
||||||
// consumer.apply(AppLoggerMiddleware).forRoutes('*');
|
consumer.apply(AppLoggerMiddleware).forRoutes('*');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,14 @@ export const immichAppConfig: ConfigModuleOptions = {
|
|||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
validationSchema: Joi.object({
|
validationSchema: Joi.object({
|
||||||
NODE_ENV: Joi.string().required().valid('development', 'production', 'staging').default('development'),
|
NODE_ENV: Joi.string().required().valid('development', 'production', 'staging').default('development'),
|
||||||
DB_HOST: Joi.string().required(),
|
// DB_HOST: Joi.string().required(),
|
||||||
DB_USERNAME: Joi.string().required(),
|
DB_USERNAME: Joi.string().required(),
|
||||||
DB_PASSWORD: Joi.string().required(),
|
DB_PASSWORD: Joi.string().required(),
|
||||||
DB_DATABASE: Joi.string().required(),
|
DB_DATABASE_NAME: Joi.string().required(),
|
||||||
UPLOAD_LOCATION: Joi.string().required(),
|
UPLOAD_LOCATION: Joi.string().required(),
|
||||||
JWT_SECRET: Joi.string().required(),
|
JWT_SECRET: Joi.string().required(),
|
||||||
REDIS_HOST: Joi.string().required(),
|
// REDIS_HOST: Joi.string().required(),
|
||||||
REDIS_PORT: Joi.string().required(),
|
// REDIS_PORT: Joi.string().required(),
|
||||||
REDIS_PASSWORD: Joi.string().required(),
|
// REDIS_PASSWORD: Joi.string().required(),
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
@ -9,11 +9,11 @@ if (result.error) {
|
|||||||
|
|
||||||
export const databaseConfig: TypeOrmModuleOptions = {
|
export const databaseConfig: TypeOrmModuleOptions = {
|
||||||
type: 'postgres',
|
type: 'postgres',
|
||||||
host: process.env.DB_HOST,
|
host: 'immich_postgres',
|
||||||
port: 5432,
|
port: 5432,
|
||||||
username: process.env.DB_USERNAME,
|
username: process.env.DB_USERNAME,
|
||||||
password: process.env.DB_PASSWORD,
|
password: process.env.DB_PASSWORD,
|
||||||
database: process.env.DB_DATABASE,
|
database: process.env.DB_DATABASE_NAME,
|
||||||
entities: [__dirname + '/../**/*.entity.{js,ts}'],
|
entities: [__dirname + '/../**/*.entity.{js,ts}'],
|
||||||
synchronize: true,
|
synchronize: true,
|
||||||
// logging: true,
|
// logging: true,
|
||||||
|
@ -7,7 +7,7 @@ import { AssetService } from '../../api-v1/asset/asset.service';
|
|||||||
import { AssetEntity } from '../../api-v1/asset/entities/asset.entity';
|
import { AssetEntity } from '../../api-v1/asset/entities/asset.entity';
|
||||||
import { ImageOptimizeProcessor } from './image-optimize.processor';
|
import { ImageOptimizeProcessor } from './image-optimize.processor';
|
||||||
import { ImageOptimizeService } from './image-optimize.service';
|
import { ImageOptimizeService } from './image-optimize.service';
|
||||||
import { MachineLearningProcessor } from './machine-learning.processor';
|
// import { MachineLearningProcessor } from './machine-learning.processor';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@ -30,7 +30,7 @@ import { MachineLearningProcessor } from './machine-learning.processor';
|
|||||||
|
|
||||||
TypeOrmModule.forFeature([AssetEntity]),
|
TypeOrmModule.forFeature([AssetEntity]),
|
||||||
],
|
],
|
||||||
providers: [ImageOptimizeService, ImageOptimizeProcessor, MachineLearningProcessor],
|
providers: [ImageOptimizeService, ImageOptimizeProcessor],
|
||||||
exports: [ImageOptimizeService],
|
exports: [ImageOptimizeService],
|
||||||
})
|
})
|
||||||
export class ImageOptimizeModule {}
|
export class ImageOptimizeModule {}
|
||||||
|
@ -8,10 +8,7 @@ import { AuthUserDto } from '../../decorators/auth-user.decorator';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ImageOptimizeService {
|
export class ImageOptimizeService {
|
||||||
constructor(
|
constructor(@InjectQueue('image') private imageQueue: Queue) {}
|
||||||
@InjectQueue('image') private imageQueue: Queue,
|
|
||||||
@InjectQueue('machine-learning') private machineLearningQueue: Queue,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
public async resizeImage(savedAsset: AssetEntity) {
|
public async resizeImage(savedAsset: AssetEntity) {
|
||||||
const job = await this.imageQueue.add(
|
const job = await this.imageQueue.add(
|
||||||
|
@ -1,39 +1,39 @@
|
|||||||
import { Process, Processor } from '@nestjs/bull';
|
// import { Process, Processor } from '@nestjs/bull';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
// import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { Job } from 'bull';
|
// import { Job } from 'bull';
|
||||||
import { Repository } from 'typeorm';
|
// import { Repository } from 'typeorm';
|
||||||
import { AssetEntity } from '../../api-v1/asset/entities/asset.entity';
|
// import { AssetEntity } from '../../api-v1/asset/entities/asset.entity';
|
||||||
import sharp from 'sharp';
|
// import sharp from 'sharp';
|
||||||
import fs, { existsSync, mkdirSync } from 'fs';
|
// import fs, { existsSync, mkdirSync } from 'fs';
|
||||||
import { ConfigService } from '@nestjs/config';
|
// import { ConfigService } from '@nestjs/config';
|
||||||
import * as tfnode from '@tensorflow/tfjs-node';
|
// import * as tfnode from '@tensorflow/tfjs-node';
|
||||||
import * as cocoSsd from '@tensorflow-models/coco-ssd';
|
// import * as cocoSsd from '@tensorflow-models/coco-ssd';
|
||||||
|
|
||||||
@Processor('machine-learning')
|
// @Processor('machine-learning')
|
||||||
export class MachineLearningProcessor {
|
// export class MachineLearningProcessor {
|
||||||
constructor(
|
// constructor(
|
||||||
@InjectRepository(AssetEntity) private assetRepository: Repository<AssetEntity>,
|
// @InjectRepository(AssetEntity) private assetRepository: Repository<AssetEntity>,
|
||||||
private configService: ConfigService,
|
// private configService: ConfigService,
|
||||||
) {}
|
// ) {}
|
||||||
|
|
||||||
@Process('object-detection')
|
// @Process('object-detection')
|
||||||
async handleOptimization(job: Job) {
|
// async handleOptimization(job: Job) {
|
||||||
try {
|
// try {
|
||||||
const { resizePath }: { resizePath: string } = job.data;
|
// const { resizePath }: { resizePath: string } = job.data;
|
||||||
|
|
||||||
const image = fs.readFileSync(resizePath);
|
// const image = fs.readFileSync(resizePath);
|
||||||
const decodedImage = tfnode.node.decodeImage(image, 3) as tfnode.Tensor3D;
|
// const decodedImage = tfnode.node.decodeImage(image, 3) as tfnode.Tensor3D;
|
||||||
const model = await cocoSsd.load();
|
// const model = await cocoSsd.load();
|
||||||
const predictions = await model.detect(decodedImage);
|
// const predictions = await model.detect(decodedImage);
|
||||||
console.log('start predictions ------------------ ');
|
// console.log('start predictions ------------------ ');
|
||||||
for (var result of predictions) {
|
// for (var result of predictions) {
|
||||||
console.log(`Found ${result.class} with score ${result.score}`);
|
// console.log(`Found ${result.class} with score ${result.score}`);
|
||||||
}
|
// }
|
||||||
console.log('end predictions ------------------ ');
|
// console.log('end predictions ------------------ ');
|
||||||
|
|
||||||
return 'ok';
|
// return 'ok';
|
||||||
} catch (e) {
|
// } catch (e) {
|
||||||
console.log('Error object detection ', e);
|
// console.log('Error object detection ', e);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
@ -844,12 +844,12 @@
|
|||||||
"@types/webgl2" "0.0.6"
|
"@types/webgl2" "0.0.6"
|
||||||
seedrandom "2.4.3"
|
seedrandom "2.4.3"
|
||||||
|
|
||||||
"@tensorflow/tfjs-converter@3.13.0":
|
"@tensorflow/tfjs-converter@3.13.0", "@tensorflow/tfjs-converter@^3.13.0":
|
||||||
version "3.13.0"
|
version "3.13.0"
|
||||||
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-3.13.0.tgz#3affc86d94c3948b01673a91309a35feb10e5eac"
|
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-3.13.0.tgz#3affc86d94c3948b01673a91309a35feb10e5eac"
|
||||||
integrity sha512-H2VpDTv9Ve0HBt7ttzz46DmnsPaiT0B+yJjVH3NebGZbgY9C8boBgJIsdyqfiqEWBS3WxF8h4rh58Hv5XXMgaQ==
|
integrity sha512-H2VpDTv9Ve0HBt7ttzz46DmnsPaiT0B+yJjVH3NebGZbgY9C8boBgJIsdyqfiqEWBS3WxF8h4rh58Hv5XXMgaQ==
|
||||||
|
|
||||||
"@tensorflow/tfjs-core@3.13.0":
|
"@tensorflow/tfjs-core@3.13.0", "@tensorflow/tfjs-core@^3.13.0":
|
||||||
version "3.13.0"
|
version "3.13.0"
|
||||||
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-3.13.0.tgz#0cfd707c668250969564991c5c101fb52e51e1aa"
|
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-3.13.0.tgz#0cfd707c668250969564991c5c101fb52e51e1aa"
|
||||||
integrity sha512-18qBEVIB/4u2OUK9nA5P1XT3e3LyarElD1UKNSNDpnMLxhLTUVZaCR71eHJcpl9wP2Q0cciaTJCTpJdPv1tNDQ==
|
integrity sha512-18qBEVIB/4u2OUK9nA5P1XT3e3LyarElD1UKNSNDpnMLxhLTUVZaCR71eHJcpl9wP2Q0cciaTJCTpJdPv1tNDQ==
|
||||||
@ -889,7 +889,7 @@
|
|||||||
rimraf "^2.6.2"
|
rimraf "^2.6.2"
|
||||||
tar "^4.4.6"
|
tar "^4.4.6"
|
||||||
|
|
||||||
"@tensorflow/tfjs@3.13.0":
|
"@tensorflow/tfjs@3.13.0", "@tensorflow/tfjs@^3.13.0":
|
||||||
version "3.13.0"
|
version "3.13.0"
|
||||||
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs/-/tfjs-3.13.0.tgz#ea0597e0208d403278e2ccbaa5faa479083a04d3"
|
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs/-/tfjs-3.13.0.tgz#ea0597e0208d403278e2ccbaa5faa479083a04d3"
|
||||||
integrity sha512-B5HvNH+6hHhQQkn+AG+u4j5sxZBMYdsq4IWXlBZzioJcVygtZhBWXkxp01boSwngjqUBgi8S2DopBE7McAUKqQ==
|
integrity sha512-B5HvNH+6hHhQQkn+AG+u4j5sxZBMYdsq4IWXlBZzioJcVygtZhBWXkxp01boSwngjqUBgi8S2DopBE7McAUKqQ==
|
||||||
|
Loading…
x
Reference in New Issue
Block a user