From 0fa3b0eff872c329bcc8f62e1988806acb657788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=8B=93=E6=B5=B7=20=E7=9C=9F=E5=A3=81?= Date: Tue, 14 Feb 2023 04:45:15 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=203:=20=E3=82=BF=E3=82=B9=E3=82=AF?= =?UTF-8?q?=201327:=20DevOps=E3=81=8B=E3=82=89Registry=E3=81=AB=E3=82=A4?= =?UTF-8?q?=E3=83=A1=E3=83=BC=E3=82=B8=E3=82=92=E3=83=97=E3=83=83=E3=82=B7?= =?UTF-8?q?=E3=83=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [タスク 1327: DevOpsからRegistryにイメージをプッシュ](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/OMDSDictation/_workitems/edit/1327) - AzureDevOpsでデプロイするためにDockerFile等の構成を修正しました。 ## レビューポイント - 情報共有 - コンテナの構成として認識違い、不自然な点はないか ## UIの変更 - なし ## 動作確認状況 - イメージをビルドしてプッシュできることを確認 --- DockerfileServerDictation.dockerfile | 29 +++++++++++++++++++ DockerfileServerLicense.dockerfile | 29 +++++++++++++++++++ .../src/pages/SamplePage/index.tsx | 2 +- dictation_server/src/app.module.ts | 28 +++++++++--------- dictation_server/src/health.controller.ts | 2 +- dictation_server/src/main.ts | 6 ++-- license_server/src/app.module.ts | 28 +++++++++--------- license_server/src/main.ts | 4 +-- 8 files changed, 92 insertions(+), 36 deletions(-) create mode 100644 DockerfileServerDictation.dockerfile create mode 100644 DockerfileServerLicense.dockerfile diff --git a/DockerfileServerDictation.dockerfile b/DockerfileServerDictation.dockerfile new file mode 100644 index 0000000..1cfdee4 --- /dev/null +++ b/DockerfileServerDictation.dockerfile @@ -0,0 +1,29 @@ +FROM node:18.13.0-buster AS build-container +WORKDIR /app +RUN mkdir dictation_client \ + && mkdir dictation_server +COPY dictation_client/ dictation_client/ +COPY dictation_server/ dictation_server/ +RUN npm install --force -g n && n 18.13.0 \ + && cd dictation_client \ + && npm ci \ + && npm run build \ + && cd ../dictation_server \ + && npm ci \ + && npm run build \ + && cd .. + +FROM node:18.13.0-alpine +RUN apk --no-cache add tzdata \ + && cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime \ + && apk del tzdata \ + && rm -rf /var/cache/apk/* +WORKDIR /app +RUN mkdir build \ + && mkdir dist \ + && mkdir node_modules +COPY --from=build-container app/dictation_client/build/ build/ +COPY --from=build-container app/dictation_server/dist/ dist/ +COPY --from=build-container app/dictation_server/.env ./ +COPY --from=build-container app/dictation_server/node_modules/ node_modules/ +CMD ["node", "./dist/main.js" ] \ No newline at end of file diff --git a/DockerfileServerLicense.dockerfile b/DockerfileServerLicense.dockerfile new file mode 100644 index 0000000..121511b --- /dev/null +++ b/DockerfileServerLicense.dockerfile @@ -0,0 +1,29 @@ +FROM node:18.13.0-buster AS build-container +WORKDIR /app +RUN mkdir license_client \ + && mkdir license_server +COPY license_client/ license_client/ +COPY license_server/ license_server/ +RUN npm install --force -g n && n 18.13.0 \ + && cd license_client \ + && npm ci \ + && npm run build \ + && cd ../license_server \ + && npm ci \ + && npm run build \ + && cd .. + +FROM node:18.13.0-alpine +RUN apk --no-cache add tzdata \ + && cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime \ + && apk del tzdata \ + && rm -rf /var/cache/apk/* +WORKDIR /app +RUN mkdir build \ + && mkdir dist \ + && mkdir node_modules +COPY --from=build-container app/license_client/build/ build/ +COPY --from=build-container app/license_server/dist/ dist/ +COPY --from=build-container app/license_server/.env ./ +COPY --from=build-container app/license_server/node_modules/ node_modules/ +CMD ["node", "./dist/main.js" ] \ No newline at end of file diff --git a/dictation_client/src/pages/SamplePage/index.tsx b/dictation_client/src/pages/SamplePage/index.tsx index 41413e3..b588b41 100644 --- a/dictation_client/src/pages/SamplePage/index.tsx +++ b/dictation_client/src/pages/SamplePage/index.tsx @@ -1,7 +1,7 @@ import React from "react"; const SamplePage: React.FC = () => { - return (
hello whorld
) + return (
hello whorld!
Dictation App Service Site
) }; export default SamplePage; diff --git a/dictation_server/src/app.module.ts b/dictation_server/src/app.module.ts index 8af4c4d..cf9bcf0 100644 --- a/dictation_server/src/app.module.ts +++ b/dictation_server/src/app.module.ts @@ -15,20 +15,20 @@ import { LoggerMiddleware } from './common/loggerMiddleware'; envFilePath: ['.env.local', '.env'], isGlobal: true, }), - TypeOrmModule.forRootAsync({ - imports: [ConfigModule], - useFactory: async (configService: ConfigService) => ({ - type: 'mysql', - host: configService.get('DB_ENDPOINT'), - port: configService.get('DB_PORT'), - username: configService.get('DB_USERNAME'), - password: configService.get('DB_PASSWORD'), - database: configService.get('DB_NAME'), - autoLoadEntities: true, // forFeature()で登録されたEntityを自動的にロード - synchronize: false, // trueにすると自動的にmigrationが行われるため注意 - }), - inject: [ConfigService], - }), + // TypeOrmModule.forRootAsync({ + // imports: [ConfigModule], + // useFactory: async (configService: ConfigService) => ({ + // type: 'mysql', + // host: configService.get('DB_ENDPOINT'), + // port: configService.get('DB_PORT'), + // username: configService.get('DB_USERNAME'), + // password: configService.get('DB_PASSWORD'), + // database: configService.get('DB_NAME'), + // autoLoadEntities: true, // forFeature()で登録されたEntityを自動的にロード + // synchronize: false, // trueにすると自動的にmigrationが行われるため注意 + // }), + // inject: [ConfigService], + // }), ], controllers: [HealthController], providers: [], diff --git a/dictation_server/src/health.controller.ts b/dictation_server/src/health.controller.ts index 7df0463..50f6949 100644 --- a/dictation_server/src/health.controller.ts +++ b/dictation_server/src/health.controller.ts @@ -6,6 +6,6 @@ export class HealthController { @Get() @ApiOperation({ operationId: 'checkHealth' }) checkHealth(): string { - return 'OK'; + return 'ODMS Dictation App Service Health OK'; } } diff --git a/dictation_server/src/main.ts b/dictation_server/src/main.ts index 16bf5e2..1c1914c 100644 --- a/dictation_server/src/main.ts +++ b/dictation_server/src/main.ts @@ -26,8 +26,8 @@ async function bootstrap() { const document = SwaggerModule.createDocument(app, options); SwaggerModule.setup('api', app, document); - console.log(process.env.PORT); - - await app.listen(process.env.PORT || 80); + // TODO:検証のためポートを固定 後で直す + // await app.listen(process.env.PORT || 80); + await app.listen(80); } bootstrap(); diff --git a/license_server/src/app.module.ts b/license_server/src/app.module.ts index 8af4c4d..cf9bcf0 100644 --- a/license_server/src/app.module.ts +++ b/license_server/src/app.module.ts @@ -15,20 +15,20 @@ import { LoggerMiddleware } from './common/loggerMiddleware'; envFilePath: ['.env.local', '.env'], isGlobal: true, }), - TypeOrmModule.forRootAsync({ - imports: [ConfigModule], - useFactory: async (configService: ConfigService) => ({ - type: 'mysql', - host: configService.get('DB_ENDPOINT'), - port: configService.get('DB_PORT'), - username: configService.get('DB_USERNAME'), - password: configService.get('DB_PASSWORD'), - database: configService.get('DB_NAME'), - autoLoadEntities: true, // forFeature()で登録されたEntityを自動的にロード - synchronize: false, // trueにすると自動的にmigrationが行われるため注意 - }), - inject: [ConfigService], - }), + // TypeOrmModule.forRootAsync({ + // imports: [ConfigModule], + // useFactory: async (configService: ConfigService) => ({ + // type: 'mysql', + // host: configService.get('DB_ENDPOINT'), + // port: configService.get('DB_PORT'), + // username: configService.get('DB_USERNAME'), + // password: configService.get('DB_PASSWORD'), + // database: configService.get('DB_NAME'), + // autoLoadEntities: true, // forFeature()で登録されたEntityを自動的にロード + // synchronize: false, // trueにすると自動的にmigrationが行われるため注意 + // }), + // inject: [ConfigService], + // }), ], controllers: [HealthController], providers: [], diff --git a/license_server/src/main.ts b/license_server/src/main.ts index 16bf5e2..49e20de 100644 --- a/license_server/src/main.ts +++ b/license_server/src/main.ts @@ -26,8 +26,6 @@ async function bootstrap() { const document = SwaggerModule.createDocument(app, options); SwaggerModule.setup('api', app, document); - console.log(process.env.PORT); - - await app.listen(process.env.PORT || 80); + await app.listen(80); } bootstrap();