Skip to content

Commit d5bbe78

Browse files
fix: Refactoring Docker to use .NET SDK ( Fixes #115, Fixes #116 )
1 parent 0d9cdeb commit d5bbe78

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

Container.init.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
That is why this file is using the namespace 'mcr.microsoft.com/powershell'.
2323
(this does nothing, but most likely will be used in the future)
2424
#>
25-
using namespace 'mcr.microsoft.com/powershell AS powerShell'
25+
# using namespace 'mcr.microsoft.com/powershell AS powerShell'
2626

2727
param(
2828
# The name of the module to be installed.
@@ -107,5 +107,5 @@ if (-not $KeepGit) {
107107
# If you have any adjustments, please put them below here, in the `#region Custom`
108108

109109
#region Custom
110-
bundle config --global silence_root_warning true
110+
# bundle config --global silence_root_warning true
111111
#endregion Custom

Container.start.ps1

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
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/2bitdesigns/4bitcss'
27+
# using namespace 'ghcr.io/2bitdesigns/4bitcss'
2828

2929
param()
3030

3131
$env:IN_CONTAINER = $true
3232
$PSStyle.OutputRendering = 'Ansi'
3333

34+
$containerModule = Get-Module $env:ModuleName
35+
3436
$mountedDrives = @(if (Test-Path '/proc/mounts') {
3537
(Select-String "\S+\s(?<p>\S+).+rw?,.+symlinkroot=/mnt/host" "/proc/mounts").Matches.Groups |
3638
Where-Object Name -eq p |
@@ -47,6 +49,7 @@ if ($args) {
4749
# If there are arguments, output them (you could handle them in a more complex way).
4850
"$args" | Out-Host
4951
} else {
52+
5053
# If there are no arguments, see if there is a Microservice.ps1
5154
if (Test-Path './Microservice.ps1') {
5255
# If there is a Microservice.ps1, run it.
@@ -55,16 +58,13 @@ if ($args) {
5558
#region Custom
5659
else
5760
{
58-
Start-ThreadJob -Name "${env:ModuleName}.Jekyll" -ScriptBlock {
59-
Push-Location ./docs
60-
jekyll serve --host "$(
61-
if ($env:JEKYLL_HOST) { $env:JEKYLL_HOST }
62-
else { '*' }
63-
)" '--port' $(
64-
if ($env:JEKYLL_PORT) { $env:JEKYLL_PORT }
65-
else { 4000 }
66-
)
61+
$containerModule | Split-Path | Push-Location
62+
Push-Location $env:ModuleDomain
63+
if (Test-Path ./serve.ps1) {
64+
. ./serve.ps1
6765
}
66+
Pop-Location
67+
Pop-Location
6868
}
6969
#endregion Custom
7070
}

Container.stop.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
It can be used to perform any necessary cleanup before the container is stopped.
88
#>
99
"Container now exiting, thank you for using $env:ModuleName!" | Out-Host
10+
Get-Job | ? HttpListener | %{ $_.HttpListener.Stop() }

Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Thank you Microsoft! Thank you PowerShell! Thank you Docker!
2-
FROM mcr.microsoft.com/powershell AS powershell
2+
FROM mcr.microsoft.com/dotnet/sdk:9.0
33

44
# Set the module name to the name of the module we are building
5-
ENV ModuleName=4bitcss
6-
ENV InstallAptGet="build-essential","ruby-full","bundler","git","curl","ca-certificates","libc6","libgcc1"
7-
ENV InstallModule="ugit","PSJekyll"
8-
ENV InstallRubyGem="jekyll"
5+
ARG ModuleName=4bitcss
6+
ARG ModuleDomain=4bitcss.com
7+
ENV ModuleName=$ModuleName
8+
ENV ModuleDomain=$ModuleDomain
99

1010
# Copy the module into the container
1111
RUN --mount=type=bind,src=./,target=/Initialize /bin/pwsh -nologo -command /Initialize/Container.init.ps1
1212
# Set the entrypoint to the script we just created.
13-
ENTRYPOINT [ "/bin/pwsh","-nologo","-noexit","-file","/Container.start.ps1" ]
13+
ENTRYPOINT [ "pwsh","-nologo","-noexit","-file","/Container.start.ps1" ]

0 commit comments

Comments
 (0)