From 6db8b4cbd7634697326426259a17f04355bb0d85 Mon Sep 17 00:00:00 2001 From: "makabe.t" Date: Mon, 4 Dec 2023 08:18:18 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20599:=20=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=82=BB=E3=83=B3=E3=82=B9=E3=82=A2=E3=83=A9=E3=83=BC=E3=83=88?= =?UTF-8?q?=E9=96=A2=E9=80=A3=EF=BC=9ADockerfileFunctionDictation.dockerfi?= =?UTF-8?q?le=E3=82=92=E5=8F=82=E7=85=A7=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=A8pipeline?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task3083: ライセンスアラート関連:DockerfileFunctionDictation.dockerfileを参照するようファイルとpipelineを修正する](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3083) - Azure Functionsのイメージを`DockerfileFunctionDictation.dockerfile`で定義するように修正しました。 - マルチステージビルドの形式で必要なファイルだけ取り込んだイメージとなるようにしています。 - 既定のパス`/home/site/wwwroot`をワークディレクトリとしています。 ## レビューポイント - 生成物イメージに入れるファイルに過不足はないでしょうか? - 環境変数でのパス指定ができないため、既定のパスで動作するようにしていますが不自然な点はないでしょうか? ## UIの変更 - なし ## 動作確認状況 - develop環境でデプロイして確認 --- DockerfileFunctionDictation.dockerfile | 35 +++++++++++++++++++------- dictation_function/Dockerfile | 12 --------- 2 files changed, 26 insertions(+), 21 deletions(-) delete mode 100644 dictation_function/Dockerfile diff --git a/DockerfileFunctionDictation.dockerfile b/DockerfileFunctionDictation.dockerfile index 3dcb7b2..4b3356f 100644 --- a/DockerfileFunctionDictation.dockerfile +++ b/DockerfileFunctionDictation.dockerfile @@ -1,12 +1,29 @@ -# To enable ssh & remote debugging on app service change the base image to the one below -# FROM mcr.microsoft.com/azure-functions/node:4-node18-appservice +#ビルドイメージ +FROM node:18.17.1-buster AS build-container +WORKDIR /app +RUN mkdir dictation_function +COPY dictation_function/ dictation_function/ +RUN npm install --force -g n && n 18.17.1 \ + && cd dictation_function \ + && npm ci \ + && npm run build \ + && cd .. + +# 成果物イメージ FROM mcr.microsoft.com/azure-functions/node:4-node18 +WORKDIR /home/site/wwwroot +RUN mkdir build \ + && mkdir dist \ + && mkdir node_modules + +COPY --from=build-container app/dictation_function/dist/ dist/ +COPY --from=build-container app/dictation_function/node_modules/ node_modules/ +COPY --from=build-container app/dictation_function/.env ./ +COPY --from=build-container app/dictation_function/host.json ./ +COPY --from=build-container app/dictation_function/package.json ./ + +ARG BUILD_VERSION ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ - AzureFunctionsJobHost__Logging__Console__IsEnabled=true - -COPY . /home/site/wwwroot - -RUN cd /home/site/wwwroot && \ - npm install && \ - npm run build \ No newline at end of file + AzureFunctionsJobHost__Logging__Console__IsEnabled=true \ + BUILD_VERSION=${BUILD_VERSION} \ No newline at end of file diff --git a/dictation_function/Dockerfile b/dictation_function/Dockerfile deleted file mode 100644 index 3dcb7b2..0000000 --- a/dictation_function/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -# To enable ssh & remote debugging on app service change the base image to the one below -# FROM mcr.microsoft.com/azure-functions/node:4-node18-appservice -FROM mcr.microsoft.com/azure-functions/node:4-node18 - -ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ - AzureFunctionsJobHost__Logging__Console__IsEnabled=true - -COPY . /home/site/wwwroot - -RUN cd /home/site/wwwroot && \ - npm install && \ - npm run build \ No newline at end of file