Skip to content

Commit bf7ffa6

Browse files
committed
create actions for godbolt base image, update Dockerfile, create unpack.bat for downstream projects
1 parent b46eaf8 commit bf7ffa6

File tree

3 files changed

+131
-12
lines changed

3 files changed

+131
-12
lines changed

.github/workflows/build-godbolt.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Godbolt
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
TAG: nano-2022
8+
9+
jobs:
10+
build-and-push:
11+
runs-on: windows-2022
12+
13+
env:
14+
entry: pwsh.exe
15+
cmd: -NoLogo -NoProfile -ExecutionPolicy Bypass
16+
17+
outputs:
18+
image_tagged: ${{ steps.vars.outputs.image_tagged }}
19+
20+
defaults:
21+
run:
22+
shell: pwsh
23+
24+
steps:
25+
- name: Checkout Repository
26+
uses: actions/checkout@v4
27+
28+
- name: Set image tag
29+
id: vars
30+
run: |
31+
$repo = $env:GITHUB_REPOSITORY.ToLower()
32+
$imageBase = "ghcr.io/$repo"
33+
$taggedImage = "${imageBase}:${env:TAG}"
34+
"image_tagged=$taggedImage" >> $env:GITHUB_OUTPUT
35+
36+
- name: Log in to GHCR
37+
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u $env:GITHUB_ACTOR --password-stdin
38+
39+
- name: Build Image
40+
run: |
41+
docker build `
42+
--isolation process `
43+
--build-arg "TAG=$env:TAG" `
44+
-t "${{ steps.vars.outputs.image_tagged }}" .
45+
46+
- name: Push Image
47+
run: |
48+
docker push "${{ steps.vars.outputs.image_tagged }}"
49+
50+
run-nano-container:
51+
needs: build-and-push
52+
runs-on: windows-2022
53+
54+
defaults:
55+
run:
56+
shell: pwsh
57+
58+
steps:
59+
- name: Log in to GHCR
60+
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u $env:GITHUB_ACTOR --password-stdin
61+
62+
- name: Pull Image
63+
run: docker pull "${{ needs.build-and-push.outputs.image_tagged }}"
64+
65+
- name: Run Container
66+
run: docker run --entrypoint ${{ env.entry }} --isolation process -di --name orphan "${{ needs.build-and-push.outputs.image_tagged }}" ${{ env.cmd }}
67+
68+
- name: Inspect Container
69+
run: docker inspect orphan
70+
71+
- name: Container – Inspect Godbolt Dist
72+
run: docker exec orphan ${{ env.entry }} ${{ env.cmd }} -Command node --import=tsx --no-warnings=ExperimentalWarning ./app.js --version --dist

Dockerfile

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33

44
# ---------------- GLOBAL VARS ----------------
55
ARG NODE_VERSION=23.10.0
6+
ARG ZSTD_VERSION=1.5.7
67

78
ARG GODBOLT_REMOTE=https://github.com/compiler-explorer/compiler-explorer.git
89
ARG GODBOLT_SHA=fc1b97ef9325eacbb8100d280aee0b0158a5adca
910

10-
ARG IMPL_NANO_BASE=mcr.microsoft.com/powershell
11-
ARG IMPL_NANO_TAG=lts-nanoserver-ltsc2022
1211
ARG IMPL_GIT_VERSION=2.48.1
1312
ARG IMPL_ARTIFACTS_DIR="C:\artifacts"
1413

14+
ARG IMPL_NANO_BASE=mcr.microsoft.com/powershell
15+
ARG IMPL_NANO_TAG=lts-nanoserver-ltsc2022
16+
1517
# ---------------- NODE JS ----------------
1618
FROM ${IMPL_NANO_BASE}:${IMPL_NANO_TAG} as node
1719
SHELL ["pwsh", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
@@ -21,7 +23,7 @@ ARG IMPL_ARTIFACTS_DIR
2123

2224
RUN Write-Host "Installing NodeJS $env:NODE_VERSION" ; `
2325
New-Item -ItemType Directory -Force -Path "C:\Temp", $env:IMPL_ARTIFACTS_DIR ; `
24-
Invoke-WebRequest -Uri https://nodejs.org/download/release/latest/node-v$env:NODE_VERSION-win-x64.zip -OutFile C:\Temp\nodejs.zip ; `
26+
Invoke-WebRequest -Uri https://nodejs.org/download/release/v$env:NODE_VERSION/node-v$env:NODE_VERSION-win-x64.zip -OutFile C:\Temp\nodejs.zip ; `
2527
tar -xf C:\Temp\nodejs.zip -C $env:IMPL_ARTIFACTS_DIR ; Remove-Item C:\Temp\nodejs.zip
2628

2729
# ---------------- GIT ----------------
@@ -65,24 +67,46 @@ RUN cd $env:IMPL_ARTIFACTS_DIR ; `
6567
Write-Host "Building Compiler Explorer" ; `
6668
pwsh -File build-win.ps1 -CEWD "$env:IMPL_ARTIFACTS_DIR"
6769

68-
# ---------------- FINAL IMAGE ----------------
69-
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
70+
# ---------------- ZSTD ----------------
71+
FROM ${IMPL_NANO_BASE}:${IMPL_NANO_TAG} as zstd
72+
SHELL ["pwsh", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
7073

74+
ARG ZSTD_VERSION
7175
ARG IMPL_ARTIFACTS_DIR
72-
ARG NODE_VERSION
7376

77+
RUN Write-Host "Installing Git $env:ZSTD_VERSION" ; `
78+
New-Item -ItemType Directory -Force -Path C:\Temp, $env:IMPL_ARTIFACTS_DIR ; `
79+
Invoke-WebRequest -Uri "https://github.com/facebook/zstd/releases/download/v$env:ZSTD_VERSION/zstd-v$env:ZSTD_VERSION-win64.zip" -OutFile C:\Temp\zstd.zip ; `
80+
tar -xf C:\Temp\zstd.zip -C $env:IMPL_ARTIFACTS_DIR ; `
81+
Remove-Item C:\Temp\zstd.zip
82+
83+
# ---------------- FINAL IMAGE ----------------
84+
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
7485
USER ContainerAdministrator
7586

87+
LABEL org.opencontainers.image.title="Compiler Explorer in Windows Nano Server"
88+
LABEL org.opencontainers.image.source=https://github.com/Devsh-Graphics-Programming/Compiler-Explorer-Docker
89+
LABEL org.opencontainers.image.description="Run Compiler Explorer in Windows Nano Server!"
90+
LABEL org.opencontainers.image.licenses=Apache-2.0
91+
92+
ARG IMPL_ARTIFACTS_DIR
93+
ARG NODE_VERSION
94+
COPY --link --from=zstd ["${IMPL_ARTIFACTS_DIR}", "C:/compress"]
7695
COPY --link --from=node ["${IMPL_ARTIFACTS_DIR}/node-v${NODE_VERSION}-win-x64", "C:/Node"]
7796
COPY --link --from=compiler-explorer ["${IMPL_ARTIFACTS_DIR}/out/dist", "C:/Compiler-Explorer"]
7897
COPY --link --from=compiler-explorer ["${IMPL_ARTIFACTS_DIR}/out/dist-bin/dist", "C:/Compiler-Explorer"]
7998
COPY --link --from=compiler-explorer ["${IMPL_ARTIFACTS_DIR}/out/webpack/static", "C:/Compiler-Explorer/static"]
8099

81-
ENV NODE_VERSION=${NODE_VERSION} NODE_ENV=production `
82-
PATH="C:\Windows\system32;C:\Windows;C:\Program Files\PowerShell;C:\Node"
100+
ARG ZSTD_VERSION
101+
102+
ENV NODE_VERSION=${NODE_VERSION} `
103+
NODE_ENV=production `
104+
ZSTD_VERSION=${ZSTD_VERSION} `
105+
PATH="C:\Windows\system32;C:\Windows;C:\Node;C:\compress\zstd-v${ZSTD_VERSION}-win64"
83106

84107
EXPOSE 10240
85-
WORKDIR C:\\Compiler-Explorer
86-
ENTRYPOINT ["cmd.exe", "/C"]
87-
CMD ["node", "--no-warnings", "--no-deprecation", "--import=tsx", "./app.js", "--language", "python"]
88-
# for instance, <...> --language HLSL; note we are running without any compilers in this example, one have to provide them
108+
COPY unpack.bat .
109+
WORKDIR C:\Compiler-Explorer
110+
111+
ENTRYPOINT ["cmd.exe", "/S", "/K"]
112+
CMD ["C:/unpack.bat"]

unpack.bat

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@echo off
2+
pushd C:\
3+
setlocal EnableDelayedExpansion
4+
set filecount=0
5+
for %%F in ("pack\*-artifacts.tar.zst") do set /A filecount+=1
6+
if %filecount% GTR 0 (
7+
echo Unpack started
8+
for %%Z in ("pack\*-artifacts.tar.zst") do (
9+
set "zst=%%~fZ"
10+
set "tar=%%~dpnZ.tar"
11+
if not exist "!tar!" (
12+
zstd.exe -d -T0 "!zst!" -o "!tar!"
13+
)
14+
tar.exe -xf "!tar!"
15+
del /Q "!tar!" "!zst!"
16+
)
17+
dir
18+
echo Unpack finished
19+
) else (
20+
echo No artifacts to unpack.
21+
)
22+
endlocal
23+
popd

0 commit comments

Comments
 (0)