Skip to content

Commit

Permalink
Revert "fix: remove the scripts and Dockerfile for windows os which a…
Browse files Browse the repository at this point in the history
…re unused and confusing"

This reverts commit 325495a.
  • Loading branch information
vasil-cf committed Jan 9, 2025
1 parent 5b6a397 commit 2013cfb
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
55 changes: 55 additions & 0 deletions Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
ARG OS_RELEASE

FROM mcr.microsoft.com/windows/servercore:${OS_RELEASE} as download

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ENV GIT_VERSION 2.39.0
ENV NODE_VERSION 16.20.0
ENV YARN_VERSION 1.22.19

# Download and install git
RUN Invoke-WebRequest $('https://github.com/git-for-windows/git/releases/download/v{0}.windows.1/MinGit-{0}-64-bit.zip' -f $env:GIT_VERSION) -OutFile 'MinGit.zip' -UseBasicParsing ; \
Expand-Archive c:\MinGit.zip -DestinationPath c:\MinGit; \
$env:PATH = $env:PATH + ';C:\MinGit\cmd\;C:\MinGit\cmd'; \
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $env:PATH

# Download and install node.js
RUN Invoke-WebRequest $('https://nodejs.org/dist/v{0}/node-v{0}-win-x64.zip' -f $env:NODE_VERSION) -OutFile 'node.zip' -UseBasicParsing ; \
# $sum = $(cat SHASUMS256.txt.asc | sls $(' node-v{0}-win-x64.zip' -f $env:NODE_VERSION)) -Split ' ' ; \
# if ((Get-FileHash node.zip -Algorithm sha256).Hash -ne $sum[0]) { Write-Error 'SHA256 mismatch' } ; \
Expand-Archive node.zip -DestinationPath C:\ ; \
Rename-Item -Path $('C:\node-v{0}-win-x64' -f $env:NODE_VERSION) -NewName 'C:\nodejs'

# Download and install yarn
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; \
Invoke-WebRequest $('https://github.com/yarnpkg/yarn/releases/download/v{0}/yarn-{0}.msi' -f $env:YARN_VERSION) -OutFile yarn.msi -UseBasicParsing ; \
Start-Process msiexec.exe -ArgumentList '/i', 'yarn.msi', '/quiet', '/norestart' -NoNewWindow -Wait

FROM download as install

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ENV NPM_CONFIG_LOGLEVEL info

COPY --from=download /nodejs /nodejs
COPY --from=download [ "/Program Files (x86)/yarn", "/yarn" ]

RUN $env:PATH = 'C:\nodejs;C:\yarn\bin;{0}' -f $env:PATH ; \
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine)

FROM install

WORKDIR C:/cf-container-logger

COPY package.json ./

COPY yarn.lock ./

RUN yarn install --frozen-lockfile --production

COPY . ./

LABEL owner="codefresh.io"

CMD ["powershell", "./lib/forever.ps1"]
4 changes: 4 additions & 0 deletions lib/forever.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
while ($true) {
Start-Sleep -s 1
& node dist/index.js
}
25 changes: 25 additions & 0 deletions lib/isReady.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# DEPRECATED:
# This script is no longer maintained, you should use the ./isReady.js script
# Leaving this script for backwards compatibility (so this container logger can work with older engines)

$CONTAINER_ID=$args[0]

if ( $CONTAINER_ID ) {
echo "checking if container:$CONTAINER_ID exists"
if (select-string -Pattern $CONTAINER_ID -Path ./dist/state.json) {
echo "container $CONTAINER_ID is ready"
Exit 0
} else {
echo "container $CONTAINER_ID is not ready"
Exit 1
}
} else {
echo "checking if container logger is ready"
if (select-string -Pattern "ready" -Path ./dist/state.json) {
echo "ready"
Exit 0
} else {
echo "not ready"
Exit 1
}
}

0 comments on commit 2013cfb

Please sign in to comment.