#ビルドイメージ
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 \
    BUILD_VERSION=${BUILD_VERSION}