diff --git a/README.md b/README.md index ccddd76..373b951 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,17 @@ The official Docker image for Doc Detective, a documentation testing framework t ## Features -- Pre-installed with Node.js and Doc Detective +- Pre-installed with + - Doc Detective + - Node.js + - Python 3 + - Java Runtime Environment (JRE) + - DITA Open Toolkit (DITA-OT) - Includes Google Chrome and Firefox for browser-based tests -- Includes DITA Open Toolkit (DITA-OT) for DITA content transformation - Optimized for CI/CD pipelines and containerized environments - Simple volume mounting for working with your local test files -> **Note:** This image runs Doc Detective in a headless mode and isn't compatible with the `record` step. If you need to record test runs, use the [Doc Detective CLI](https://github.com/doc-detective/doc-detective) directly in your local environment. +> **Note:** This image runs Doc Detective in a headless mode and isn't compatible with the `record` step. If you need to record test runs, use the [Doc Detective CLI](https://github.com/doc-detective/doc-detective) directly in your local or CI/CD environment. ## Usage diff --git a/linux.Dockerfile b/linux.Dockerfile index 6ae53f3..4244f80 100644 --- a/linux.Dockerfile +++ b/linux.Dockerfile @@ -26,6 +26,7 @@ RUN apt update \ libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 \ libxtst6 ffmpeg wget xdg-utils \ default-jre \ + python3 python3-pip python3-venv \ && update-ca-certificates \ && apt autoclean -y \ && apt autoremove -y \ @@ -44,6 +45,14 @@ RUN curl -kL https://github.com/dita-ot/dita-ot/releases/download/${DITA_OT_VERS # Add DITA-OT to PATH ENV PATH="/opt/dita-ot/bin:${PATH}" +# Check versions of installed packages +RUN node -v \ + && npm -v \ + && java -version \ + && python3 --version \ + && pip3 --version \ + && dita --version + # Create app directory WORKDIR /app diff --git a/test/ditaVersion.test.js b/test/ditaVersion.test.js deleted file mode 100644 index f04b370..0000000 --- a/test/ditaVersion.test.js +++ /dev/null @@ -1,71 +0,0 @@ -const { exec } = require("child_process"); -const assert = require("assert").strict; - -// Parse command line arguments -const args = process.argv.slice(2); -const versionArg = args.find(arg => arg.startsWith('--version=') || arg.startsWith('-v=')); -const version = versionArg ? versionArg.split('=')[1] : 'latest'; - -let os; -if (process.platform === "win32") { - os = "windows"; -} else { - os = "linux"; -} - -// Test DITA-OT version command -describe("DITA-OT is installed", function () { - // Set indefinite timeout for Docker operations - this.timeout(0); - - it("dita --version returns valid output", async () => { - return new Promise((resolve, reject) => { - let ditaVersionCmd; - if (os === "linux") { - ditaVersionCmd = `docker run --rm --entrypoint "" docdetective/docdetective:${version}-${os} dita --version`; - } else { - ditaVersionCmd = `docker run --rm --entrypoint cmd.exe docdetective/docdetective:${version}-${os} /c "dita --version"`; - } - - console.log(`Running: ${ditaVersionCmd}`); - - const ditaVersion = exec(ditaVersionCmd); - - let stdout = ""; - let stderr = ""; - - ditaVersion.stdout.on("data", (data) => { - stdout += data; - console.log(`stdout: ${data}`); - }); - - ditaVersion.stderr.on("data", (data) => { - stderr += data; - console.error(`stderr: ${data}`); - }); - - ditaVersion.on("error", (error) => { - console.error(`Error: ${error.message}`); - reject(error); - }); - - ditaVersion.on("close", (code) => { - console.log(`Child process exited with code ${code}`); - if (code !== 0) { - reject(new Error(`Docker process exited with code ${code}. stderr: ${stderr}`)); - } else { - // Verify that output contains the exact DITA-OT version 4.3.4 - const trimmedStdout = stdout.trim(); - const trimmedStderr = stderr.trim(); - - if (trimmedStdout.includes("4.3.4") || trimmedStderr.includes("4.3.4")) { - console.log("DITA-OT version 4.3.4 confirmed"); - resolve(); - } else { - reject(new Error(`Version output does not contain expected version "4.3.4". stdout: ${trimmedStdout}, stderr: ${trimmedStderr}`)); - } - } - }); - }); - }); -}); diff --git a/windows.Dockerfile b/windows.Dockerfile index ac151f3..fb0bd2f 100644 --- a/windows.Dockerfile +++ b/windows.Dockerfile @@ -1,5 +1,6 @@ FROM mcr.microsoft.com/windows/server:ltsc2022 AS system ARG PACKAGE_VERSION=latest +ARG PYTHON_VERSION=3.13.1 LABEL authors="Doc Detective" \ description="The official Docker image for Doc Detective. Keep your docs accurate with ease." \ @@ -47,9 +48,29 @@ RUN $env:Path = 'C:\Program Files\nodejs;' + $env:Path; \ npm -v; \ npm install -g npm@latest -# Install Doc Detective from NPM -RUN Set-ExecutionPolicy Bypass -Scope Process -Force; \ - npm install -g doc-detective@$env:PACKAGE_VERSION + # Download and install Python +RUN $PythonVersion = $env:PYTHON_VERSION; \ + $PythonMajorMinor = ($PythonVersion -split '\.')[0..1] -join ''; \ + $PythonUrl = 'https://www.python.org/ftp/python/' + $PythonVersion + '/python-' + $PythonVersion + '-amd64.exe'; \ + $PythonInstaller = 'C:\python-installer.exe'; \ + Write-Host 'Downloading Python...'; \ + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ + Invoke-WebRequest -Uri $PythonUrl -OutFile $PythonInstaller -UseBasicParsing; \ + Write-Host 'Installing Python...'; \ + Start-Process -FilePath $PythonInstaller -ArgumentList '/quiet', 'InstallAllUsers=1', 'PrependPath=0', 'Include_test=0' -Wait; \ + Write-Host 'Python installation completed'; \ + Remove-Item -Path $PythonInstaller -Force + +# Add Python to PATH and verify installation +RUN $PythonVersion = $env:PYTHON_VERSION; \ + $PythonMajorMinor = ($PythonVersion -split '\.')[0..1] -join ''; \ + $PythonPath = 'C:\Program Files\Python' + $PythonMajorMinor; \ + $PythonScriptsPath = 'C:\Program Files\Python' + $PythonMajorMinor + '\Scripts'; \ + $env:Path = $PythonPath + ';' + $PythonScriptsPath + ';' + $env:Path; \ + [Environment]::SetEnvironmentVariable('Path', $env:Path, [System.EnvironmentVariableTarget]::Machine); \ + Write-Host 'Verifying Python installation...'; \ + python --version; \ + pip --version; # Download and install Microsoft OpenJDK 17 RUN $JavaVersion = '17.0.14'; \ @@ -93,6 +114,10 @@ RUN $env:Path = 'C:\dita-ot\bin;' + $env:Path; \ Write-Host 'DITA-OT installed. Verifying...'; \ dita --version +# Install Doc Detective from NPM +RUN Set-ExecutionPolicy Bypass -Scope Process -Force; \ + npm install -g doc-detective@$env:PACKAGE_VERSION + # Create app directory WORKDIR /app