From 9db2c1892e7c3512f07b7cbf30b0fd736e60d227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B9=AF=E6=9C=AC=20=E9=96=8B?= Date: Fri, 28 Jul 2023 03:56:36 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20282:=20=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=81=AE=E6=8C=99=E5=8B=95=E3=81=AB=E3=81=A4=E3=81=84?= =?UTF-8?q?=E3=81=A6=E7=A2=BA=E8=AA=8D=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task2302: エラーの挙動について確認する](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2302) - ローカル環境でのみ静的ファイルをホストするよう修正 - 不要なビルドが行われている箇所を修正 ## レビューポイント - develop/staging環境での動作に影響がなさそうか - 該当ファイルを修正しただけで問題なくCI/CDも修正される認識だが合っているか ## 動作確認状況 - ローカルで確認 --- DockerfileServerDictation.dockerfile | 10 ++-------- DockerfileServerLicense.dockerfile | 29 ---------------------------- dictation_server/src/app.module.ts | 11 +++++++++-- 3 files changed, 11 insertions(+), 39 deletions(-) delete mode 100644 DockerfileServerLicense.dockerfile diff --git a/DockerfileServerDictation.dockerfile b/DockerfileServerDictation.dockerfile index 1cfdee4..fa06e84 100644 --- a/DockerfileServerDictation.dockerfile +++ b/DockerfileServerDictation.dockerfile @@ -1,14 +1,9 @@ FROM node:18.13.0-buster AS build-container WORKDIR /app -RUN mkdir dictation_client \ - && mkdir dictation_server -COPY dictation_client/ dictation_client/ +RUN mkdir dictation_server 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 \ + && cd dictation_server \ && npm ci \ && npm run build \ && cd .. @@ -22,7 +17,6 @@ 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/ diff --git a/DockerfileServerLicense.dockerfile b/DockerfileServerLicense.dockerfile deleted file mode 100644 index 121511b..0000000 --- a/DockerfileServerLicense.dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -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_server/src/app.module.ts b/dictation_server/src/app.module.ts index a7b3f86..172cb56 100644 --- a/dictation_server/src/app.module.ts +++ b/dictation_server/src/app.module.ts @@ -43,8 +43,15 @@ import { TemplateFilesRepositoryModule } from './repositories/template_files/tem @Module({ imports: [ - ServeStaticModule.forRoot({ - rootPath: join(__dirname, '..', 'build'), + ServeStaticModule.forRootAsync({ + useFactory: () => + process.env.STAGE === 'local' + ? [ + { + rootPath: join(__dirname, '..', 'build'), + }, + ] + : [], }), ConfigModule.forRoot({ envFilePath: ['.env.local', '.env'],