diff --git a/apps/Dockerfile.apigateway b/apps/Dockerfile.apigateway index 4ea563d..808468d 100644 --- a/apps/Dockerfile.apigateway +++ b/apps/Dockerfile.apigateway @@ -11,7 +11,7 @@ COPY . . RUN turbo prune ${service} --docker # Add lockfile and package.json's of isolated subworkspace -FROM base AS installer +FROM base AS development ARG service WORKDIR /app @@ -40,7 +40,7 @@ RUN npm install --omit=dev --workspace=${service} # COPY . . -COPY --from=installer /app/dist/apps/${service} ./dist +COPY --from=development /app/dist/apps/${service} ./dist CMD ["node", "dist/server.js"] diff --git a/apps/auth/package.json b/apps/auth/package.json index df179b9..e45190a 100644 --- a/apps/auth/package.json +++ b/apps/auth/package.json @@ -32,6 +32,7 @@ "@nestjs/cli": "^10.0.0", "@nestjs/schematics": "^10.0.0", "@nestjs/testing": "^10.0.0", + "@types/bcrypt": "^5.0.2", "@types/express": "^4.17.17", "@types/jest": "^29.5.2", "@types/morgan": "^1.9.9", diff --git a/apps/auth/src/auth.controller.ts b/apps/auth/src/auth.controller.ts index 0773f1b..8f78389 100644 --- a/apps/auth/src/auth.controller.ts +++ b/apps/auth/src/auth.controller.ts @@ -1,6 +1,7 @@ import { Body, Controller, + Get, HttpCode, HttpStatus, Post, @@ -14,6 +15,12 @@ import { AuthDto, VerificationDto } from './dto/auth.dto'; export class AuthController { constructor(private authService: AuthService) {} + @HttpCode(HttpStatus.OK) + @Get('') + healthCheck() { + return 'Auth ok'; + } + @HttpCode(HttpStatus.OK) @Post('login') signIn(@Body() signInDto: AuthDto) { diff --git a/apps/auth/src/main.ts b/apps/auth/src/main.ts index 946abeb..d796d6e 100644 --- a/apps/auth/src/main.ts +++ b/apps/auth/src/main.ts @@ -19,7 +19,7 @@ async function bootstrap() { const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('api', app, document, { customSiteTitle: 'Auth' }); - const PORT = process.env.PORT || 8001; + const PORT = process.env.PORT || 8005; const loggingMode = process.env.NODE_ENV === 'production' ? 'combined' : 'dev'; app.use(morgan(loggingMode)); diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index e31bb85..e8f2a0b 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -14,6 +14,7 @@ services: environment: - MONGODB_URI=mongodb://mongodb:27017/libraryapp-book - RABBIT_MQ_URI=amqp://rabbitmq:5672 + - BASEURL_AUTH=http://auth:8005 depends_on: - mongodb - rabbitmq @@ -35,6 +36,7 @@ services: - ./apps/customer/.env environment: - MONGODB_URI=mongodb://mongodb:27017/libraryapp-customer + - BASEURL_AUTH=http://auth:8005 depends_on: - mongodb # ports: @@ -55,6 +57,7 @@ services: environment: - MONGODB_URI=mongodb://mongodb:27017/libraryapp-borrowing - RABBIT_MQ_URI=amqp://rabbitmq:5672 + - BASEURL_AUTH=http://auth:8005 depends_on: - mongodb - rabbitmq @@ -77,6 +80,7 @@ services: environment: - MONGODB_URI=mongodb://mongodb:27017/libraryapp-payment - RABBIT_MQ_URI=amqp://rabbitmq:5672 + - BASEURL_AUTH=http://auth:8005 depends_on: - mongodb - rabbitmq @@ -87,6 +91,28 @@ services: links: - mongodb - rabbitmq + auth: + build: + context: . + dockerfile: ./apps/Dockerfile.service + target: production + args: + service: auth + env_file: + - ./apps/auth/.env + depends_on: + - mongodb + # ports: + # - '8005:8005' + networks: + - node-network + links: + - book + - customer + - borrowing + - payment + environment: + - BASEURL_CUSTOMER=http://customer:8002 notification: build: context: . @@ -119,6 +145,7 @@ services: - customer - borrowing - payment + - auth - notification ports: - '8000:8000' @@ -133,8 +160,6 @@ services: service: apigateway env_file: - ./apps/apigateway/.env - depends_on: - - view ports: - '8080:8080' networks: @@ -144,11 +169,13 @@ services: - customer - borrowing - payment + - auth environment: - BASEURL_BOOK=http://book:8001 - BASEURL_CUSTOMER=http://customer:8002 - BASEURL_BORROWING=http://borrowing:8003 - BASEURL_PAYMENT=http://payment:8004 + - BASEURL_AUTH=http://auth:8005 # Dependencies rabbitmq: diff --git a/docker-compose.yml b/docker-compose.yml index 82b0db8..853cfe4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,7 @@ services: environment: - MONGODB_URI=mongodb://mongodb:27017/libraryapp-book - RABBIT_MQ_URI=amqp://rabbitmq:5672 + - BASEURL_AUTH=http://auth:8005 depends_on: - mongodb - rabbitmq @@ -40,6 +41,7 @@ services: - ./apps/customer/.env environment: - MONGODB_URI=mongodb://mongodb:27017/libraryapp-customer + - BASEURL_AUTH=http://auth:8005 depends_on: - mongodb volumes: @@ -65,6 +67,7 @@ services: environment: - MONGODB_URI=mongodb://mongodb:27017/libraryapp-borrowing - RABBIT_MQ_URI=amqp://rabbitmq:5672 + - BASEURL_AUTH=http://auth:8005 depends_on: - mongodb - rabbitmq @@ -92,6 +95,7 @@ services: environment: - MONGODB_URI=mongodb://mongodb:27017/libraryapp-payment - RABBIT_MQ_URI=amqp://rabbitmq:5672 + - BASEURL_AUTH=http://auth:8005 depends_on: - mongodb - rabbitmq @@ -105,6 +109,30 @@ services: links: - mongodb - rabbitmq + auth: + image: libraryapp-dev-auth + build: + context: . + dockerfile: ./apps/Dockerfile.service + target: development + args: + service: auth + env_file: + - ./apps/auth/.env + depends_on: + - mongodb + ports: + - '8005:8005' + networks: + - node-network + links: + - book + - customer + - borrowing + - payment + command: npm run start:dev auth + environment: + - BASEURL_CUSTOMER=http://customer:8002 notification: image: libraryapp-dev-notification build: @@ -123,8 +151,8 @@ services: volumes: - .:/usr/src/app - /usr/src/app/node_modules - ports: - - '8005:8005' + # ports: + # - '8005:8005' networks: - node-network links: @@ -145,6 +173,7 @@ services: - customer - borrowing - payment + - auth - notification volumes: - .:/usr/src/app @@ -165,8 +194,6 @@ services: command: npm run dev:apigateway env_file: - ./apps/apigateway/.env - depends_on: - - view volumes: - .:/usr/src/app - /usr/src/app/node_modules @@ -179,11 +206,14 @@ services: - customer - borrowing - payment + - auth environment: + - NODE_ENV=development - BASEURL_BOOK=http://book:8001 - BASEURL_CUSTOMER=http://customer:8002 - BASEURL_BORROWING=http://borrowing:8003 - BASEURL_PAYMENT=http://payment:8004 + - BASEURL_AUTH=http://auth:8005 # Dependencies rabbitmq: diff --git a/package-lock.json b/package-lock.json index e8200b6..4fe4e0c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -68,6 +68,7 @@ "@nestjs/cli": "^10.0.0", "@nestjs/schematics": "^10.0.0", "@nestjs/testing": "^10.0.0", + "@types/bcrypt": "^5.0.2", "@types/express": "^4.17.17", "@types/jest": "^29.5.2", "@types/morgan": "^1.9.9",