The windows image iis:windowsservercore-ltsc2019 starts IIS manually. I need to execute a command after the docker build but prior to starting IIS. The objective is to replace compiled node .env data with docker .env data at run time similar to this Alpine image example: GitHub - juanise/jvjr-docker-env-example. Unfortunately my work would like to continue using Windows images.
The docker file:
FROM mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019 as build-stage
EXPOSE 80
# install nodejs
SHELL ["cmd", "/S", "/C"]
ADD ./DockerBuildAssets/node-v16.12.0-x64.msi nodejs.msi
RUN msiexec.exe /q /i nodejs.msi
RUN del /f nodejs.msi
WORKDIR /app
COPY package*json ./
COPY .env .
RUN npm install
COPY . .
RUN npm run build
COPY jvjr-env.json /
COPY start.bat /
COPY ./DockerBuildAssets/jvjr-entrypoint.ps1 /
# Copy output to IIS
RUN xcopy .\build c:\inetpub\wwwroot /E /Q /Y
# this appears to replace / override IIS start.
CMD C:\start.bat
I have not used this image, but if it has an entrypoint as the answer indicates, you need to check that too. But another post refers to this issue on GitHub, where someone wrote a solution worked: