diff --git a/README.md b/README.md index 8aa0edd01c..d26b02fa57 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,8 @@ Loading ~4000 images/videos
- + +
diff --git a/design/nsc4.jpeg b/design/nsc4.jpeg new file mode 100644 index 0000000000..3228b348c0 Binary files /dev/null and b/design/nsc4.jpeg differ diff --git a/docker/.env.example b/docker/.env.example index 2298bf31a1..1d61eac1cf 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -1,6 +1,3 @@ -# STAGE -NODE_ENV=development - # Database DB_USERNAME=postgres DB_PASSWORD=postgres diff --git a/docker/docker-compose.dev.yml b/docker/docker-compose.dev.yml index 5f64a092b5..01ecf79546 100644 --- a/docker/docker-compose.dev.yml +++ b/docker/docker-compose.dev.yml @@ -5,7 +5,6 @@ services: image: immich-server-dev:1.3.2 build: context: ../server - target: development dockerfile: ../server/Dockerfile command: npm run start:dev expose: @@ -16,6 +15,8 @@ services: - /usr/src/app/node_modules env_file: - .env + environment: + - NODE_ENV=development depends_on: - redis - database @@ -26,7 +27,6 @@ services: image: immich-microservices-dev:1.3.2 build: context: ../microservices - target: development dockerfile: ../microservices/Dockerfile command: npm run start:dev expose: @@ -37,6 +37,8 @@ services: - /usr/src/app/node_modules env_file: - .env + environment: + - NODE_ENV=development depends_on: - database networks: diff --git a/docker/docker-compose.gpu.yml b/docker/docker-compose.gpu.yml index 57e74ceb58..21df69c828 100644 --- a/docker/docker-compose.gpu.yml +++ b/docker/docker-compose.gpu.yml @@ -5,7 +5,6 @@ services: image: immich-server-dev:1.4.0 build: context: ../server - target: development dockerfile: ../server/Dockerfile command: npm run start:dev expose: @@ -26,7 +25,6 @@ services: image: immich-microservices-dev:1.4.0 build: context: ../microservices - target: development dockerfile: ../microservices/Dockerfile command: npm run start:dev deploy: diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index d652637582..efd6bb1c8f 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -5,7 +5,6 @@ services: image: immich-server:1.4.0 build: context: ../server - target: production dockerfile: ../server/Dockerfile command: npm run start:prod expose: @@ -16,6 +15,8 @@ services: - /usr/src/app/node_modules env_file: - .env + environment: + - NODE_ENV=production depends_on: - redis - database @@ -26,7 +27,6 @@ services: image: immich-microservices:1.4.0 build: context: ../microservices - target: production dockerfile: ../microservices/Dockerfile command: npm run start:prod expose: @@ -37,6 +37,8 @@ services: - /usr/src/app/node_modules env_file: - .env + environment: + - NODE_ENV=production depends_on: - database networks: diff --git a/microservices/Dockerfile b/microservices/Dockerfile index a0f4c9aea7..38aed3759d 100644 --- a/microservices/Dockerfile +++ b/microservices/Dockerfile @@ -1,7 +1,4 @@ -################################## -# DEVELOPMENT -################################## -FROM node:16-bullseye-slim AS development +FROM node:16-bullseye-slim ARG DEBIAN_FRONTEND=noninteractive @@ -17,27 +14,3 @@ RUN npm install COPY . . RUN npm run build - -################################# -# PRODUCTION -################################# -FROM node:16-bullseye-slim AS production - -ARG DEBIAN_FRONTEND=noninteractive -ARG NODE_ENV=production -ENV NODE_ENV=${NODE_ENV} - -WORKDIR /usr/src/app - -COPY package.json package-lock.json ./ - -RUN apt-get update -RUN apt-get install gcc g++ make cmake python3 python3-pip ffmpeg -y - -RUN npm install --only=production - -COPY . . - -COPY --from=development /usr/src/app/dist ./dist - -CMD ["node", "dist/main"] \ No newline at end of file diff --git a/microservices/src/main.ts b/microservices/src/main.ts index 2e8c808589..4f9d22d007 100644 --- a/microservices/src/main.ts +++ b/microservices/src/main.ts @@ -1,10 +1,25 @@ import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; +import { Logger } from '@nestjs/common'; async function bootstrap() { const app = await NestFactory.create(AppModule); - await app.listen(3001); + await app.listen(3001, () => { + if (process.env.NODE_ENV == 'development') { + Logger.log( + 'Running Immich Microservices in DEVELOPMENT environment', + 'IMMICH MICROSERVICES', + ); + } + + if (process.env.NODE_ENV == 'production') { + Logger.log( + 'Running Immich Microservices in PRODUCTION environment', + 'IMMICH MICROSERVICES', + ); + } + }); } bootstrap(); diff --git a/server/Dockerfile b/server/Dockerfile index db9ef93647..7be1e30e9f 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -1,7 +1,4 @@ -################################## -# DEVELOPMENT -################################## -FROM node:16-alpine3.14 AS development +FROM node:16-alpine3.14 ARG DEBIAN_FRONTEND=noninteractive @@ -15,27 +12,4 @@ RUN npm install COPY . . -RUN npm run build - -################################# -# PRODUCTION -################################# -FROM node:16-alpine3.14 AS production - -ARG DEBIAN_FRONTEND=noninteractive -ARG NODE_ENV=production -ENV NODE_ENV=${NODE_ENV} - -WORKDIR /usr/src/app - -COPY package.json package-lock.json ./ - -RUN apk add --update-cache build-base python3 - -RUN npm install --only=production - -COPY . . - -COPY --from=development /usr/src/app/dist ./dist - -CMD ["node", "dist/main"] \ No newline at end of file +RUN npm run build \ No newline at end of file diff --git a/server/src/app.module.ts b/server/src/app.module.ts index 272d695210..f62b38de6d 100644 --- a/server/src/app.module.ts +++ b/server/src/app.module.ts @@ -46,6 +46,8 @@ import { CommunicationModule } from './api-v1/communication/communication.module }) export class AppModule implements NestModule { configure(consumer: MiddlewareConsumer): void { - // consumer.apply(AppLoggerMiddleware).forRoutes('*'); + if (process.env.NODE_ENV == 'development') { + consumer.apply(AppLoggerMiddleware).forRoutes('*'); + } } } diff --git a/server/src/main.ts b/server/src/main.ts index 435a3cb033..c53ba25a14 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -1,3 +1,4 @@ +import { Logger } from '@nestjs/common'; import { NestFactory } from '@nestjs/core'; import { NestExpressApplication } from '@nestjs/platform-express'; import { AppModule } from './app.module'; @@ -10,6 +11,14 @@ async function bootstrap() { app.useWebSocketAdapter(new RedisIoAdapter(app)); - await app.listen(3000); + await app.listen(3000, () => { + if (process.env.NODE_ENV == 'development') { + Logger.log('Running Immich Server in DEVELOPMENT environment', 'IMMICH SERVER'); + } + + if (process.env.NODE_ENV == 'production') { + Logger.log('Running Immich Server in PRODUCTION environment', 'IMMICH SERVER'); + } + }); } bootstrap();