This repository has been archived by the owner on Jul 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
65 lines (44 loc) · 2.92 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Set our default Windows Server LTSC version to 2022
ARG win_version=ltsc2022
# Pull our Windows Container from the Microsoft Container Registry
FROM mcr.microsoft.com/windows/servercore:$win_version as build
# Set our shell to PowerShell and specify error handling
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
# Set our default Nim version, see the note in README.md, this is automatically overridden by the GitHub Actions workflow with the latest versions polled from GitHub
ARG nim_version=1.6.12
# Build our Nim download URL using our Nim version
ARG nim_uri="https://nim-lang.org/download/nim-"$nim_version"_x64.zip"
# Download compiled Nim binaries, saving them as nim.zip to simplify things
RUN Invoke-WebRequest -Uri $env:nim_uri -OutFile nim.zip
# Expand nim.zip to c:\
RUN Expand-Archive -Path 'nim.zip' -DestinationPath 'c:\'
# Rename the resulting extracted directory, e.g. c:\nim-1.4.8, to just c:\nim, to provide a consistent location
RUN Get-ChildItem -Path 'c:\' | Where-Object { $_.Name -like 'nim-*' } | %{ Rename-Item -LiteralPath $_.FullName -NewName 'nim' }
# Download compatible mingw binaries as mingw.7z (ported from finish.exe)
RUN Invoke-WebRequest -Uri "https://nim-lang.org/download/mingw64.7z" -OutFile mingw.7z
# Expand mingw.7z to c:\nim\dist (ported from finish.exe)
RUN cd "c:\nim\dist"; "c:\nim\bin\7zG.exe" x "c:\mingw.7z"
# Build our MinGit download URL using our MinGit version
ARG mingit_uri="https://github.com/git-for-windows/git/releases/download/v2.40.0.windows.1/MinGit-2.40.0-64-bit.zip"
# Download compiled MinGit binaries, saving them as mingit.zip to simplify things
RUN echo "$env:mingit_uri": $env:mingit_uri
RUN Invoke-WebRequest -Uri $env:mingit_uri -OutFile mingit.zip
# Expand mingit.zip to c:\nim\dist\mingit\
RUN Expand-Archive -Path 'mingit.zip' -DestinationPath 'c:\nim\dist\mingit\'
# Download Nim container pause application
RUN Invoke-WebRequest -Uri https://github.com/sirredbeard/nim-pause/releases/download/0.1/pause.exe -OutFile C:\nim\pause.exe
#---
# Pull our Windows Container from the Microsoft Container Registry
FROM mcr.microsoft.com/windows/servercore:$win_version
# Set our shell to PowerShell and specify error handling
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
# Change our Docker work directory to our extracted Nim location
WORKDIR "c:\nim"
# Set the Path environment variable to include nim, mingw, mingit, and nimble locations (ported from finish.exe)
RUN "[Environment]::SetEnvironmentVariable('Path', '${env:Path};C:\nim\bin;C:\nim\dist\mingw64\bin;${env:USERPROFILE}\.nimble\bin;c:\nim\dist\mingit\cmd', [System.EnvironmentVariableTarget]::User)"
# Copy the c:\nim directory from the build container
COPY --from=build "c:\nim" "c:\nim"
# Run Nim finish.exe non-interactively to complete Nim environment
RUN "C:\nim\finish.exe -y"
# Refresh the Nim package manager cache, see https://github.com/nim-lang/nimble
RUN "nimble update"