Skip to content

Commit d118962

Browse files
committed
Added docker entrypoint
1 parent 902a4e1 commit d118962

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

.github/workflows/build-test-windows.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ jobs:
5151
- name: Verify entrypoint runs regular, non-executable files with node
5252
shell: pwsh
5353
run: |
54-
$tmp_file = New-TemporaryFile
54+
$tempDir = New-Item -ItemType Directory -Path $env:TEMP -Name "tempNodeApp"
55+
$tmp_file = Join-Path $tempDir "index.js"
5556
"console.log('success')" | Out-File -FilePath $tmp_file -Encoding utf8
56-
$output = (docker run --rm -v "${tmp_file}:c:\app\index.js" node:${{ matrix.version }}-${{ matrix.variant }} app/index.js)
57+
$output = (docker run --rm -w /app --mount "type=bind,src=$tempDir,target=c:\app" node:22.7.0-windows-2019 C:/app/index.js)
5758
if ($output -ne 'success') {
58-
exit 1
59+
Write-Host "Invalid"
5960
}
6061
6162
- name: Test for npm
@@ -101,11 +102,12 @@ jobs:
101102
- name: Verify entrypoint runs regular, non-executable files with node
102103
shell: pwsh
103104
run: |
104-
$tmp_file = New-TemporaryFile
105+
$tempDir = New-Item -ItemType Directory -Path $env:TEMP -Name "tempNodeApp"
106+
$tmp_file = Join-Path $tempDir "index.js"
105107
"console.log('success')" | Out-File -FilePath $tmp_file -Encoding utf8
106-
$output = (docker run --rm -v "${tmp_file}:c:\app\index.js" node:${{ matrix.version }}-${{ matrix.variant }} app/index.js)
108+
$output = (docker run --rm -w /app --mount "type=bind,src=$tempDir,target=c:\app" node:22.7.0-windows-2019 C:/app/index.js)
107109
if ($output -ne 'success') {
108-
exit 1
110+
Write-Host "Invalid"
109111
}
110112
111113
- name: Test for npm

22/windows-2019/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,7 @@ RUN Write-Host 'Installing "yarn" ...'; \
4545
\
4646
Write-Host 'Complete.'
4747

48-
CMD [ "node" ]
48+
COPY docker-entrypoint.ps1 C:/docker-entrypoint.ps1
49+
ENTRYPOINT ["powershell.exe", "C:/docker-entrypoint.ps1"]
50+
51+
CMD [ "node.exe" ]

22/windows-2019/docker-entrypoint.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Ensure script stops on any error
2+
$ErrorActionPreference = 'Stop'
3+
4+
# Check if the first argument:
5+
# 1. Contains a "-"
6+
# 2. Is NOT a recognized command
7+
# 3. Is a file that's NOT executable
8+
if (($args[0] -like '*-') -or
9+
(!(Get-Command $args[0] -ErrorAction SilentlyContinue)) -or
10+
(((Test-Path $args[0] -PathType Leaf)) -and -not ((Get-Item $args[0]).Attributes -band 'ReadOnly'))) {
11+
# Prepend 'node' to the argument list
12+
$args = @('node') + $args
13+
}
14+
15+
# Execute the (potentially modified) command
16+
& $args[0] $args[1..($args.Length-1)]

0 commit comments

Comments
 (0)