# # https://github.com/kubernetes/kubernetes/blob/master/test/images/windows/powershell-helper/Dockerfile_windows # https://github.com/kubernetes/kubernetes/blob/master/test/images/busybox/Dockerfile_windows # https://github.com/kubernetes/kubernetes/tree/master/test/images#windows-test-images-considerations # https://stefanscherer.github.io/find-dependencies-in-windows-containers/ # https://stackoverflow.com/questions/65104246/how-to-install-powershell-core-in-aspnet-nanoserver-docker-container # # docker build --build-arg NANO_BASE_TAG=1809 --build-arg CORE_BASE_TAG=ltsc2019 -t foobar -f Dockerfile.Windows . # docker run --rm -ti --entrypoint powershell foobar # docker run --rm -ti --entrypoint cmd foobar # docker run --rm foobar # docker save foobar -o foobar.tar # buildah pull docker-archive:foobar.tar # mcr.microsoft.com/windows/servercore:ltsc2019 # mcr.microsoft.com/windows/nanoserver:1809 ARG NANO_BASE_TAG ARG CORE_BASE_TAG FROM mcr.microsoft.com/windows/servercore:${CORE_BASE_TAG} as build SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] ENV POWERSHELL_TELEMETRY_OPTOUT="1" ARG PS_VERSION=7.5.0 ADD https://github.com/PowerShell/PowerShell/releases/download/v$PS_VERSION/PowerShell-$PS_VERSION-win-x64.zip /PowerShell/powershell.zip RUN \ Expand-Archive '/PowerShell/powershell.zip' -DestinationPath '/PowerShell' ; \ cd C:\PowerShell ; \ del powershell.zip ; \ New-Item -ItemType SymbolicLink -Path "powershell.exe" -Target "pwsh.exe" ENV NODE_VERSION 20.19.0 ENV NODE_ENV=production RUN Invoke-WebRequest $('https://nodejs.org/dist/v{0}/node-v{0}-win-x64.zip' -f $env:NODE_VERSION) -OutFile 'node.zip' -UseBasicParsing ; \ Expand-Archive node.zip -DestinationPath C:\ ; \ Rename-Item -Path $('C:\node-v{0}-win-x64' -f $env:NODE_VERSION) -NewName 'C:\nodejs' RUN mkdir \usr\local\bin; mkdir \tmp ARG RCLONE_VERSION=v1.69.1 RUN Invoke-WebRequest "https://github.com/rclone/rclone/releases/download/${env:RCLONE_VERSION}/rclone-${env:RCLONE_VERSION}-windows-amd64.zip" -OutFile '/tmp/rclone.zip' -UseBasicParsing ; \ Expand-Archive C:\tmp\rclone.zip -DestinationPath C:\tmp ; \ Copy-Item $('C:\tmp\rclone-{0}-windows-amd64\rclone.exe' -f $env:RCLONE_VERSION) -Destination "C:\usr\local\bin" ARG RESTIC_VERSION=0.18.0 RUN Invoke-WebRequest "https://github.com/restic/restic/releases/download/v${env:RESTIC_VERSION}/restic_${env:RESTIC_VERSION}_windows_amd64.zip" -OutFile '/tmp/restic.zip' -UseBasicParsing ; \ Expand-Archive C:\tmp\restic.zip -DestinationPath C:\tmp ; \ Copy-Item $('C:\tmp\restic_{0}_windows_amd64.exe' -f $env:RESTIC_VERSION) -Destination "C:\usr\local\bin\restic.exe" ARG KOPIA_VERSION=0.19.0 RUN Invoke-WebRequest "https://github.com/kopia/kopia/releases/download/v${env:KOPIA_VERSION}/kopia-${env:KOPIA_VERSION}-windows-x64.zip" -OutFile '/tmp/kopia.zip' -UseBasicParsing ; \ Expand-Archive C:\tmp\kopia.zip -DestinationPath C:\tmp ; \ Copy-Item $('C:\tmp\kopia-{0}-windows-x64\kopia.exe' -f $env:KOPIA_VERSION) -Destination "C:\usr\local\bin" ARG YQ_VERSION=v4.45.1 RUN Invoke-WebRequest "https://github.com/mikefarah/yq/releases/download/${env:YQ_VERSION}/yq_windows_amd64.zip" -OutFile '/tmp/yq.zip' -UseBasicParsing ; \ Expand-Archive C:\tmp\yq.zip -DestinationPath C:\tmp ; \ Copy-Item $('C:\tmp\yq_windows_amd64.exe') -Destination "C:\usr\local\bin\yq.exe" RUN Remove-Item C:\tmp\ -Force -Recurse # install app #RUN setx /M PATH "%PATH%;C:\nodejs" RUN setx /M PATH $(${Env:PATH} + \";C:\nodejs\") RUN node --version; npm --version; RUN mkdir /app WORKDIR /app COPY package*.json ./ RUN npm install --only=production; ls / COPY . . ###################### # actual image ###################### FROM mcr.microsoft.com/windows/nanoserver:${NANO_BASE_TAG} SHELL ["cmd.exe", "/s" , "/c"] #https://github.com/PowerShell/PowerShell-Docker/issues/236 # NOTE: this works for non-host process containers, but host process containers will have specials PATH requirements # C:\Windows\System32\WindowsPowerShell\v1.0\ ENV PATH="C:\Windows\system32;C:\Windows;C:\PowerShell;C:\app\bin;" ENV DEMOCRATIC_CSI_IS_CONTAINER=true ENV NODE_ENV=production LABEL org.opencontainers.image.source https://github.com/democratic-csi/democratic-csi LABEL org.opencontainers.image.url https://github.com/democratic-csi/democratic-csi LABEL org.opencontainers.image.licenses MIT # install powershell COPY --from=build /PowerShell /PowerShell # install app COPY --from=build /app /app WORKDIR /app COPY --from=build /nodejs/node.exe ./bin COPY --from=build /usr/local/bin/ ./bin SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue'; $verbosePreference='Continue';"] EXPOSE 50051 # this works for both host-process and non-host-process container semantics #ENTRYPOINT [ "bin/node.exe", "--expose-gc", "bin/democratic-csi" ] ADD docker/entrypoint.ps1 ./bin # NOTE: this powershell.exe could be problematic based on overriding PATH in container vs host etc ENTRYPOINT [ "powershell.exe", "bin/entrypoint.ps1" ]