mirror of
https://github.com/immich-app/immich.git
synced 2024-12-22 01:47:08 +02: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;
|
||||
}
|
||||
}
|
||||
|
||||
return SafeArea(
|
||||
return SafeArea(
|
||||
child: CustomScrollView(
|
||||
controller: _scrollController,
|
||||
slivers: [
|
||||
@ -98,9 +99,6 @@ class HomePage extends HookConsumerWidget {
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
# Database
|
||||
DB_HOST=
|
||||
DB_USERNAME=
|
||||
DB_PASSWORD=
|
||||
DB_DATABASE=
|
||||
DB_USERNAME=postgres
|
||||
DB_PASSWORD=postgres
|
||||
DB_DATABASE_NAME=
|
||||
|
||||
# Upload File Config
|
||||
UPLOAD_LOCATION=./tmp
|
||||
UPLOAD_LOCATION=./upload
|
||||
|
||||
# JWT SECRET
|
||||
JWT_SECRET=
|
1
server/.gitignore
vendored
1
server/.gitignore
vendored
@ -38,3 +38,4 @@ lerna-debug.log*
|
||||
dist/
|
||||
upload/
|
||||
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
|
||||
$ 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/typeorm": "^8.0.3",
|
||||
"@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",
|
||||
"@types/sharp": "^0.29.5",
|
||||
"bcrypt": "^5.0.1",
|
||||
|
@ -27,9 +27,9 @@ import { ServerInfoModule } from './api-v1/server-info/server-info.module';
|
||||
imports: [ConfigModule],
|
||||
useFactory: async (configService: ConfigService) => ({
|
||||
redis: {
|
||||
host: configService.get('REDIS_HOST'),
|
||||
port: configService.get('REDIS_PORT'),
|
||||
password: configService.get('REDIS_PASSWORD'),
|
||||
host: 'immich_redis',
|
||||
port: 6379,
|
||||
// password: configService.get('REDIS_PASSWORD'),
|
||||
},
|
||||
}),
|
||||
inject: [ConfigService],
|
||||
@ -44,6 +44,6 @@ import { ServerInfoModule } from './api-v1/server-info/server-info.module';
|
||||
})
|
||||
export class AppModule implements NestModule {
|
||||
configure(consumer: MiddlewareConsumer): void {
|
||||
// consumer.apply(AppLoggerMiddleware).forRoutes('*');
|
||||
consumer.apply(AppLoggerMiddleware).forRoutes('*');
|
||||
}
|
||||
}
|
||||
|
@ -6,14 +6,14 @@ export const immichAppConfig: ConfigModuleOptions = {
|
||||
isGlobal: true,
|
||||
validationSchema: Joi.object({
|
||||
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_PASSWORD: Joi.string().required(),
|
||||
DB_DATABASE: Joi.string().required(),
|
||||
DB_DATABASE_NAME: Joi.string().required(),
|
||||
UPLOAD_LOCATION: Joi.string().required(),
|
||||
JWT_SECRET: Joi.string().required(),
|
||||
REDIS_HOST: Joi.string().required(),
|
||||
REDIS_PORT: Joi.string().required(),
|
||||
REDIS_PASSWORD: Joi.string().required(),
|
||||
// REDIS_HOST: Joi.string().required(),
|
||||
// REDIS_PORT: Joi.string().required(),
|
||||
// REDIS_PASSWORD: Joi.string().required(),
|
||||
}),
|
||||
};
|
||||
|
@ -9,11 +9,11 @@ if (result.error) {
|
||||
|
||||
export const databaseConfig: TypeOrmModuleOptions = {
|
||||
type: 'postgres',
|
||||
host: process.env.DB_HOST,
|
||||
host: 'immich_postgres',
|
||||
port: 5432,
|
||||
username: process.env.DB_USERNAME,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_DATABASE,
|
||||
database: process.env.DB_DATABASE_NAME,
|
||||
entities: [__dirname + '/../**/*.entity.{js,ts}'],
|
||||
synchronize: 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 { ImageOptimizeProcessor } from './image-optimize.processor';
|
||||
import { ImageOptimizeService } from './image-optimize.service';
|
||||
import { MachineLearningProcessor } from './machine-learning.processor';
|
||||
// import { MachineLearningProcessor } from './machine-learning.processor';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@ -30,7 +30,7 @@ import { MachineLearningProcessor } from './machine-learning.processor';
|
||||
|
||||
TypeOrmModule.forFeature([AssetEntity]),
|
||||
],
|
||||
providers: [ImageOptimizeService, ImageOptimizeProcessor, MachineLearningProcessor],
|
||||
providers: [ImageOptimizeService, ImageOptimizeProcessor],
|
||||
exports: [ImageOptimizeService],
|
||||
})
|
||||
export class ImageOptimizeModule {}
|
||||
|
@ -8,10 +8,7 @@ import { AuthUserDto } from '../../decorators/auth-user.decorator';
|
||||
|
||||
@Injectable()
|
||||
export class ImageOptimizeService {
|
||||
constructor(
|
||||
@InjectQueue('image') private imageQueue: Queue,
|
||||
@InjectQueue('machine-learning') private machineLearningQueue: Queue,
|
||||
) {}
|
||||
constructor(@InjectQueue('image') private imageQueue: Queue) {}
|
||||
|
||||
public async resizeImage(savedAsset: AssetEntity) {
|
||||
const job = await this.imageQueue.add(
|
||||
|
@ -1,39 +1,39 @@
|
||||
import { Process, Processor } from '@nestjs/bull';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Job } from 'bull';
|
||||
import { Repository } from 'typeorm';
|
||||
import { AssetEntity } from '../../api-v1/asset/entities/asset.entity';
|
||||
import sharp from 'sharp';
|
||||
import fs, { existsSync, mkdirSync } from 'fs';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import * as tfnode from '@tensorflow/tfjs-node';
|
||||
import * as cocoSsd from '@tensorflow-models/coco-ssd';
|
||||
// import { Process, Processor } from '@nestjs/bull';
|
||||
// import { InjectRepository } from '@nestjs/typeorm';
|
||||
// import { Job } from 'bull';
|
||||
// import { Repository } from 'typeorm';
|
||||
// import { AssetEntity } from '../../api-v1/asset/entities/asset.entity';
|
||||
// import sharp from 'sharp';
|
||||
// import fs, { existsSync, mkdirSync } from 'fs';
|
||||
// import { ConfigService } from '@nestjs/config';
|
||||
// import * as tfnode from '@tensorflow/tfjs-node';
|
||||
// import * as cocoSsd from '@tensorflow-models/coco-ssd';
|
||||
|
||||
@Processor('machine-learning')
|
||||
export class MachineLearningProcessor {
|
||||
constructor(
|
||||
@InjectRepository(AssetEntity) private assetRepository: Repository<AssetEntity>,
|
||||
private configService: ConfigService,
|
||||
) {}
|
||||
// @Processor('machine-learning')
|
||||
// export class MachineLearningProcessor {
|
||||
// constructor(
|
||||
// @InjectRepository(AssetEntity) private assetRepository: Repository<AssetEntity>,
|
||||
// private configService: ConfigService,
|
||||
// ) {}
|
||||
|
||||
@Process('object-detection')
|
||||
async handleOptimization(job: Job) {
|
||||
try {
|
||||
const { resizePath }: { resizePath: string } = job.data;
|
||||
// @Process('object-detection')
|
||||
// async handleOptimization(job: Job) {
|
||||
// try {
|
||||
// const { resizePath }: { resizePath: string } = job.data;
|
||||
|
||||
const image = fs.readFileSync(resizePath);
|
||||
const decodedImage = tfnode.node.decodeImage(image, 3) as tfnode.Tensor3D;
|
||||
const model = await cocoSsd.load();
|
||||
const predictions = await model.detect(decodedImage);
|
||||
console.log('start predictions ------------------ ');
|
||||
for (var result of predictions) {
|
||||
console.log(`Found ${result.class} with score ${result.score}`);
|
||||
}
|
||||
console.log('end predictions ------------------ ');
|
||||
// const image = fs.readFileSync(resizePath);
|
||||
// const decodedImage = tfnode.node.decodeImage(image, 3) as tfnode.Tensor3D;
|
||||
// const model = await cocoSsd.load();
|
||||
// const predictions = await model.detect(decodedImage);
|
||||
// console.log('start predictions ------------------ ');
|
||||
// for (var result of predictions) {
|
||||
// console.log(`Found ${result.class} with score ${result.score}`);
|
||||
// }
|
||||
// console.log('end predictions ------------------ ');
|
||||
|
||||
return 'ok';
|
||||
} catch (e) {
|
||||
console.log('Error object detection ', e);
|
||||
}
|
||||
}
|
||||
}
|
||||
// return 'ok';
|
||||
// } catch (e) {
|
||||
// console.log('Error object detection ', e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
@ -844,12 +844,12 @@
|
||||
"@types/webgl2" "0.0.6"
|
||||
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"
|
||||
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-3.13.0.tgz#3affc86d94c3948b01673a91309a35feb10e5eac"
|
||||
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"
|
||||
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-3.13.0.tgz#0cfd707c668250969564991c5c101fb52e51e1aa"
|
||||
integrity sha512-18qBEVIB/4u2OUK9nA5P1XT3e3LyarElD1UKNSNDpnMLxhLTUVZaCR71eHJcpl9wP2Q0cciaTJCTpJdPv1tNDQ==
|
||||
@ -889,7 +889,7 @@
|
||||
rimraf "^2.6.2"
|
||||
tar "^4.4.6"
|
||||
|
||||
"@tensorflow/tfjs@3.13.0":
|
||||
"@tensorflow/tfjs@3.13.0", "@tensorflow/tfjs@^3.13.0":
|
||||
version "3.13.0"
|
||||
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs/-/tfjs-3.13.0.tgz#ea0597e0208d403278e2ccbaa5faa479083a04d3"
|
||||
integrity sha512-B5HvNH+6hHhQQkn+AG+u4j5sxZBMYdsq4IWXlBZzioJcVygtZhBWXkxp01boSwngjqUBgi8S2DopBE7McAUKqQ==
|
||||
|
Loading…
Reference in New Issue
Block a user