Skip to content

Commit b1af464

Browse files
committed
new dockerfile based on windows nanoserver
1 parent e7d3e6c commit b1af464

File tree

1 file changed

+29
-81
lines changed

1 file changed

+29
-81
lines changed

Dockerfile

Lines changed: 29 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,42 @@
1-
# escape=`
1+
ARG IMPL_NANO_BASE=mcr.microsoft.com/powershell
2+
ARG IMPL_NANO_TAG=lts-nanoserver-ltsc2022
3+
ARG IMPL_ARTIFACTS_DIR="C:\artifacts"
4+
ARG NODE_VERSION=23.10.0
25

3-
ARG BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022-amd64
6+
# nodejs
7+
FROM ${IMPL_NANO_BASE}:${IMPL_NANO_TAG} as node
8+
SHELL ["pwsh", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
49

5-
FROM ${BASE_IMAGE}
10+
ARG NODE_VERSION
11+
ARG IMPL_ARTIFACTS_DIR
612

7-
SHELL ["cmd", "/S", "/C"]
13+
RUN New-Item -ItemType Directory -Force -Path "C:\Temp", $env:IMPL_ARTIFACTS_DIR && Invoke-WebRequest -Uri https://nodejs.org/download/release/latest/node-v$env:NODE_VERSION-win-x64.zip -OutFile C:\Temp\nodejs.zip && tar -xf C:\Temp\nodejs.zip -C $env:IMPL_ARTIFACTS_DIR && Remove-Item C:\Temp\nodejs.zip && ls $env:IMPL_ARTIFACTS_DIR
814

9-
ENV GIT_VERSION=2.47.1
15+
# compiler-explorer
16+
FROM ${IMPL_NANO_BASE}:${IMPL_NANO_TAG} as compiler-explorer
17+
SHELL ["pwsh", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
1018

11-
RUN `
12-
# Download Git
13-
`
14-
curl -SL --output git.zip https://github.com/git-for-windows/git/releases/download/v%GIT_VERSION%.windows.1/MinGit-%GIT_VERSION%-64-bit.zip `
15-
`
16-
&& mkdir "C:\\git" `
17-
`
18-
&& tar -xf git.zip -C "C:\\git" `
19-
`
20-
&& setx PATH "%PATH%;C:\\git\\cmd" /M `
21-
`
22-
&& del /q git.zip
23-
24-
RUN `
25-
# Post git configuration
26-
`
27-
git config --system --add safe.directory *
19+
ARG IMPL_ARTIFACTS_DIR
2820

29-
ENV PYTHON_VERSION=3.11.0
21+
RUN New-Item -ItemType Directory -Force -Path "C:\Temp", $env:IMPL_ARTIFACTS_DIR && Invoke-WebRequest -Uri https://github.com/Devsh-Graphics-Programming/compiler-explorer/archive/refs/heads/main.zip -OutFile C:\Temp\CompilerExplorer.zip && tar -xf C:\Temp\CompilerExplorer.zip -C $env:IMPL_ARTIFACTS_DIR && Remove-Item C:\Temp\CompilerExplorer.zip
3022

31-
RUN `
32-
# Download Python
33-
`
34-
curl -SL --output python.zip https://www.python.org/ftp/python/%PYTHON_VERSION%/python-%PYTHON_VERSION%-embed-amd64.zip `
35-
`
36-
&& mkdir "C:\\python" `
37-
`
38-
&& tar -xf python.zip -C "C:\\python" `
39-
`
40-
&& setx PATH "%PATH%;C:\\python" /M `
41-
`
42-
&& del /q python.zip
23+
# final image
24+
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
25+
SHELL ["cmd.exe", "/C"]
4326

44-
ENV NODEJS_MSI=https://nodejs.org/dist/v18.19.0/node-v18.19.0-x64.msi
27+
ARG IMPL_ARTIFACTS_DIR
28+
ARG NODE_VERSION
4529

46-
RUN `
47-
# Install Node LTS
48-
`
49-
curl -SL --output nodejs.msi %NODEJS_MSI% `
50-
`
51-
&& msiexec /i nodejs.msi /qn `
52-
`
53-
&& del /q nodejs.msi
30+
COPY --link --from=node ["${IMPL_ARTIFACTS_DIR}/node-v${NODE_VERSION}-win-x64", "C:/Node"]
31+
COPY --link --from=compiler-explorer ["${IMPL_ARTIFACTS_DIR}/compiler-explorer-main", "C:/Compiler-Explorer"]
5432

55-
ENV GIT_GODBOLT_REPOSITORY_PATH=C:\compiler-explorer
56-
ENV CE_URL=https://github.com/Devsh-Graphics-Programming/compiler-explorer.git
57-
ENV CE_SHA=ce980aded514ae6a0a1b1f63e7fb358e57c9ed57
33+
USER ContainerAdministrator
34+
ENV NODE_VERSION=${NODE_VERSION} NODE_OPTIONS="--max-old-space-size=4096" GIT_VERSION=${GIT_VERSION} PATH="C:\Windows\system32;C\Windows;C:\Program Files\PowerShell;C:\Git\cmd;C:\Git\bin;C:\Git\usr\bin;C:\Git\mingw64\bin;C:\Node"
5835

59-
RUN `
60-
# Checkout Compiler-Explorer
61-
`
62-
mkdir %GIT_GODBOLT_REPOSITORY_PATH% `
63-
`
64-
&& git -C %GIT_GODBOLT_REPOSITORY_PATH% init `
65-
`
66-
&& git -C %GIT_GODBOLT_REPOSITORY_PATH% remote add origin %CE_URL% `
67-
`
68-
&& git -C %GIT_GODBOLT_REPOSITORY_PATH% fetch --depth=1 -- origin %CE_SHA% `
69-
`
70-
&& git -C %GIT_GODBOLT_REPOSITORY_PATH% checkout %CE_SHA% `
71-
`
72-
&& setx GIT_GODBOLT_REPOSITORY_PATH %GIT_GODBOLT_REPOSITORY_PATH% /M
36+
EXPOSE 10240
37+
WORKDIR C:\\Compiler-Explorer
7338

74-
ENV NODE_OPTIONS="--max-old-space-size=4096"
39+
RUN npm install && npm run webpack
7540

76-
RUN `
77-
# Install Node.js dependencies & precompile production
78-
`
79-
cd %GIT_GODBOLT_REPOSITORY_PATH% `
80-
`
81-
&& npm ci `
82-
`
83-
&& npm run webpack
84-
85-
RUN `
86-
# Post registry configuration
87-
`
88-
reg add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v "LongPathsEnabled" /t REG_DWORD /d 1 /f
89-
90-
COPY ce_healthy_check.py /ce_healthy_check.py
91-
92-
SHELL ["powershell.exe", "-ExecutionPolicy", "Bypass", "-Command"]
93-
ENTRYPOINT ["powershell.exe", "-ExecutionPolicy", "Bypass"]
94-
CMD ["-NoExit"]
41+
ENTRYPOINT ["cmd.exe", "/C"]
42+
CMD ["npm", "run", "start"]

0 commit comments

Comments
 (0)