Skip to content

Instantly share code, notes, and snippets.

@pflannery
Created June 16, 2024 05:59
Show Gist options
  • Save pflannery/9144abad685f3cf722a6213bfcb1fc59 to your computer and use it in GitHub Desktop.
Save pflannery/9144abad685f3cf722a6213bfcb1fc59 to your computer and use it in GitHub Desktop.
FROM mcr.microsoft.com/powershell:lts-7.2-nanoserver-ltsc2022
ARG NODE_ZIP=https://nodejs.org/dist/v20.14.0/node-v20.14.0-win-x64.zip
ARG NODE_PATH="C:\Program Files\nodejs"
# add node to PATH
ENV PATH "C:\Windows\system32;C:\Program Files\PowerShell;${NODE_PATH}"
# download nodejs
RUN curl.exe -o node.zip %NODE_ZIP%
RUN mkdir "%NODE_PATH%"
RUN tar.exe -xf node.zip -C "%NODE_PATH%" --strip-components=1
ARG TARGET_PATH=/my-npm-package
# copy in project files (minus the .dockerignore entries)
COPY / $TARGET_PATH
# set the $CWD to the project root
WORKDIR $TARGET_PATH
# update npm to latest
RUN npm install -g npm
# install dependencies
RUN npm ci
# set the ComSpec to tell node what shell to use
ENV ComSpec "C:\Program Files\PowerShell\pwsh.exe"
# run the tests
CMD ["pwsh.exe", "-NoLogo", "-ExecutionPolicy", "Bypass", "-Command", "npm test"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment