Skip to content

Commit 7ab7f2f

Browse files
author
James Brundage
committed
fix: WebSocket Container fix ( Fixes #96 )
1 parent c2a0ec0 commit 7ab7f2f

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

Container.init.ps1

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,16 @@
1010
# Thank you Microsoft! Thank you PowerShell! Thank you Docker!
1111
FROM mcr.microsoft.com/powershell
1212
# Set the shell to PowerShell (thanks again, Docker!)
13-
SHELL ["/bin/pwsh", "-nologo", "-command"]
14-
# Run the initialization script. This will do all remaining initialization in a single layer.
15-
RUN --mount=type=bind,src=./,target=/Initialize ./Initialize/Container.init.ps1
13+
# Copy the module into the container
14+
RUN --mount=type=bind,src=./,target=/Initialize /bin/pwsh -nologo -command /Initialize/Container.init.ps1
15+
# Set the entrypoint to the script we just created.
16+
ENTRYPOINT [ "/bin/pwsh","-nologo","-noexit","-file","/Container.start.ps1" ]
1617
~~~
1718
1819
The scripts arguments can be provided with either an `ARG` or `ENV` instruction in the Dockerfile.
19-
.NOTES
20-
Did you know that in PowerShell you can 'use' namespaces that do not really exist?
21-
This seems like a nice way to describe a relationship to a container image.
22-
That is why this file is using the namespace 'mcr.microsoft.com/powershell'.
23-
(this does nothing, but most likely will be used in the future)
2420
#>
25-
using namespace 'mcr.microsoft.com/powershell AS powerShell'
21+
22+
#use container mcr.microsoft.com/powershell
2623

2724
param(
2825
# The name of the module to be installed.

Container.start.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
That is why this file is using the namespace 'mcr.microsoft.com/powershell'.
2525
(this does nothing, but most likely will be used in the future)
2626
#>
27-
using namespace 'ghcr.io/powershellweb/websocket'
27+
28+
#use container ghcr.io/powershellweb/websocket
2829

2930
param()
3031

@@ -62,7 +63,7 @@ if ($args) {
6263
# If a single drive is mounted, start the socket files.
6364
$webSocketFiles = $mountedFolders | Get-ChildItem -Filter *.WebSocket.ps1
6465
foreach ($webSocketFile in $webSocketFiles) {
65-
Start-ThreadJob -Name $webSocketFile.Name -ScriptBlock {param($webSocketFile) . $using:webSocketFile.FullName } -ArgumentList $webSocketFile
66+
Start-ThreadJob -Name $webSocketFile.Name -ScriptBlock { . $using:webSocketFile.FullName }
6667
. $webSocketFile.FullName
6768
}
6869
}

Container.stop.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
77
It can be used to perform any necessary cleanup before the container is stopped.
88
#>
9-
"Container now exiting, thank you for using WebSocket!" | Out-Host
9+
"Container now exiting, thank you for using $env:ModuleName!" | Out-Host

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Thank you Microsoft! Thank you PowerShell! Thank you Docker!
2-
FROM mcr.microsoft.com/powershell AS powershell
2+
FROM mcr.microsoft.com/powershell
33

44
# Set the module name to the name of the module we are building
55
ENV ModuleName=WebSocket

0 commit comments

Comments
 (0)