diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..ed4cf3c49afcf2e15690138925ccb515727daecd --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +/*/**/Dockerfile linguist-generated +docker_templates/*Dockerfile.j2 linguist-language=Dockerfile +/*/**/entrypoint.sh linguist-generated +.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000000000000000000000000000000000000..6c1b2f67f9a28bff9619d5b9a908bbd49a5d0617 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,39 @@ +name: Bug Report +description: File a bug report +title: "[Bug]: " +labels: ["bug"] +body: + - type: markdown + attributes: + value: Thanks for taking the time to fill out this bug report! + - type: input + id: image + attributes: + label: Please add the exact image (with tag) that you are using + description: Please paste the exact image (with tag) that you are using + placeholder: e.g eclipse-temurin:17-jdk + validations: + required: true + - type: input + id: docker_version + attributes: + label: Please add the version of Docker you are running + description: Please paste the output of `docker --version` into this field. + placeholder: Paste docker version here + validations: + required: true + - type: textarea + id: what-happened + attributes: + label: What happened? + description: Also tell us, what did you expect to happen? + placeholder: Tell us what you see! + value: "A bug happened!" + validations: + required: true + - type: textarea + id: logs + attributes: + label: Relevant log output + description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + render: shell diff --git a/.github/ISSUE_TEMPLATE/new-distro.yml b/.github/ISSUE_TEMPLATE/new-distro.yml new file mode 100644 index 0000000000000000000000000000000000000000..34870cf9697b66269f76cad1c271cbc2d9fd4088 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/new-distro.yml @@ -0,0 +1,44 @@ +name: New Distribution Proposal +description: Template for proposing support for a new distribution. +title: "Proposal: [Distribution Name] [Version] Support" +labels: ["PMC-agenda"] +body: + - type: markdown + attributes: + value: "## New Distribution Proposal\nThank you for proposing a new distribution for support in the Adoptium project! Please fill out the following details to help us evaluate the proposal." + + - type: input + id: distribution-name + attributes: + label: "Distribution Name" + description: "What is the name of the distribution you are proposing?" + placeholder: "e.g., Ubuntu, Fedora, etc." + validations: + required: true + + - type: input + id: distribution-version + attributes: + label: "Distribution Version" + description: "What is the version of the distribution you are proposing?" + placeholder: "e.g., 20.04, 34, etc." + validations: + required: true + + - type: textarea + id: justification + attributes: + label: "Justification for Inclusion" + description: "Please provide a detailed justification for why this distribution should be supported." + placeholder: "Explain the demand, usage statistics, community interest, etc." + validations: + required: true + + - type: checkboxes + id: lts-confirmation + attributes: + label: "Long-Term Support Confirmation" + description: "Confirm that this distribution is a Long-Term Support (LTS) version." + options: + - label: "This distribution is an LTS version and will receive long-term support from its maintainers." + required: true diff --git a/.github/agents/agentic-workflows.md b/.github/agents/agentic-workflows.md new file mode 100644 index 0000000000000000000000000000000000000000..b824e60580e156949fa3442cdf3122a3b4a34a28 --- /dev/null +++ b/.github/agents/agentic-workflows.md @@ -0,0 +1,226 @@ +--- +name: Agentic Workflows +description: GitHub Agentic Workflows (gh-aw) - Create, debug, and upgrade AI-powered workflows with intelligent prompt routing. +disable-model-invocation: true +--- + +# GitHub Agentic Workflows Agent + +This agent helps you work with **GitHub Agentic Workflows (gh-aw)**, a CLI extension for creating AI-powered workflows in natural language using markdown files. + +## What This Agent Does + +This is a **dispatcher agent** that routes your request to the appropriate specialized prompt based on your task: + +- **Creating new workflows**: Routes to `create` prompt +- **Updating existing workflows**: Routes to `update` prompt +- **Debugging workflows**: Routes to `debug` prompt +- **Upgrading workflows**: Routes to `upgrade-agentic-workflows` prompt +- **Creating report-generating workflows**: Routes to `report` prompt — consult this whenever the workflow posts status updates, audits, analyses, or any structured output as issues, discussions, or comments +- **Creating shared components**: Routes to `create-shared-agentic-workflow` prompt +- **Fixing Dependabot PRs**: Routes to `dependabot` prompt — use this when Dependabot opens PRs that modify generated manifest files (`.github/workflows/package.json`, `.github/workflows/requirements.txt`, `.github/workflows/go.mod`). Never merge those PRs directly; instead update the source `.md` files and rerun `gh aw compile --dependabot` to bundle all fixes +- **Analyzing test coverage**: Routes to `test-coverage` prompt — consult this whenever the workflow reads, analyzes, or reports on test coverage data from PRs or CI runs +- **Rendering ASCII charts in markdown**: Routes to `asciicharts` guide — consult this whenever the workflow needs compact charts that render reliably in GitHub issues, comments, or discussions +- **CLI commands and triggering workflows**: Routes to `cli-commands` guide — consult this whenever the user asks how to run, compile, debug, or manage workflows from the command line, or when they need the MCP tool equivalent of a `gh aw` command +- **Reducing token consumption / cost optimization**: Routes to `token-optimization` guide — consult this whenever the user asks how to reduce token usage, lower costs, speed up workflows, or measure the impact of prompt changes with experiments +- **Choosing workflow architectures and design patterns**: Routes to `patterns` guide — consult this whenever the user asks for strategy, architecture, operating models, or pattern selection for agentic workflows + +Workflows may optionally include: + +- **Project tracking / monitoring** (GitHub Projects updates, status reporting) +- **Orchestration / coordination** (one workflow assigning agents or dispatching and coordinating other workflows) + +## Files This Applies To + +- Workflow files: `.github/workflows/*.md` and `.github/workflows/**/*.md` +- Workflow lock files: `.github/workflows/*.lock.yml` +- Shared components: `.github/workflows/shared/*.md` +- Configuration: `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/github-agentic-workflows.md` + +## Problems This Solves + +- **Workflow Creation**: Design secure, validated agentic workflows with proper triggers, tools, and permissions +- **Workflow Debugging**: Analyze logs, identify missing tools, investigate failures, and fix configuration issues +- **Version Upgrades**: Migrate workflows to new gh-aw versions, apply codemods, fix breaking changes +- **Component Design**: Create reusable shared workflow components that wrap MCP servers + +## How to Use + +When you interact with this agent, it will: + +1. **Understand your intent** - Determine what kind of task you're trying to accomplish +2. **Route to the right prompt** - Load the specialized prompt file for your task +3. **Execute the task** - Follow the detailed instructions in the loaded prompt + +## Available Prompts + +> **Note**: The prompt and reference files listed below are located in the [`github/gh-aw`](https://github.com/github/gh-aw) repository and are **not available locally** in this repository. Load them from their public URLs. + +### Create New Workflow +**Load when**: User wants to create a new workflow from scratch, add automation, or design a workflow that doesn't exist yet + +**Prompt file**: `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/create-agentic-workflow.md` + +**Use cases**: +- "Create a workflow that triages issues" +- "I need a workflow to label pull requests" +- "Design a weekly research automation" + +### Update Existing Workflow +**Load when**: User wants to modify, improve, or refactor an existing workflow + +**Prompt file**: `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/update-agentic-workflow.md` + +**Use cases**: +- "Add web-fetch tool to the issue-classifier workflow" +- "Update the PR reviewer to use discussions instead of issues" +- "Improve the prompt for the weekly-research workflow" + +### Debug Workflow +**Load when**: User needs to investigate, audit, debug, or understand a workflow, troubleshoot issues, analyze logs, or fix errors + +**Prompt file**: `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/debug-agentic-workflow.md` + +**Use cases**: +- "Why is this workflow failing?" +- "Analyze the logs for workflow X" +- "Investigate missing tool calls in run #12345" + +### Upgrade Agentic Workflows +**Load when**: User wants to upgrade workflows to a new gh-aw version or fix deprecations + +**Prompt file**: `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/upgrade-agentic-workflows.md` + +**Use cases**: +- "Upgrade all workflows to the latest version" +- "Fix deprecated fields in workflows" +- "Apply breaking changes from the new release" + +### Create a Report-Generating Workflow +**Load when**: The workflow being created or updated produces reports — recurring status updates, audit summaries, analyses, or any structured output posted as a GitHub issue, discussion, or comment + +**Prompt file**: `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/report.md` + +**Use cases**: +- "Create a weekly CI health report" +- "Post a daily security audit to Discussions" +- "Add a status update comment to open PRs" + +### Create Shared Agentic Workflow +**Load when**: User wants to create a reusable workflow component or wrap an MCP server + +**Prompt file**: `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/create-shared-agentic-workflow.md` + +**Use cases**: +- "Create a shared component for Notion integration" +- "Wrap the Slack MCP server as a reusable component" +- "Design a shared workflow for database queries" + +### Fix Dependabot PRs +**Load when**: User needs to close or fix open Dependabot PRs that update dependencies in generated manifest files (`.github/workflows/package.json`, `.github/workflows/requirements.txt`, `.github/workflows/go.mod`) + +**Prompt file**: `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/dependabot.md` + +**Use cases**: +- "Fix the open Dependabot PRs for npm dependencies" +- "Bundle and close the Dependabot PRs for workflow dependencies" +- "Update @playwright/test to fix the Dependabot PR" + +### Analyze Test Coverage +**Load when**: The workflow reads, analyzes, or reports test coverage — whether triggered by a PR, a schedule, or a slash command. Always consult this prompt before designing the coverage data strategy. + +**Prompt file**: `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/test-coverage.md` + +**Use cases**: +- "Create a workflow that comments coverage on PRs" +- "Analyze coverage trends over time" +- "Add a coverage gate that blocks PRs below a threshold" + +### CLI Commands Reference +**Load when**: The user asks how to run, compile, debug, or manage workflows from the command line; needs the MCP tool equivalent of a `gh aw` command; or is in a restricted environment (e.g., Copilot Cloud) without direct CLI access. + +**Reference file**: `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/cli-commands.md` + +**Use cases**: +- "How do I trigger workflow X on the main branch?" +- "What's the MCP equivalent of `gh aw logs`?" +- "I'm in Copilot Cloud — how do I compile a workflow?" +- "Show me all available gh aw commands" + +### Token Consumption Optimization +**Load when**: The user asks how to reduce token usage, lower workflow costs, make a workflow faster or cheaper, or measure the impact of prompt or configuration changes. + +**Reference file**: `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/token-optimization.md` + +**Use cases**: +- "How do I reduce the token cost of this workflow?" +- "My workflow is too expensive — how do I optimize it?" +- "How do I compare token usage between two runs?" +- "Should I use gh-proxy or the MCP server?" +- "How do I use sub-agents to reduce costs?" +- "How do I measure the impact of a prompt change?" + +### Workflow Pattern Selection +**Load when**: The user asks for architecture, strategy, operating model selection, or pattern recommendations for building agentic workflows. + +**Reference file**: `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/patterns.md` + +**Use cases**: +- "Which pattern should I use for multi-repo rollout?" +- "How should I structure this workflow architecture?" +- "What pattern fits slash-command triage?" +- "Should this be DispatchOps or DailyOps?" + +## Instructions + +When a user interacts with you: + +1. **Identify the task type** from the user's request +2. **Load the appropriate prompt** from the URLs listed above +3. **Follow the loaded prompt's instructions** exactly +4. **If uncertain**, ask clarifying questions to determine the right prompt + +## Quick Reference + +```bash +# Initialize repository for agentic workflows +gh aw init + +# Generate the lock file for a workflow +gh aw compile [workflow-name] + +# Trigger a workflow on demand (preferred over gh workflow run) +gh aw run # interactive input collection +gh aw run --ref main # run on a specific branch + +# Debug workflow runs +gh aw logs [workflow-name] +gh aw audit + +# Upgrade workflows +gh aw fix --write +gh aw compile --validate +``` + +## Key Features of gh-aw + +- **Natural Language Workflows**: Write workflows in markdown with YAML frontmatter +- **AI Engine Support**: Copilot, Claude, Codex, or custom engines +- **MCP Server Integration**: Connect to Model Context Protocol servers for tools +- **Safe Outputs**: Structured communication between AI and GitHub API +- **Strict Mode**: Security-first validation and sandboxing +- **Shared Components**: Reusable workflow building blocks +- **Repo Memory**: Persistent git-backed storage for agents +- **Sandboxed Execution**: All workflows run in the Agent Workflow Firewall (AWF) sandbox, enabling full `bash` and `edit` tools by default + +## Important Notes + +- Always reference the instructions file at `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/github-agentic-workflows.md` for complete documentation +- Use the MCP tool `agentic-workflows` when running in GitHub Copilot Cloud +- Workflows must be compiled to `.lock.yml` files before running in GitHub Actions +- **Bash tools are enabled by default** - Don't restrict bash commands unnecessarily since workflows are sandboxed by the AWF +- Follow security best practices: minimal permissions, explicit network access, no template injection +- **Network configuration**: Use ecosystem identifiers (`node`, `python`, `go`, etc.) or explicit FQDNs in `network.allowed`. Bare shorthands like `npm` or `pypi` are **not** valid. See `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/network.md` for the full list of valid ecosystem identifiers and domain patterns. +- **Single-file output**: When creating a workflow, produce exactly **one** workflow `.md` file. Do not create separate documentation files (architecture docs, runbooks, usage guides, etc.). If documentation is needed, add a brief `## Usage` section inside the workflow file itself. +- **Triggering runs**: Always use `gh aw run ` to trigger a workflow on demand — not `gh workflow run .lock.yml`. `gh aw run` handles workflow resolution by short name, input parsing and validation, and correct run-tracking for agentic workflows. Use `--ref ` to run on a specific branch. +- **CLI commands reference**: For a complete guide on all `gh aw` commands and their MCP tool equivalents (for restricted environments), see `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/cli-commands.md` diff --git a/.github/aw/actions-lock.json b/.github/aw/actions-lock.json new file mode 100644 index 0000000000000000000000000000000000000000..11e3ee5382aa3e1aa09f9b500241529b68de0335 --- /dev/null +++ b/.github/aw/actions-lock.json @@ -0,0 +1,14 @@ +{ + "entries": { + "actions/github-script@v9.0.0": { + "repo": "actions/github-script", + "version": "v9.0.0", + "sha": "3a2844b7e9c422d3c10d287c895573f7108da1b3" + }, + "github/gh-aw-actions/setup@v0.81.6": { + "repo": "github/gh-aw-actions/setup", + "version": "v0.81.6", + "sha": "ba6380cc6e5be5d21677bebe04d52fb48e3abec7" + } + } +} diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000000000000000000000000000000000..146525853975ec3def57adb022610f7378c83229 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: daily + open-pull-requests-limit: 10 + exclude-paths: + - ".github/workflows/*.lock.yml" # gh aw managed workflows + groups: + codeql-action: + patterns: + - "github/codeql-action/*" +version: 2 diff --git a/.github/skills/agentic-workflows/SKILL.md b/.github/skills/agentic-workflows/SKILL.md new file mode 100644 index 0000000000000000000000000000000000000000..9648733fd24708cbe46d896a77dc35e5b8a74e78 --- /dev/null +++ b/.github/skills/agentic-workflows/SKILL.md @@ -0,0 +1,85 @@ +--- +name: agentic-workflows +description: Route gh-aw workflow design/create/debug/upgrade requests to the right prompts. +--- + +# Agentic Workflows Router + +Use this skill when a user asks to design, create, update, debug, or upgrade GitHub Agentic Workflows in this repository. + +This skill is a dispatcher: identify the task type, load the matching workflow prompt/skill file, and follow it directly. Keep responses concise and ask a clarifying question if the correct prompt is unclear. + +Read only the files you need: +Load these files from `github/gh-aw` (they are not available locally). +- `.github/aw/agentic-chat.md` +- `.github/aw/agentic-workflows-mcp.md` +- `.github/aw/asciicharts.md` +- `.github/aw/campaign.md` +- `.github/aw/charts-trending.md` +- `.github/aw/charts.md` +- `.github/aw/cli-commands.md` +- `.github/aw/context.md` +- `.github/aw/create-agentic-workflow-trigger-details.md` +- `.github/aw/create-agentic-workflow.md` +- `.github/aw/create-shared-agentic-workflow.md` +- `.github/aw/debug-agentic-workflow.md` +- `.github/aw/dependabot.md` +- `.github/aw/deployment-status.md` +- `.github/aw/experiments.md` +- `.github/aw/github-agentic-workflows.md` +- `.github/aw/github-mcp-server.md` +- `.github/aw/instructions.md` +- `.github/aw/llms.md` +- `.github/aw/loop.md` +- `.github/aw/lsp.md` +- `.github/aw/mcp-clis.md` +- `.github/aw/memory-stateful-patterns.md` +- `.github/aw/memory.md` +- `.github/aw/messages.md` +- `.github/aw/network.md` +- `.github/aw/optimize-agentic-workflow.md` +- `.github/aw/patterns.md` +- `.github/aw/pr-reviewer.md` +- `.github/aw/report.md` +- `.github/aw/reuse.md` +- `.github/aw/safe-outputs-automation.md` +- `.github/aw/safe-outputs-content.md` +- `.github/aw/safe-outputs-management.md` +- `.github/aw/safe-outputs-runtime.md` +- `.github/aw/safe-outputs.md` +- `.github/aw/serena-tool.md` +- `.github/aw/shared-safe-jobs.md` +- `.github/aw/skills.md` +- `.github/aw/subagents.md` +- `.github/aw/syntax-agentic.md` +- `.github/aw/syntax-core.md` +- `.github/aw/syntax-tools-imports.md` +- `.github/aw/syntax.md` +- `.github/aw/test-coverage.md` +- `.github/aw/test-expression.md` +- `.github/aw/token-optimization.md` +- `.github/aw/triggers.md` +- `.github/aw/update-agentic-workflow.md` +- `.github/aw/upgrade-agentic-workflows.md` +- `.github/aw/visual-regression.md` +- `.github/aw/workflow-constraints.md` +- `.github/aw/workflow-editing.md` +- `.github/aw/workflow-patterns.md` + +- `.github/skills/agentic-workflow-designer/SKILL.md` +After loading the matching workflow prompt or skill, follow it directly: +- Design workflows from scratch via interview: `skills/agentic-workflow-designer/SKILL.md` +- Create new workflows: `.github/aw/create-agentic-workflow.md` +- Update existing workflows: `.github/aw/update-agentic-workflow.md` +- Debug, audit, or investigate workflows: `.github/aw/debug-agentic-workflow.md` +- Upgrade workflows and fix deprecations: `.github/aw/upgrade-agentic-workflows.md` +- Create shared components or MCP wrappers: `.github/aw/create-shared-agentic-workflow.md` +- Create report-generating workflows: `.github/aw/report.md` +- Fix Dependabot manifest PRs: `.github/aw/dependabot.md` +- Analyze coverage workflows: `.github/aw/test-coverage.md` +- Render compact markdown charts: `.github/aw/asciicharts.md` +- Map CLI commands to MCP usage: `.github/aw/cli-commands.md` +- Choose workflow architecture and patterns: `.github/aw/patterns.md` +- Optimize token usage and cost: `.github/aw/token-optimization.md` + +When the task involves OTEL, OTLP, traces, observability backends, or telemetry-driven analysis, also read and follow `skills/otel-queries/SKILL.md` after loading the matching workflow prompt or skill. diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml new file mode 100644 index 0000000000000000000000000000000000000000..fc7453a6dd947cb412697b81f5b5db27762d145e --- /dev/null +++ b/.github/workflows/auto-merge.yml @@ -0,0 +1,16 @@ +name: Pull Request auto-merge + +on: + pull_request: + types: [labeled] + +permissions: read-all + +jobs: + automerge: + permissions: + contents: write + pull-requests: write + uses: adoptium/.github/.github/workflows/pr-auto-merge.yml@main + with: + allowed-author: eclipse-temurin-bot diff --git a/.github/workflows/check-eol.yml b/.github/workflows/check-eol.yml new file mode 100644 index 0000000000000000000000000000000000000000..dcf30cd9314de7af552f9cd01bbb78d72d0558ad --- /dev/null +++ b/.github/workflows/check-eol.yml @@ -0,0 +1,92 @@ +name: Check EOL Distros + +on: + schedule: + # Run every Monday at 09:00 UTC + - cron: '0 9 * * 1' + workflow_dispatch: + +permissions: + contents: read + issues: write + +jobs: + check-eol: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: "3.x" + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Check for expired distros + id: eol-check + run: | + python -c " + import yaml, json, sys + from eol_checker import check_eol_configs + + with open('config/temurin.yml') as f: + config = yaml.safe_load(f) + + expired = check_eol_configs(config) + if not expired: + print('No expired distros found.') + sys.exit(0) + + print(f'Found {len(expired)} expired distro(s):') + body_lines = ['## Expired Distro Report', '', 'The following base images are past their EOL date and should be removed:', ''] + for cfg, eol_date in expired: + image = cfg.get('image', cfg.get('directory', 'unknown')) + directory = cfg.get('directory', '') + line = f'- **{image}** (\`{directory}\`) — EOL {eol_date}' + print(f' {image} ({directory}) expired {eol_date}') + body_lines.append(line) + + body_lines.append('') + body_lines.append('Please remove these configurations and their generated Dockerfiles.') + + with open('eol_report.json', 'w') as f: + json.dump({'title': f'🗑️ {len(expired)} distro(s) past EOL', 'body': chr(10).join(body_lines)}, f) + " + + - name: Create issue for expired distros + if: hashFiles('eol_report.json') != '' + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + const fs = require('fs'); + const report = JSON.parse(fs.readFileSync('eol_report.json', 'utf8')); + + // Check if an open issue already exists + const issues = await github.rest.issues.listForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + labels: 'eol-cleanup', + }); + + if (issues.data.length > 0) { + // Update existing issue + await github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issues.data[0].number, + body: report.body, + }); + console.log(`Updated existing issue #${issues.data[0].number}`); + } else { + // Create new issue + await github.rest.issues.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: report.title, + body: report.body, + labels: ['eol-cleanup'], + }); + console.log('Created new EOL cleanup issue'); + } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..0626937fdf1f09d0d439baf9eb2efb5360575e65 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,32 @@ +name: Jinja CI +on: + pull_request: + paths: + - adoptium_api.py + - dockerhub_doc_config_update.py + - eol_checker.py + - generate_dockerfiles.py + - test_dockerhub_doc_config_update.py + - test_eol_checker.py + - test_generate_dockerfiles.py + - requirements.txt + branches: [ main ] + +permissions: + contents: read + +jobs: + CI: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: "3.x" + + - name: Install dependencies + run: "pip3 install -r requirements.txt" + + - name: Run tests + run: python3 -m unittest discover -v -p 'test_*.py' diff --git a/.github/workflows/code-freeze.yml b/.github/workflows/code-freeze.yml new file mode 100644 index 0000000000000000000000000000000000000000..8f9f79e46db88428edb997382c2db86e114e4038 --- /dev/null +++ b/.github/workflows/code-freeze.yml @@ -0,0 +1,42 @@ +# ******************************************************************************** +# Copyright (c) 2024 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made +# available under the terms of the Apache Software License 2.0 +# which is available at https://www.apache.org/licenses/LICENSE-2.0. +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************** + +name: Code Freeze Bot + +# Controls when the workflow will run +on: + pull_request_target: + issue_comment: + types: [created] + +permissions: read-all + +jobs: + # Check if the pull request target branch matches the required branch-regex? + codefreeze_branch_check: + permissions: + contents: write + pull-requests: write + uses: adoptium/.github/.github/workflows/code-freeze-regex-branch.yml@main + with: + branch-regex: "^main$" + + # Code freeze if branch-regex matches + codefreeze_if_branch_match: + permissions: + contents: write + pull-requests: write + needs: codefreeze_branch_check + uses: adoptium/.github/.github/workflows/code-freeze.yml@main + if: (github.event_name == 'pull_request_target' || (github.event_name == 'issue_comment' && github.event.issue.pull_request)) && needs.codefreeze_branch_check.outputs.regex-matches == 'true' + secrets: inherit diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000000000000000000000000000000000000..3139ed3f779e7fd1e3a8143c51a7d5d134a42f7a --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,73 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: ["main"] + pull_request: + # The branches below must be a subset of the branches above + branches: ["main"] + schedule: + - cron: "0 0 * * 1" + +permissions: + contents: read + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: ["python"] + # CodeQL supports [ $supported-codeql-languages ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@d1ba80a13dd99fba24a470575428917156a28b43 # v4.37.5 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@d1ba80a13dd99fba24a470575428917156a28b43 # v4.37.5 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@d1ba80a13dd99fba24a470575428917156a28b43 # v4.37.5 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml new file mode 100644 index 0000000000000000000000000000000000000000..0715d6c4604571c3337042439a6985d927cfab0f --- /dev/null +++ b/.github/workflows/copilot-setup-steps.yml @@ -0,0 +1,26 @@ +name: "Copilot Setup Steps" + +# This workflow configures the environment for GitHub Copilot Agent with gh-aw MCP server +on: + workflow_dispatch: + push: + paths: + - .github/workflows/copilot-setup-steps.yml + +jobs: + # The job MUST be called 'copilot-setup-steps' to be recognized by GitHub Copilot Agent + copilot-setup-steps: + runs-on: ubuntu-latest + + # Set minimal permissions for setup steps + # Copilot Agent receives its own token with appropriate permissions + permissions: + contents: read + + steps: + - name: Checkout repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Install gh-aw extension + uses: github/gh-aw-actions/setup-cli@029204130cb73f6ba684e56428c7f3e9319b708c # v0.84.1 + with: + version: v0.81.6 diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml new file mode 100644 index 0000000000000000000000000000000000000000..4b13985da717026d840cbfff427b3b646a71103d --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,12 @@ +# This is a templated file from https://github.com/adoptium/.eclipsefdn/tree/main/otterdog/blueprints/require_dependabot_auto_merge.yml +name: Dependabot auto-merge +on: pull_request_target + +permissions: read-all + +jobs: + dependabot: + permissions: + contents: write + pull-requests: write + uses: adoptium/.github/.github/workflows/dependabot-auto-merge.yml@main diff --git a/.github/workflows/dockerfile-readiness.lock.yml b/.github/workflows/dockerfile-readiness.lock.yml new file mode 100644 index 0000000000000000000000000000000000000000..3f08399a7bfa5dddb08c2958da23b0e76a2bf158 --- /dev/null +++ b/.github/workflows/dockerfile-readiness.lock.yml @@ -0,0 +1,1639 @@ +# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"813eeeef6cb7592ffba257901fcb92ea06abd03fc540e21521b53d2dedfcbcfe","body_hash":"7b73ef7f38bf6ff9b9e6230fbe766010f22e5c601a932fdb57174643790ae9f9","compiler_version":"v0.81.6","strict":true,"agent_id":"copilot","engine_versions":{"copilot":"1.0.65"}} +# gh-aw-manifest: {"version":1,"secrets":["GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN"],"actions":[{"repo":"actions/cache/restore","sha":"27d5ce7f107fe9357f9df03efb73ab90386fccae","version":"v5.0.5"},{"repo":"actions/cache/save","sha":"27d5ce7f107fe9357f9df03efb73ab90386fccae","version":"v5.0.5"},{"repo":"actions/checkout","sha":"9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0","version":"v7.0.0"},{"repo":"actions/download-artifact","sha":"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c","version":"v8.0.1"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-node","sha":"48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e","version":"v6.4.0"},{"repo":"actions/setup-python","sha":"ece7cb06caefa5fff74198d8649806c4678c61a1","version":"v6.3.0"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"},{"repo":"github/gh-aw-actions/setup","sha":"ba6380cc6e5be5d21677bebe04d52fb48e3abec7","version":"v0.81.6"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.27.11","digest":"sha256:979723c628182da7729333f2208bb249fd25ddee579645cf9a3892d681a929c7","pinned_image":"ghcr.io/github/gh-aw-firewall/agent:0.27.11@sha256:979723c628182da7729333f2208bb249fd25ddee579645cf9a3892d681a929c7"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.27.11","digest":"sha256:807e4831999b44513b0a66e5859d478dc4da7ae74ab1918cec967d513f95bf9d","pinned_image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.27.11@sha256:807e4831999b44513b0a66e5859d478dc4da7ae74ab1918cec967d513f95bf9d"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.27.11","digest":"sha256:ff27ea0525ad953a6adee28a5fbe9d2e22be47dbec755c15767af4ea3f91df7d","pinned_image":"ghcr.io/github/gh-aw-firewall/squid:0.27.11@sha256:ff27ea0525ad953a6adee28a5fbe9d2e22be47dbec755c15767af4ea3f91df7d"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.3.30","digest":"sha256:35625d1a2269b1238606078c879f59a91cffc4ac33eb54bf39c6418822c1a8be","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.3.30@sha256:35625d1a2269b1238606078c879f59a91cffc4ac33eb54bf39c6418822c1a8be"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:529d02eb970b1161aa25c593a9c3df57fdfad5a8add328cb3b6eccef66f3183b","pinned_image":"ghcr.io/github/gh-aw-node@sha256:529d02eb970b1161aa25c593a9c3df57fdfad5a8add328cb3b6eccef66f3183b"},{"image":"ghcr.io/github/github-mcp-server:v1.4.0","digest":"sha256:2afb26356481d1a350e14544a6e160f7f7ec1561a1ea309b823665abf0309036","pinned_image":"ghcr.io/github/github-mcp-server:v1.4.0@sha256:2afb26356481d1a350e14544a6e160f7f7ec1561a1ea309b823665abf0309036"}]} +# This file was automatically generated by gh-aw (v0.81.6). DO NOT EDIT. To debug this workflow, load the skill at https://github.com/github/gh-aw/blob/main/debug.md +# +# ___ _ _ +# / _ \ | | (_) +# | |_| | __ _ ___ _ __ | |_ _ ___ +# | _ |/ _` |/ _ \ '_ \| __| |/ __| +# | | | | (_| | __/ | | | |_| | (__ +# \_| |_/\__, |\___|_| |_|\__|_|\___| +# __/ | +# _ _ |___/ +# | | | | / _| | +# | | | | ___ _ __ _ __| |_| | _____ ____ +# | |/\| |/ _ \ '__| |/ /| _| |/ _ \ \ /\ / / ___| +# \ /\ / (_) | | | | ( | | | | (_) \ V V /\__ \ +# \/ \/ \___/|_| |_|\_\|_| |_|\___/ \_/\_/ |___/ +# +# +# To update this file, edit the corresponding .md file and run: +# gh aw compile +# Not all edits will cause changes to this file. +# +# For more information: https://github.github.com/gh-aw/introduction/overview/ +# +# +# Secrets used: +# - GH_AW_GITHUB_MCP_SERVER_TOKEN +# - GH_AW_GITHUB_TOKEN +# - GITHUB_TOKEN +# +# Custom actions used: +# - actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 +# - actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 +# - actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 +# - actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 +# - actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 +# - actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 (source v9) +# - actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 +# - actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 +# - actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 +# - github/gh-aw-actions/setup@ba6380cc6e5be5d21677bebe04d52fb48e3abec7 # v0.81.6 +# +# Container images used: +# - ghcr.io/github/gh-aw-firewall/agent:0.27.11@sha256:979723c628182da7729333f2208bb249fd25ddee579645cf9a3892d681a929c7 +# - ghcr.io/github/gh-aw-firewall/api-proxy:0.27.11@sha256:807e4831999b44513b0a66e5859d478dc4da7ae74ab1918cec967d513f95bf9d +# - ghcr.io/github/gh-aw-firewall/squid:0.27.11@sha256:ff27ea0525ad953a6adee28a5fbe9d2e22be47dbec755c15767af4ea3f91df7d +# - ghcr.io/github/gh-aw-mcpg:v0.3.30@sha256:35625d1a2269b1238606078c879f59a91cffc4ac33eb54bf39c6418822c1a8be +# - ghcr.io/github/gh-aw-node@sha256:529d02eb970b1161aa25c593a9c3df57fdfad5a8add328cb3b6eccef66f3183b +# - ghcr.io/github/github-mcp-server:v1.4.0@sha256:2afb26356481d1a350e14544a6e160f7f7ec1561a1ea309b823665abf0309036 + +name: "Dockerfile Readiness Report" +on: + pull_request: + paths: + - "*/jdk/**" + - "*/jre/**" + workflow_dispatch: + inputs: + aw_context: + default: "" + description: "Agent caller context (used internally by Agentic Workflows)." + required: false + type: string + pr-number: + description: PR number to analyze + required: true + type: number + +permissions: {} + +concurrency: + cancel-in-progress: true + group: dockerfile-readiness-${{ github.ref }} + +run-name: "Dockerfile Readiness Report" + +jobs: + activation: + needs: pre_activation + if: > + needs.pre_activation.outputs.activated == 'true' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.id == github.repository_id) + runs-on: ubuntu-slim + permissions: + actions: read + contents: read + env: + GH_AW_MAX_DAILY_AI_CREDITS: ${{ vars.GH_AW_DEFAULT_MAX_DAILY_AI_CREDITS || '5000' }} + GH_AW_RUNTIME_FEATURES: ${{ vars.GH_AW_RUNTIME_FEATURES }} + outputs: + body: ${{ steps.sanitized.outputs.body }} + comment_id: "" + comment_repo: "" + daily_ai_credits_exceeded: ${{ steps.daily-effective-workflow-guardrail.outputs.daily_ai_credits_exceeded == 'true' }} + daily_ai_credits_threshold: ${{ steps.daily-effective-workflow-guardrail.outputs.daily_ai_credits_threshold || '' }} + daily_ai_credits_total_effective_tokens: ${{ steps.daily-effective-workflow-guardrail.outputs.daily_ai_credits_total_effective_tokens || '' }} + engine_id: ${{ steps.generate_aw_info.outputs.engine_id }} + lockdown_check_failed: ${{ steps.generate_aw_info.outputs.lockdown_check_failed == 'true' }} + model: ${{ steps.generate_aw_info.outputs.model }} + setup-parent-span-id: ${{ steps.setup.outputs.parent-span-id || steps.setup.outputs.span-id }} + setup-span-id: ${{ steps.setup.outputs.span-id }} + setup-trace-id: ${{ steps.setup.outputs.trace-id }} + stale_lock_file_failed: ${{ steps.check-lock-file.outputs.stale_lock_file_failed == 'true' }} + text: ${{ steps.sanitized.outputs.text }} + title: ${{ steps.sanitized.outputs.title }} + steps: + - name: Setup Scripts + id: setup + uses: github/gh-aw-actions/setup@ba6380cc6e5be5d21677bebe04d52fb48e3abec7 # v0.81.6 + with: + destination: ${{ runner.temp }}/gh-aw/actions + job-name: ${{ github.job }} + trace-id: ${{ needs.pre_activation.outputs.setup-trace-id }} + parent-span-id: ${{ needs.pre_activation.outputs.setup-parent-span-id || needs.pre_activation.outputs.setup-span-id }} + safe-output-artifact-client: ${{ env.GH_AW_MAX_DAILY_AI_CREDITS != '' }} + env: + GH_AW_SETUP_WORKFLOW_NAME: "Dockerfile Readiness Report" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/dockerfile-readiness.lock.yml@${{ github.ref }} + GH_AW_INFO_VERSION: "1.0.65" + GH_AW_INFO_AWF_VERSION: "v0.27.11" + GH_AW_INFO_ENGINE_ID: "copilot" + - name: Generate agentic run info + id: generate_aw_info + env: + GH_AW_INFO_ENGINE_ID: "copilot" + GH_AW_INFO_ENGINE_NAME: "GitHub Copilot CLI" + GH_AW_INFO_MODEL: ${{ vars.GH_AW_MODEL_AGENT_COPILOT || vars.GH_AW_DEFAULT_MODEL_COPILOT || 'claude-sonnet-4.6' }} + GH_AW_INFO_VERSION: "1.0.65" + GH_AW_INFO_AGENT_VERSION: "1.0.65" + GH_AW_INFO_CLI_VERSION: "v0.81.6" + GH_AW_INFO_WORKFLOW_NAME: "Dockerfile Readiness Report" + GH_AW_INFO_EXPERIMENTAL: "false" + GH_AW_INFO_SUPPORTS_TOOLS_ALLOWLIST: "true" + GH_AW_INFO_STAGED: "false" + GH_AW_INFO_ALLOWED_DOMAINS: '["defaults"]' + GH_AW_INFO_FIREWALL_ENABLED: "true" + GH_AW_INFO_AWF_VERSION: "v0.27.11" + GH_AW_INFO_AWMG_VERSION: "" + GH_AW_INFO_FIREWALL_TYPE: "squid" + GH_AW_COMPILED_STRICT: "true" + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/generate_aw_info.cjs'); + await main(core, context); + - name: Restore daily AIC usage cache + id: restore-daily-aic-cache + if: ${{ env.GH_AW_MAX_DAILY_AI_CREDITS != '' }} + continue-on-error: true + uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + key: agentic-workflow-usage-dockerfilereadiness-${{ github.run_id }} + restore-keys: agentic-workflow-usage-dockerfilereadiness- + path: /tmp/gh-aw/agentic-workflow-usage-cache.jsonl + - name: Restore daily AIC usage cache (artifact fallback) + id: restore-daily-aic-cache-fallback + if: ${{ env.GH_AW_MAX_DAILY_AI_CREDITS != '' }} + continue-on-error: true + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_AW_RESTORE_DAILY_AIC_CACHE_HIT: ${{ steps.restore-daily-aic-cache.outputs.cache-hit }} + GH_AW_RESTORE_DAILY_AIC_CACHE_MATCHED_KEY: ${{ steps.restore-daily-aic-cache.outputs.cache-matched-key }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/restore_aic_usage_cache_fallback.cjs'); + await main(); + - name: Check daily workflow token guardrail + id: daily-effective-workflow-guardrail + if: ${{ env.GH_AW_MAX_DAILY_AI_CREDITS != '' }} + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_AW_WORKFLOW_NAME: "Dockerfile Readiness Report" + GH_AW_WORKFLOW_ID: "dockerfile-readiness" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + GH_AW_WORKFLOW_DISPATCH_AW_CONTEXT: ${{ github.event.inputs.aw_context || '' }} + GH_AW_HAS_SLASH_COMMAND: "false" + GH_AW_HAS_LABEL_COMMAND: "false" + GH_AW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_AW_MAX_DAILY_AI_CREDITS: ${{ vars.GH_AW_DEFAULT_MAX_DAILY_AI_CREDITS || '5000' }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/check_daily_aic_workflow_guardrail.cjs'); + await main(); + - name: Checkout .github and .agents folders + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false + sparse-checkout: | + .github + .agents + .antigravity + .claude + .codex + .crush + .gemini + .opencode + .pi + sparse-checkout-cone-mode: true + fetch-depth: 1 + - name: Save agent config folders for base branch restoration + env: + GH_AW_AGENT_FOLDERS: ".agents .antigravity .claude .codex .crush .gemini .github .opencode .pi" + GH_AW_AGENT_FILES: ".crush.json AGENTS.md ANTIGRAVITY.md CLAUDE.md GEMINI.md PI.md opencode.jsonc" + # poutine:ignore untrusted_checkout_exec + run: bash "${RUNNER_TEMP}/gh-aw/actions/save_base_github_folders.sh" + - name: Check workflow lock file + id: check-lock-file + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_AW_WORKFLOW_FILE: "dockerfile-readiness.lock.yml" + GH_AW_CONTEXT_WORKFLOW_REF: "${{ github.workflow_ref }}" + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/check_workflow_timestamp_api.cjs'); + await main(); + - name: Check compile-agentic version + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_AW_COMPILED_VERSION: "v0.81.6" + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/check_version_updates.cjs'); + await main(); + - name: Compute current body text + id: sanitized + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_AW_ALLOWED_DOMAINS: "api.business.githubcopilot.com,api.enterprise.githubcopilot.com,api.github.com,api.githubcopilot.com,api.individual.githubcopilot.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,github.com,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,ppa.launchpad.net,raw.githubusercontent.com,registry.npmjs.org,s.symcb.com,s.symcd.com,security.ubuntu.com,telemetry.enterprise.githubcopilot.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com" + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/compute_text.cjs'); + await main(); + - name: Log runtime features + if: ${{ contains(toJSON(vars), '"GH_AW_RUNTIME_FEATURES":') }} + run: bash "${RUNNER_TEMP}/gh-aw/actions/log_runtime_features_summary.sh" + - name: Create prompt with built-in context + env: + GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt + GH_AW_SAFE_OUTPUTS: ${{ runner.temp }}/gh-aw/safeoutputs/outputs.jsonl + GH_AW_EXPR_1A3A194A: ${{ github.event.discussion.number || (fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_type == 'discussion' && fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_number) }} + GH_AW_EXPR_463A214A: ${{ github.event.pull_request.number || (fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_type == 'pull_request' && fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_number) }} + GH_AW_EXPR_802A9F6A: ${{ github.event.issue.number || (fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_type == 'issue' && fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_number) }} + GH_AW_EXPR_FF1D34CE: ${{ github.event.comment.id || fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').comment_id }} + GH_AW_GITHUB_ACTOR: ${{ github.actor }} + GH_AW_GITHUB_REPOSITORY: ${{ github.repository }} + GH_AW_GITHUB_RUN_ID: ${{ github.run_id }} + GH_AW_GITHUB_WORKSPACE: ${{ github.workspace }} + # poutine:ignore untrusted_checkout_exec + run: | + bash "${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh" + { + cat << 'GH_AW_PROMPT_3ea989b9863e7e22_EOF' + + GH_AW_PROMPT_3ea989b9863e7e22_EOF + cat "${RUNNER_TEMP}/gh-aw/prompts/xpia.md" + cat "${RUNNER_TEMP}/gh-aw/prompts/temp_folder_prompt.md" + cat "${RUNNER_TEMP}/gh-aw/prompts/markdown.md" + cat "${RUNNER_TEMP}/gh-aw/prompts/safe_outputs_prompt.md" + cat << 'GH_AW_PROMPT_3ea989b9863e7e22_EOF' + + Tools: add_comment, missing_tool, missing_data, noop + + GH_AW_PROMPT_3ea989b9863e7e22_EOF + cat "${RUNNER_TEMP}/gh-aw/prompts/mcp_cli_tools_prompt.md" + cat << 'GH_AW_PROMPT_3ea989b9863e7e22_EOF' + + The following GitHub context information is available for this workflow: + {{#if github.actor}} + - **actor**: __GH_AW_GITHUB_ACTOR__ + {{/if}} + {{#if github.repository}} + - **repository**: __GH_AW_GITHUB_REPOSITORY__ + {{/if}} + {{#if github.workspace}} + - **workspace**: __GH_AW_GITHUB_WORKSPACE__ + {{/if}} + {{#if github.event.issue.number || (github.aw.context.item_type == 'issue' && github.aw.context.item_number)}} + - **issue-number**: #__GH_AW_EXPR_802A9F6A__ + {{/if}} + {{#if github.event.discussion.number || (github.aw.context.item_type == 'discussion' && github.aw.context.item_number)}} + - **discussion-number**: #__GH_AW_EXPR_1A3A194A__ + {{/if}} + {{#if github.event.pull_request.number || (github.aw.context.item_type == 'pull_request' && github.aw.context.item_number)}} + - **pull-request-number**: #__GH_AW_EXPR_463A214A__ + {{/if}} + {{#if github.event.comment.id || github.aw.context.comment_id}} + - **comment-id**: __GH_AW_EXPR_FF1D34CE__ + {{/if}} + {{#if github.run_id}} + - **workflow-run-id**: __GH_AW_GITHUB_RUN_ID__ + {{/if}} + - **checkouts**: The following repositories have been checked out and are available in the workspace: + - repo `__GH_AW_GITHUB_REPOSITORY__` → `$GITHUB_WORKSPACE` (cwd) [full history, all branches available as remote-tracking refs] + - **Note**: If a branch you need is not in the list above and is not listed as an additional fetched ref, it has NOT been checked out. For private repositories you cannot fetch it. If the branch is required and not available, exit with an error and ask the user to add it to the `fetch:` option of the `checkout:` configuration (e.g., `fetch: ["refs/pulls/open/*"]` for all open PR refs, or `fetch: ["main", "feature/my-branch"]` for specific branches). + - **Warning: No git credentials are available to the agent.** Credentials are + intentionally removed after the checkout step for security. This means any git + operation that needs to authenticate to the remote will fail. In private repositories, that includes: + - `git fetch`, `git pull`, `git clone`, and `git push` (direct push, not via safe-output tools) + - Checking out or switching to a remote branch that is not already fetched + - Deepening a shallow clone (`git fetch --unshallow`) + - On-demand blob fetches in partial/blobless clones (operations on files not in the initial checkout) + Do NOT attempt to configure credentials, run `git credential fill`, or modify `.gitconfig` — + authentication will not succeed. If you encounter credential prompts or authentication errors, + stop immediately and report the limitation rather than spending turns trying to work around it. + + + GH_AW_PROMPT_3ea989b9863e7e22_EOF + cat "${RUNNER_TEMP}/gh-aw/prompts/github_mcp_tools_with_safeoutputs_prompt.md" + cat << 'GH_AW_PROMPT_3ea989b9863e7e22_EOF' + + {{#runtime-import .github/workflows/dockerfile-readiness.md}} + GH_AW_PROMPT_3ea989b9863e7e22_EOF + } > "$GH_AW_PROMPT" + - name: Interpolate variables and render templates + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt + GH_AW_ENGINE_ID: "copilot" + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/interpolate_prompt.cjs'); + await main(); + - name: Substitute placeholders + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt + GH_AW_EXPR_1A3A194A: ${{ github.event.discussion.number || (fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_type == 'discussion' && fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_number) }} + GH_AW_EXPR_463A214A: ${{ github.event.pull_request.number || (fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_type == 'pull_request' && fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_number) }} + GH_AW_EXPR_802A9F6A: ${{ github.event.issue.number || (fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_type == 'issue' && fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_number) }} + GH_AW_EXPR_FF1D34CE: ${{ github.event.comment.id || fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').comment_id }} + GH_AW_GITHUB_ACTOR: ${{ github.actor }} + GH_AW_GITHUB_REPOSITORY: ${{ github.repository }} + GH_AW_GITHUB_RUN_ID: ${{ github.run_id }} + GH_AW_GITHUB_WORKSPACE: ${{ github.workspace }} + GH_AW_MCP_CLI_SERVERS_LIST: '- `safeoutputs` — run `safeoutputs --help` to see available tools' + GH_AW_NEEDS_PRE_ACTIVATION_OUTPUTS_ACTIVATED: ${{ needs.pre_activation.outputs.activated }} + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + + const substitutePlaceholders = require('${{ runner.temp }}/gh-aw/actions/substitute_placeholders.cjs'); + + // Call the substitution function + return await substitutePlaceholders({ + file: process.env.GH_AW_PROMPT, + substitutions: { + GH_AW_EXPR_1A3A194A: process.env.GH_AW_EXPR_1A3A194A, + GH_AW_EXPR_463A214A: process.env.GH_AW_EXPR_463A214A, + GH_AW_EXPR_802A9F6A: process.env.GH_AW_EXPR_802A9F6A, + GH_AW_EXPR_FF1D34CE: process.env.GH_AW_EXPR_FF1D34CE, + GH_AW_GITHUB_ACTOR: process.env.GH_AW_GITHUB_ACTOR, + GH_AW_GITHUB_REPOSITORY: process.env.GH_AW_GITHUB_REPOSITORY, + GH_AW_GITHUB_RUN_ID: process.env.GH_AW_GITHUB_RUN_ID, + GH_AW_GITHUB_WORKSPACE: process.env.GH_AW_GITHUB_WORKSPACE, + GH_AW_MCP_CLI_SERVERS_LIST: process.env.GH_AW_MCP_CLI_SERVERS_LIST, + GH_AW_NEEDS_PRE_ACTIVATION_OUTPUTS_ACTIVATED: process.env.GH_AW_NEEDS_PRE_ACTIVATION_OUTPUTS_ACTIVATED + } + }); + - name: Validate prompt placeholders + env: + GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt + # poutine:ignore untrusted_checkout_exec + run: bash "${RUNNER_TEMP}/gh-aw/actions/validate_prompt_placeholders.sh" + - name: Print prompt + env: + GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt + # poutine:ignore untrusted_checkout_exec + run: bash "${RUNNER_TEMP}/gh-aw/actions/print_prompt_summary.sh" + - name: Upload activation artifact + if: success() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: activation + include-hidden-files: true + path: | + /tmp/gh-aw/aw_info.json + /tmp/gh-aw/models.json + /tmp/gh-aw/aw-prompts/prompt.txt + /tmp/gh-aw/aw-prompts/prompt-template.txt + /tmp/gh-aw/aw-prompts/prompt-import-tree.json + /tmp/gh-aw/github_rate_limits.jsonl + /tmp/gh-aw/base + /tmp/gh-aw/.github/agents + /tmp/gh-aw/.github/skills + if-no-files-found: ignore + retention-days: 1 + + agent: + needs: activation + if: needs.activation.outputs.daily_ai_credits_exceeded != 'true' + runs-on: ubuntu-latest + permissions: + contents: read + copilot-requests: write + pull-requests: read + env: + DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} + GH_AW_ASSETS_ALLOWED_EXTS: "" + GH_AW_ASSETS_BRANCH: "" + GH_AW_ASSETS_MAX_SIZE_KB: 0 + GH_AW_MCP_LOG_DIR: /tmp/gh-aw/mcp-logs/safeoutputs + GH_AW_RUNTIME_FEATURES: ${{ vars.GH_AW_RUNTIME_FEATURES }} + GH_AW_WORKFLOW_ID_SANITIZED: dockerfilereadiness + outputs: + agentic_engine_timeout: ${{ steps.detect-agent-errors.outputs.agentic_engine_timeout || 'false' }} + ai_credits_rate_limit_error: ${{ steps.parse-mcp-gateway.outputs.ai_credits_rate_limit_error || 'false' }} + aic: ${{ steps.parse-mcp-gateway.outputs.aic }} + ambient_context: ${{ steps.parse-mcp-gateway.outputs.ambient_context }} + checkout_pr_success: ${{ steps.checkout-pr.outputs.checkout_pr_success || 'true' }} + effective_tokens: ${{ steps.parse-mcp-gateway.outputs.effective_tokens }} + has_patch: ${{ steps.collect_output.outputs.has_patch }} + inference_access_error: ${{ steps.detect-agent-errors.outputs.inference_access_error || 'false' }} + mcp_policy_error: ${{ steps.detect-agent-errors.outputs.mcp_policy_error || 'false' }} + model: ${{ needs.activation.outputs.model }} + model_not_supported_error: ${{ steps.detect-agent-errors.outputs.model_not_supported_error || 'false' }} + output: ${{ steps.collect_output.outputs.output }} + output_types: ${{ steps.collect_output.outputs.output_types }} + setup-parent-span-id: ${{ steps.setup.outputs.parent-span-id || steps.setup.outputs.span-id }} + setup-span-id: ${{ steps.setup.outputs.span-id }} + setup-trace-id: ${{ steps.setup.outputs.trace-id }} + unknown_model_ai_credits: ${{ steps.parse-mcp-gateway.outputs.unknown_model_ai_credits || 'false' }} + steps: + - name: Setup Scripts + id: setup + uses: github/gh-aw-actions/setup@ba6380cc6e5be5d21677bebe04d52fb48e3abec7 # v0.81.6 + with: + destination: ${{ runner.temp }}/gh-aw/actions + job-name: ${{ github.job }} + trace-id: ${{ needs.activation.outputs.setup-trace-id }} + parent-span-id: ${{ needs.activation.outputs.setup-parent-span-id || needs.activation.outputs.setup-span-id }} + env: + GH_AW_SETUP_WORKFLOW_NAME: "Dockerfile Readiness Report" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/dockerfile-readiness.lock.yml@${{ github.ref }} + GH_AW_INFO_VERSION: "1.0.65" + GH_AW_INFO_AWF_VERSION: "v0.27.11" + GH_AW_INFO_ENGINE_ID: "copilot" + - name: Set runtime paths + id: set-runtime-paths + run: | + { + echo "GH_AW_SAFE_OUTPUTS=${RUNNER_TEMP}/gh-aw/safeoutputs/outputs.jsonl" + echo "GH_AW_SAFE_OUTPUTS_CONFIG_PATH=${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" + echo "GH_AW_SAFE_OUTPUTS_TOOLS_PATH=${RUNNER_TEMP}/gh-aw/safeoutputs/tools.json" + } >> "$GITHUB_OUTPUT" + - name: Checkout repository + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false + fetch-depth: 0 + - name: Create gh-aw temp directory + run: bash "${RUNNER_TEMP}/gh-aw/actions/create_gh_aw_tmp_dir.sh" + - name: Configure gh CLI for GitHub Enterprise + run: bash "${RUNNER_TEMP}/gh-aw/actions/configure_gh_for_ghe.sh" + env: + GH_TOKEN: ${{ github.token }} + - name: Set up Python + uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 + with: + python-version: 3.x + - name: Install dependencies + run: pip install -r requirements.txt + - name: Generate current manifest + run: python3 dockerhub_doc_config_update.py eclipse-temurin + - name: Fetch official upstream manifest + run: "curl -sSfL \\\n https://raw.githubusercontent.com/docker-library/official-images/master/library/eclipse-temurin \\\n -o official-eclipse-temurin\n" + + - name: Configure Git credentials + env: + GITHUB_REPOSITORY: ${{ github.repository }} + GITHUB_SERVER_URL: ${{ github.server_url }} + GITHUB_TOKEN: ${{ github.token }} + run: bash "${RUNNER_TEMP}/gh-aw/actions/configure_git_credentials.sh" + - name: Checkout PR branch + id: checkout-pr + if: | + github.event.pull_request || github.event.issue.pull_request || github.event_name == 'workflow_dispatch' && fromJSON(github.event.inputs.aw_context || '{}').item_type == 'pull_request' + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/checkout_pr_branch.cjs'); + await main(); + - name: Install GitHub Copilot CLI + run: bash "${RUNNER_TEMP}/gh-aw/actions/install_copilot_cli.sh" 1.0.65 + env: + GH_HOST: github.com + - name: Install AWF binary + run: bash "${RUNNER_TEMP}/gh-aw/actions/install_awf_binary.sh" v0.27.11 + - name: Determine automatic lockdown mode for GitHub MCP Server + id: determine-automatic-lockdown + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 (source v9) + env: + GH_AW_GITHUB_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN }} + GH_AW_GITHUB_MCP_SERVER_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN }} + with: + script: | + const determineAutomaticLockdown = require('${{ runner.temp }}/gh-aw/actions/determine_automatic_lockdown.cjs'); + await determineAutomaticLockdown(github, context, core); + - name: Download activation artifact + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: activation + path: /tmp/gh-aw + - name: Restore agent config folders from base branch + if: steps.checkout-pr.outcome == 'success' + env: + GH_AW_AGENT_FOLDERS: ".agents .antigravity .claude .codex .crush .gemini .github .opencode .pi" + GH_AW_AGENT_FILES: ".crush.json AGENTS.md ANTIGRAVITY.md CLAUDE.md GEMINI.md PI.md opencode.jsonc" + run: bash "${RUNNER_TEMP}/gh-aw/actions/restore_base_github_folders.sh" + - name: Restore inline sub-agents from activation artifact + env: + GH_AW_SUB_AGENT_DIR: ".github/agents" + GH_AW_SUB_AGENT_EXT: ".agent.md" + run: bash "${RUNNER_TEMP}/gh-aw/actions/restore_inline_sub_agents.sh" + - name: Restore inline skills from activation artifact + env: + GH_AW_SKILL_DIR: ".github/skills" + run: bash "${RUNNER_TEMP}/gh-aw/actions/restore_inline_skills.sh" + - name: Download container images + run: bash "${RUNNER_TEMP}/gh-aw/actions/download_docker_images.sh" ghcr.io/github/gh-aw-firewall/agent:0.27.11@sha256:979723c628182da7729333f2208bb249fd25ddee579645cf9a3892d681a929c7 ghcr.io/github/gh-aw-firewall/api-proxy:0.27.11@sha256:807e4831999b44513b0a66e5859d478dc4da7ae74ab1918cec967d513f95bf9d ghcr.io/github/gh-aw-firewall/squid:0.27.11@sha256:ff27ea0525ad953a6adee28a5fbe9d2e22be47dbec755c15767af4ea3f91df7d ghcr.io/github/gh-aw-mcpg:v0.3.30@sha256:35625d1a2269b1238606078c879f59a91cffc4ac33eb54bf39c6418822c1a8be ghcr.io/github/gh-aw-node@sha256:529d02eb970b1161aa25c593a9c3df57fdfad5a8add328cb3b6eccef66f3183b ghcr.io/github/github-mcp-server:v1.4.0@sha256:2afb26356481d1a350e14544a6e160f7f7ec1561a1ea309b823665abf0309036 + - name: Generate Safe Outputs Config + run: | + mkdir -p "${RUNNER_TEMP}/gh-aw/safeoutputs" + mkdir -p /tmp/gh-aw/safeoutputs + mkdir -p /tmp/gh-aw/mcp-logs/safeoutputs + cat > "${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" << 'GH_AW_SAFE_OUTPUTS_CONFIG_1ac138f5d8a92364_EOF' + {"add_comment":{"hide_older_comments":true,"max":1},"create_report_incomplete_issue":{},"missing_data":{},"missing_tool":{},"noop":{"max":1,"report-as-issue":"false"},"report_incomplete":{}} + GH_AW_SAFE_OUTPUTS_CONFIG_1ac138f5d8a92364_EOF + - name: Generate Safe Outputs Tools + env: + GH_AW_TOOLS_META_JSON: | + { + "description_suffixes": { + "add_comment": " CONSTRAINTS: Maximum 1 comment(s) can be added. Supports reply_to_id for discussion threading." + }, + "repo_params": {}, + "dynamic_tools": [] + } + GH_AW_VALIDATION_JSON: | + { + "add_comment": { + "defaultMax": 1, + "fields": { + "body": { + "required": true, + "type": "string", + "sanitize": true, + "maxLength": 65000 + }, + "item_number": { + "issueOrPRNumber": true + }, + "reply_to_id": { + "type": "string", + "maxLength": 256 + }, + "repo": { + "type": "string", + "maxLength": 256 + } + } + }, + "missing_data": { + "defaultMax": 20, + "fields": { + "alternatives": { + "type": "string", + "sanitize": true, + "maxLength": 256 + }, + "context": { + "type": "string", + "sanitize": true, + "maxLength": 256 + }, + "data_type": { + "type": "string", + "sanitize": true, + "maxLength": 128 + }, + "reason": { + "type": "string", + "sanitize": true, + "maxLength": 256 + } + } + }, + "missing_tool": { + "defaultMax": 20, + "fields": { + "alternatives": { + "type": "string", + "sanitize": true, + "maxLength": 512 + }, + "reason": { + "required": true, + "type": "string", + "sanitize": true, + "maxLength": 256 + }, + "tool": { + "type": "string", + "sanitize": true, + "maxLength": 128 + } + } + }, + "noop": { + "defaultMax": 1, + "fields": { + "message": { + "required": true, + "type": "string", + "sanitize": true, + "maxLength": 65000 + } + } + }, + "report_incomplete": { + "defaultMax": 5, + "fields": { + "details": { + "type": "string", + "sanitize": true, + "maxLength": 65000 + }, + "reason": { + "required": true, + "type": "string", + "sanitize": true, + "maxLength": 1024 + } + } + } + } + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/generate_safe_outputs_tools.cjs'); + await main(); + - name: Start MCP Gateway + id: start-mcp-gateway + env: + GH_AW_POLICY_ALLOW_CREATE_PULL_REQUEST: ${{ vars.GH_AW_POLICY_ALLOW_CREATE_PULL_REQUEST || 'true' }} + GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }} + GH_AW_SAFE_OUTPUTS_CONFIG_PATH: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS_CONFIG_PATH }} + GH_AW_SAFE_OUTPUTS_TOOLS_PATH: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS_TOOLS_PATH }} + GITHUB_MCP_GUARD_MIN_INTEGRITY: ${{ steps.determine-automatic-lockdown.outputs.min_integrity }} + GITHUB_MCP_GUARD_REPOS: ${{ steps.determine-automatic-lockdown.outputs.repos }} + GITHUB_MCP_SERVER_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -eo pipefail + mkdir -p "${RUNNER_TEMP}/gh-aw/mcp-config" + + # Export gateway environment variables for MCP config and gateway script + export MCP_GATEWAY_PORT="8080" + export MCP_GATEWAY_DOMAIN="host.docker.internal" + export MCP_GATEWAY_HOST_DOMAIN="localhost" + MCP_GATEWAY_API_KEY=$(openssl rand -base64 45 | tr -d '/+=') + echo "::add-mask::${MCP_GATEWAY_API_KEY}" + export MCP_GATEWAY_API_KEY + export MCP_GATEWAY_PAYLOAD_DIR="/tmp/gh-aw/mcp-payloads" + mkdir -p "${MCP_GATEWAY_PAYLOAD_DIR}" + export MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD="524288" + export DEBUG="*" + + export GH_AW_ENGINE="copilot" + MCP_GATEWAY_UID=$(id -u 2>/dev/null || echo '0') + MCP_GATEWAY_GID=$(id -g 2>/dev/null || echo '0') + case "${DOCKER_HOST:-}" in + unix://* ) DOCKER_SOCK_PATH="${DOCKER_HOST#unix://}" ;; + /* ) DOCKER_SOCK_PATH="$DOCKER_HOST" ;; + * ) DOCKER_SOCK_PATH=/var/run/docker.sock ;; + esac + DOCKER_SOCK_GID=$(stat -c '%g' "$DOCKER_SOCK_PATH" 2>/dev/null || echo '0') + export MCP_GATEWAY_DOCKER_COMMAND='docker run -i --rm --network host --name awmg-mcpg --add-host host.docker.internal:127.0.0.1 --user '"${MCP_GATEWAY_UID}"':'"${MCP_GATEWAY_GID}"' --group-add '"${DOCKER_SOCK_GID}"' -v '"${DOCKER_SOCK_PATH}"':/var/run/docker.sock -e MCP_GATEWAY_PORT -e MCP_GATEWAY_DOMAIN -e MCP_GATEWAY_API_KEY -e MCP_GATEWAY_PAYLOAD_DIR -e MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD -e DOCKER_HOST=unix:///var/run/docker.sock -e DEBUG -e MCP_GATEWAY_LOG_DIR -e GH_AW_MCP_LOG_DIR -e GH_AW_SAFE_OUTPUTS -e GH_AW_SAFE_OUTPUTS_CONFIG_PATH -e GH_AW_SAFE_OUTPUTS_TOOLS_PATH -e GH_AW_POLICY_ALLOW_CREATE_PULL_REQUEST -e GH_AW_ASSETS_BRANCH -e GH_AW_ASSETS_MAX_SIZE_KB -e GH_AW_ASSETS_ALLOWED_EXTS -e DEFAULT_BRANCH -e GITHUB_MCP_SERVER_TOKEN -e GITHUB_MCP_GUARD_MIN_INTEGRITY -e GITHUB_MCP_GUARD_REPOS -e GITHUB_REPOSITORY -e GITHUB_SERVER_URL -e GITHUB_SHA -e GITHUB_WORKSPACE -e GITHUB_TOKEN -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RUN_ATTEMPT -e GITHUB_JOB -e GITHUB_ACTION -e GITHUB_EVENT_NAME -e GITHUB_EVENT_PATH -e GITHUB_ACTOR -e GITHUB_ACTOR_ID -e GITHUB_TRIGGERING_ACTOR -e GITHUB_WORKFLOW -e GITHUB_WORKFLOW_REF -e GITHUB_WORKFLOW_SHA -e GITHUB_REF -e GITHUB_REF_NAME -e GITHUB_REF_TYPE -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e RUNNER_TEMP -v /tmp/gh-aw/mcp-payloads:/tmp/gh-aw/mcp-payloads:rw -v /opt:/opt:ro -v /tmp:/tmp:rw -v '"${GITHUB_WORKSPACE}"':'"${GITHUB_WORKSPACE}"':rw -v '"${RUNNER_TEMP}"'/gh-aw/safeoutputs:'"${RUNNER_TEMP}"'/gh-aw/safeoutputs:rw ghcr.io/github/gh-aw-mcpg:v0.3.30' + + mkdir -p "$HOME/.copilot" + GH_AW_NODE=$(which node 2>/dev/null || command -v node 2>/dev/null || echo node) + cat << GH_AW_MCP_CONFIG_f014db59cae17bc3_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs" + { + "mcpServers": { + "github": { + "type": "stdio", + "container": "ghcr.io/github/github-mcp-server:v1.4.0", + "env": { + "GITHUB_HOST": "${GITHUB_SERVER_URL}", + "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_MCP_SERVER_TOKEN}", + "GITHUB_READ_ONLY": "1", + "GITHUB_TOOLSETS": "context,repos,issues,pull_requests" + }, + "guard-policies": { + "allow-only": { + "min-integrity": "$GITHUB_MCP_GUARD_MIN_INTEGRITY", + "repos": "$GITHUB_MCP_GUARD_REPOS" + } + } + }, + "safeoutputs": { + "type": "stdio", + "container": "ghcr.io/github/gh-aw-node", + "mounts": ["\${GITHUB_WORKSPACE}:\${GITHUB_WORKSPACE}:rw", "${RUNNER_TEMP}/gh-aw/safeoutputs:${RUNNER_TEMP}/gh-aw/safeoutputs:rw", "/tmp/gh-aw:/tmp/gh-aw:rw"], + "args": ["-w", "\${GITHUB_WORKSPACE}"], + "entrypoint": "sh", + "entrypointArgs": ["-c", "sh ${RUNNER_TEMP}/gh-aw/safeoutputs/start_safe_outputs_mcp.sh"], + "env": { + "DEBUG": "*", + "DEFAULT_BRANCH": "\${DEFAULT_BRANCH}", + "GH_AW_ASSETS_ALLOWED_EXTS": "\${GH_AW_ASSETS_ALLOWED_EXTS}", + "GH_AW_ASSETS_BRANCH": "\${GH_AW_ASSETS_BRANCH}", + "GH_AW_ASSETS_MAX_SIZE_KB": "\${GH_AW_ASSETS_MAX_SIZE_KB}", + "GH_AW_MCP_LOG_DIR": "\${GH_AW_MCP_LOG_DIR}", + "GH_AW_SAFE_OUTPUTS": "\${GH_AW_SAFE_OUTPUTS}", + "GH_AW_SAFE_OUTPUTS_CONFIG_PATH": "\${GH_AW_SAFE_OUTPUTS_CONFIG_PATH}", + "GH_AW_SAFE_OUTPUTS_TOOLS_PATH": "\${GH_AW_SAFE_OUTPUTS_TOOLS_PATH}", + "GH_AW_POLICY_ALLOW_CREATE_PULL_REQUEST": "\${GH_AW_POLICY_ALLOW_CREATE_PULL_REQUEST}", + "GITHUB_REPOSITORY": "\${GITHUB_REPOSITORY}", + "GITHUB_TOKEN": "\${GITHUB_TOKEN}", + "GITHUB_WORKSPACE": "\${GITHUB_WORKSPACE}", + "RUNNER_TEMP": "\${RUNNER_TEMP}" + }, + "guard-policies": { + "write-sink": { + "accept": [ + "*" + ] + } + } + } + }, + "gateway": { + "port": $MCP_GATEWAY_PORT, + "domain": "${MCP_GATEWAY_DOMAIN}", + "apiKey": "${MCP_GATEWAY_API_KEY}", + "payloadDir": "${MCP_GATEWAY_PAYLOAD_DIR}" + } + } + GH_AW_MCP_CONFIG_f014db59cae17bc3_EOF + - name: Mount MCP servers as CLIs + id: mount-mcp-clis + continue-on-error: true + env: + MCP_GATEWAY_API_KEY: ${{ steps.start-mcp-gateway.outputs.gateway-api-key }} + MCP_GATEWAY_DOMAIN: ${{ steps.start-mcp-gateway.outputs.gateway-domain }} + MCP_GATEWAY_PORT: ${{ steps.start-mcp-gateway.outputs.gateway-port }} + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/mount_mcp_as_cli.cjs'); + await main(); + - name: Clean credentials + continue-on-error: true + run: bash "${RUNNER_TEMP}/gh-aw/actions/clean_git_credentials.sh" + - name: Audit pre-agent workspace + id: pre_agent_audit + continue-on-error: true + run: bash "${RUNNER_TEMP}/gh-aw/actions/audit_pre_agent_workspace.sh" + - name: Execute GitHub Copilot CLI + id: agentic_execution + # Copilot CLI tool arguments (sorted): + timeout-minutes: 60 + run: | + set -o pipefail + printf '%s' "$(date +%s%3N)" > /tmp/gh-aw/agent_cli_start_ms.txt + trap 'rm -f "$HOME/.copilot/settings.json"' EXIT + mkdir -p "$HOME/.copilot" + printf '%s' '{"builtInAgents":{"rubberDuck":false}}' > "$HOME/.copilot/settings.json" + export XDG_CONFIG_HOME="$HOME" + export GH_AW_MCP_CONFIG="$HOME/.copilot/mcp-config.json" + touch /tmp/gh-aw/agent-step-summary.md + GH_AW_NODE_BIN=$(command -v node 2>/dev/null || true) + export GH_AW_NODE_BIN + export COPILOT_API_KEY="$COPILOT_DUMMY_BYOK" + (umask 177 && touch /tmp/gh-aw/agent-stdio.log) + GH_AW_MAX_AI_CREDITS="${GH_AW_MAX_AI_CREDITS:-1000}" + printf '%s\n' "{\"\$schema\":\"https://github.com/github/gh-aw-firewall/releases/download/v0.27.11/awf-config.schema.json\",\"network\":{\"allowDomains\":[\"api.business.githubcopilot.com\",\"api.enterprise.githubcopilot.com\",\"api.github.com\",\"api.githubcopilot.com\",\"api.individual.githubcopilot.com\",\"api.snapcraft.io\",\"archive.ubuntu.com\",\"azure.archive.ubuntu.com\",\"crl.geotrust.com\",\"crl.globalsign.com\",\"crl.identrust.com\",\"crl.sectigo.com\",\"crl.thawte.com\",\"crl.usertrust.com\",\"crl.verisign.com\",\"crl3.digicert.com\",\"crl4.digicert.com\",\"crls.ssl.com\",\"github.com\",\"host.docker.internal\",\"json-schema.org\",\"json.schemastore.org\",\"keyserver.ubuntu.com\",\"ocsp.digicert.com\",\"ocsp.geotrust.com\",\"ocsp.globalsign.com\",\"ocsp.identrust.com\",\"ocsp.sectigo.com\",\"ocsp.ssl.com\",\"ocsp.thawte.com\",\"ocsp.usertrust.com\",\"ocsp.verisign.com\",\"packagecloud.io\",\"packages.cloud.google.com\",\"packages.microsoft.com\",\"ppa.launchpad.net\",\"raw.githubusercontent.com\",\"registry.npmjs.org\",\"s.symcb.com\",\"s.symcd.com\",\"security.ubuntu.com\",\"telemetry.enterprise.githubcopilot.com\",\"ts-crl.ws.symantec.com\",\"ts-ocsp.ws.symantec.com\",\"www.googleapis.com\"]},\"apiProxy\":{\"enabled\":true,\"enableTokenSteering\":true,\"maxRuns\":500,\"maxAiCredits\":${GH_AW_MAX_AI_CREDITS},\"maxCacheMisses\":5,\"models\":{\"agent\":[\"sonnet-6x\",\"gpt-5.5\",\"gpt-5.4\",\"gpt-5.3\",\"gemini-pro\",\"any\"],\"antigravity\":[\"copilot/antigravity*\",\"google/antigravity*\",\"gemini/antigravity*\"],\"any\":[\"copilot/*\",\"anthropic/*\",\"openai/*\",\"google/*\",\"gemini/*\"],\"claude\":[\"agent\"],\"codex\":[\"agent\"],\"coding\":[\"copilot/gpt-5*codex*\",\"openai/gpt-5*codex*\",\"gpt-5-codex\"],\"computer-use\":[\"copilot/*computer-use*\",\"google/*computer-use*\",\"gemini/*computer-use*\",\"openai/*computer-use*\"],\"copilot\":[\"agent\"],\"deep-research\":[\"copilot/deep-research*\",\"copilot/o3-deep-research*\",\"copilot/o4-mini-deep-research*\",\"google/deep-research*\",\"gemini/deep-research*\",\"openai/o3-deep-research*\",\"openai/o4-mini-deep-research*\"],\"gemini\":[\"agent\"],\"gemini-3-flash\":[\"copilot/gemini-3*flash*\",\"google/gemini-3*flash*\",\"gemini/gemini-3*flash*\"],\"gemini-3-pro\":[\"copilot/gemini-3*pro*\",\"google/gemini-3*pro*\",\"google/nano-banana*\",\"gemini/gemini-3*pro*\"],\"gemini-3.1-flash\":[\"copilot/gemini-3.1*flash*\",\"google/gemini-3.1*flash*\",\"gemini/gemini-3.1*flash*\"],\"gemini-3.1-pro\":[\"copilot/gemini-3.1*pro*\",\"google/gemini-3.1*pro*\",\"gemini/gemini-3.1*pro*\"],\"gemini-3.5-flash\":[\"copilot/gemini-3.5*flash*\",\"google/gemini-3.5*flash*\",\"gemini/gemini-3.5*flash*\"],\"gemini-flash\":[\"copilot/gemini-*flash*\",\"google/gemini-*flash*\",\"gemini/gemini-*flash*\"],\"gemini-flash-lite\":[\"copilot/gemini-*flash*lite*\",\"google/gemini-*flash*lite*\",\"gemini/gemini-*flash*lite*\"],\"gemini-pro\":[\"copilot/gemini-*pro*\",\"google/gemini-*pro*\",\"gemini/gemini-*pro*\"],\"gemma\":[\"copilot/gemma*\",\"google/gemma*\",\"gemini/gemma*\"],\"gpt-5\":[\"copilot/gpt-5*\",\"openai/gpt-5*\"],\"gpt-5-codex\":[\"copilot/gpt-5*codex*\",\"openai/gpt-5*codex*\"],\"gpt-5-mini\":[\"copilot/gpt-5*mini*\",\"openai/gpt-5*mini*\"],\"gpt-5-nano\":[\"copilot/gpt-5*nano*\",\"openai/gpt-5*nano*\"],\"gpt-5-pro\":[\"copilot/gpt-5*pro*\",\"openai/gpt-5*pro*\"],\"gpt-5.1\":[\"copilot/gpt-5.1*\",\"openai/gpt-5.1*\"],\"gpt-5.2\":[\"copilot/gpt-5.2*\",\"openai/gpt-5.2*\"],\"gpt-5.3\":[\"copilot/gpt-5.3*\",\"openai/gpt-5.3*\"],\"gpt-5.4\":[\"copilot/gpt-5.4*\",\"openai/gpt-5.4*\"],\"gpt-5.5\":[\"copilot/gpt-5.5*\",\"openai/gpt-5.5*\"],\"haiku\":[\"copilot/*haiku*\",\"anthropic/*haiku*\"],\"image-generation\":[\"copilot/gpt-image*\",\"openai/gpt-image*\",\"openai/chatgpt-image*\",\"copilot/gemini-*image*\",\"google/gemini-*image*\",\"gemini/gemini-*image*\",\"google/imagen*\"],\"large\":[\"sonnet\",\"gpt-5-pro\",\"gpt-5\",\"gemini-pro\"],\"mai-code\":[\"copilot/MAI-Code*\",\"copilot/mai-code*\",\"openai/MAI-Code*\"],\"mini\":[\"haiku\",\"gpt-5-mini\",\"gpt-5-nano\",\"gemini-flash-lite\"],\"nano-banana\":[\"copilot/nano-banana*\",\"google/nano-banana*\",\"gemini/nano-banana*\"],\"opus\":[\"copilot/*opus*\",\"anthropic/*opus*\"],\"opusplan\":[\"opus?effort=high\"],\"reasoning\":[\"copilot/o1*\",\"copilot/o3*\",\"copilot/o4*\",\"openai/o1*\",\"openai/o3*\",\"openai/o4*\"],\"robotics\":[\"copilot/*robotics*\",\"google/*robotics*\",\"gemini/*robotics*\"],\"small\":[\"mini\"],\"small-agent\":[\"haiku\",\"gpt-5-mini\",\"gemini-flash\"],\"sonnet\":[\"copilot/*sonnet*\",\"anthropic/*sonnet*\"],\"sonnet-6x\":[\"copilot/*sonnet-4.5*\",\"copilot/*sonnet-4.6*\",\"copilot/*sonnet-4-5-*\",\"anthropic/*sonnet-4-5-*\",\"copilot/*sonnet-4-6*\",\"anthropic/*sonnet-4-6*\"],\"summarization\":[\"haiku\",\"gpt-5-mini\",\"gemini-flash-lite\",\"mini\"],\"vision\":[\"copilot/gemini-*image*\",\"google/gemini-*image*\",\"gemini/gemini-*image*\",\"copilot/gemini-*flash*\",\"google/gemini-*flash*\",\"gemini/gemini-*flash*\"]}},\"container\":{\"imageTag\":\"0.27.11,squid=sha256:ff27ea0525ad953a6adee28a5fbe9d2e22be47dbec755c15767af4ea3f91df7d,agent=sha256:979723c628182da7729333f2208bb249fd25ddee579645cf9a3892d681a929c7,api-proxy=sha256:807e4831999b44513b0a66e5859d478dc4da7ae74ab1918cec967d513f95bf9d\"}}" > "${RUNNER_TEMP}/gh-aw/awf-config.json" + cp "${RUNNER_TEMP}/gh-aw/awf-config.json" /tmp/gh-aw/awf-config.json + export GH_AW_MODELS_JSON_PATH="/tmp/gh-aw/models.json" + GH_AW_DOCKER_HOST="" + if [[ "${DOCKER_HOST:-}" =~ ^tcp:// ]]; then + GH_AW_DOCKER_HOST="${DOCKER_HOST}" + fi + GH_AW_DOCKER_HOST_PATH_PREFIX_ARGS="" + if [[ "${DOCKER_HOST:-}" =~ ^tcp:// ]]; then + GH_AW_DOCKER_HOST_PATH_PREFIX_ARGS="--docker-host-path-prefix /tmp/gh-aw" + GH_AW_CHROOT_BINARIES_SOURCE_PATH=/tmp/gh-aw GH_AW_CHROOT_IDENTITY_HOME=/tmp/gh-aw/home node "${RUNNER_TEMP}/gh-aw/actions/patch_awf_chroot_config.cjs" + fi + GH_AW_TOOL_CACHE_MOUNT="" + GH_AW_TOOL_CACHE="${RUNNER_TOOL_CACHE:?RUNNER_TOOL_CACHE must be set}" + if [ -d "$GH_AW_TOOL_CACHE" ]; then + if [[ "$GH_AW_TOOL_CACHE" != /opt/* ]]; then + GH_AW_TOOL_CACHE_MOUNT="$GH_AW_TOOL_CACHE:$GH_AW_TOOL_CACHE:ro" + fi + fi + # shellcheck disable=SC1003,SC2086 + sudo -E awf --config "${RUNNER_TEMP}/gh-aw/awf-config.json" --container-workdir "${GITHUB_WORKSPACE}" --mount "${RUNNER_TEMP}/gh-aw:${RUNNER_TEMP}/gh-aw:ro" --mount "${RUNNER_TEMP}/gh-aw:/host${RUNNER_TEMP}/gh-aw:ro" ${GH_AW_TOOL_CACHE_MOUNT:+--mount "$GH_AW_TOOL_CACHE_MOUNT"} ${GH_AW_DOCKER_HOST:+--docker-host "$GH_AW_DOCKER_HOST"} ${GH_AW_DOCKER_HOST_PATH_PREFIX_ARGS} --env-all --exclude-env COPILOT_GITHUB_TOKEN --exclude-env GITHUB_MCP_SERVER_TOKEN --exclude-env MCP_GATEWAY_API_KEY --log-level info --proxy-logs-dir /tmp/gh-aw/sandbox/firewall/logs --audit-dir /tmp/gh-aw/sandbox/firewall/audit --enable-host-access --allow-host-ports 80,443,8080 --skip-pull \ + -- /bin/bash -c 'set +o histexpand; export PATH="${RUNNER_TEMP}/gh-aw/mcp-cli/bin:$PATH" && : "${RUNNER_TOOL_CACHE:?RUNNER_TOOL_CACHE must be set}"; GH_AW_TOOL_CACHE="$RUNNER_TOOL_CACHE"; export PATH="$(find "$GH_AW_TOOL_CACHE" -maxdepth 5 -type d -name bin 2>/dev/null | tr '\''\n'\'' '\'':'\'')$PATH"; [ -n "$GOROOT" ] && export PATH="$GOROOT/bin:$PATH" || true && GH_AW_NODE_EXEC="${GH_AW_NODE_BIN:-}"; if [ -z "$GH_AW_NODE_EXEC" ] || [ ! -x "$GH_AW_NODE_EXEC" ]; then GH_AW_NODE_EXEC="$(command -v node 2>/dev/null || true)"; fi; if [ -z "$GH_AW_NODE_EXEC" ]; then echo "node runtime missing on this runner — check runtimes.node in workflow YAML" >&2; exit 127; fi; GH_AW_NPM_GLOBAL_ROOT="$(npm root -g 2>/dev/null || true)"; if [ -n "$GH_AW_NPM_GLOBAL_ROOT" ]; then export NODE_PATH="${GH_AW_NPM_GLOBAL_ROOT}${NODE_PATH:+:${NODE_PATH}}"; fi; "$GH_AW_NODE_EXEC" ${RUNNER_TEMP}/gh-aw/actions/copilot_harness.cjs /usr/local/bin/copilot --add-dir /tmp/gh-aw/ --log-level all --log-dir /tmp/gh-aw/sandbox/agent/logs/ --disable-builtin-mcps --no-ask-user --allow-all-tools --allow-all-paths --add-dir "${GITHUB_WORKSPACE}" --prompt-file /tmp/gh-aw/aw-prompts/prompt.txt' 2>&1 | tee -a /tmp/gh-aw/agent-stdio.log + env: + AWF_REFLECT_ENABLED: 1 + COPILOT_AGENT_RUNNER_TYPE: STANDALONE + COPILOT_DUMMY_BYOK: dummy-byok-key-for-offline-mode + COPILOT_GITHUB_TOKEN: ${{ github.token }} + COPILOT_MODEL: ${{ vars.GH_AW_MODEL_AGENT_COPILOT || vars.GH_AW_DEFAULT_MODEL_COPILOT || 'claude-sonnet-4.6' }} + GH_AW_LLM_PROVIDER: github + GH_AW_MAX_AI_CREDITS: ${{ vars.GH_AW_DEFAULT_MAX_AI_CREDITS || '1000' }} + GH_AW_MAX_TURNS: ${{ vars.GH_AW_DEFAULT_MAX_TURNS || '' }} + GH_AW_PHASE: agent + GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt + GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }} + GH_AW_TIMEOUT_MINUTES: 60 + GH_AW_VERSION: v0.81.6 + GITHUB_API_URL: ${{ github.api_url }} + GITHUB_AW: true + GITHUB_COPILOT_INTEGRATION_ID: agentic-workflows + GITHUB_HEAD_REF: ${{ github.head_ref }} + GITHUB_MCP_SERVER_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + GITHUB_REF_NAME: ${{ github.ref_name }} + GITHUB_SERVER_URL: ${{ github.server_url }} + GITHUB_STEP_SUMMARY: /tmp/gh-aw/agent-step-summary.md + GITHUB_WORKSPACE: ${{ github.workspace }} + GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com + GIT_AUTHOR_NAME: github-actions[bot] + GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com + GIT_COMMITTER_NAME: github-actions[bot] + RUNNER_TEMP: ${{ runner.temp }} + S2STOKENS: true + TRACEPARENT: ${{ env.GITHUB_AW_OTEL_TRACE_ID != '' && env.GITHUB_AW_OTEL_PARENT_SPAN_ID != '' && format('00-{0}-{1}-01', env.GITHUB_AW_OTEL_TRACE_ID, env.GITHUB_AW_OTEL_PARENT_SPAN_ID) || '' }} + - name: Detect agent errors + if: always() + id: detect-agent-errors + continue-on-error: true + run: node "${RUNNER_TEMP}/gh-aw/actions/detect_agent_errors.cjs" + - name: Configure Git credentials + env: + GITHUB_REPOSITORY: ${{ github.repository }} + GITHUB_SERVER_URL: ${{ github.server_url }} + GITHUB_TOKEN: ${{ github.token }} + run: bash "${RUNNER_TEMP}/gh-aw/actions/configure_git_credentials.sh" + - name: Copy Copilot session state files to logs + if: always() + continue-on-error: true + run: bash "${RUNNER_TEMP}/gh-aw/actions/copy_copilot_session_state.sh" + - name: Stop MCP Gateway + if: always() + continue-on-error: true + env: + MCP_GATEWAY_PORT: ${{ steps.start-mcp-gateway.outputs.gateway-port }} + MCP_GATEWAY_API_KEY: ${{ steps.start-mcp-gateway.outputs.gateway-api-key }} + GATEWAY_PID: ${{ steps.start-mcp-gateway.outputs.gateway-pid }} + run: | + bash "${RUNNER_TEMP}/gh-aw/actions/stop_mcp_gateway.sh" "$GATEWAY_PID" + - name: Redact secrets in logs + if: always() + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/redact_secrets.cjs'); + await main(); + env: + GH_AW_SECRET_NAMES: 'GH_AW_GITHUB_MCP_SERVER_TOKEN,GH_AW_GITHUB_TOKEN,GITHUB_TOKEN' + SECRET_GH_AW_GITHUB_MCP_SERVER_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN }} + SECRET_GH_AW_GITHUB_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN }} + SECRET_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Append agent step summary + if: always() + run: bash "${RUNNER_TEMP}/gh-aw/actions/append_agent_step_summary.sh" + - name: Copy Safe Outputs + if: always() + env: + GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }} + run: | + mkdir -p /tmp/gh-aw + cp "$GH_AW_SAFE_OUTPUTS" /tmp/gh-aw/safeoutputs.jsonl 2>/dev/null || true + - name: Ingest agent output + id: collect_output + if: always() + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }} + GH_AW_ALLOWED_DOMAINS: "api.business.githubcopilot.com,api.enterprise.githubcopilot.com,api.github.com,api.githubcopilot.com,api.individual.githubcopilot.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,github.com,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,ppa.launchpad.net,raw.githubusercontent.com,registry.npmjs.org,s.symcb.com,s.symcd.com,security.ubuntu.com,telemetry.enterprise.githubcopilot.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com" + GITHUB_SERVER_URL: ${{ github.server_url }} + GITHUB_API_URL: ${{ github.api_url }} + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/collect_ndjson_output.cjs'); + await main(); + - name: Parse agent logs for step summary + if: always() + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_AW_AGENT_OUTPUT: /tmp/gh-aw/sandbox/agent/logs/ + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_copilot_log.cjs'); + await main(); + - name: Parse MCP Gateway logs for step summary + if: always() + id: parse-mcp-gateway + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_mcp_gateway_log.cjs'); + await main(); + - name: Print firewall logs + if: always() + continue-on-error: true + env: + AWF_LOGS_DIR: /tmp/gh-aw/sandbox/firewall/logs + run: | + # Fix permissions on firewall logs/audit dirs so they can be uploaded as artifacts + # AWF runs with sudo, creating files owned by root + sudo chmod -R a+rX /tmp/gh-aw/sandbox/firewall 2>/dev/null || true + # Only run awf logs summary if awf command exists (it may not be installed if workflow failed before install step) + if command -v awf &> /dev/null; then + awf logs summary | tee -a "$GITHUB_STEP_SUMMARY" + else + echo 'AWF binary not installed, skipping firewall log summary' + fi + - name: Parse token usage for step summary + if: always() + continue-on-error: true + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_token_usage.cjs'); + await main(); + - name: Print AWF reflect summary + if: always() + continue-on-error: true + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/awf_reflect_summary.cjs'); + await main(); + - name: Write agent output placeholder if missing + if: always() + run: | + if [ ! -f /tmp/gh-aw/agent_output.json ]; then + echo '{"items":[]}' > /tmp/gh-aw/agent_output.json + fi + - name: Upload agent artifacts + if: always() + continue-on-error: true + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: agent + path: | + /tmp/gh-aw/aw-prompts/prompt.txt + /tmp/gh-aw/sandbox/agent/logs/ + /tmp/gh-aw/redacted-urls.log + /tmp/gh-aw/mcp-logs/ + /tmp/gh-aw/agent_usage.json + /tmp/gh-aw/agent-stdio.log + /tmp/gh-aw/pre-agent-audit.txt + /tmp/gh-aw/agent/ + /tmp/gh-aw/github_rate_limits.jsonl + /tmp/gh-aw/safeoutputs.jsonl + /tmp/gh-aw/agent_output.json + /tmp/gh-aw/aw-*.patch + /tmp/gh-aw/aw-*.bundle + /tmp/gh-aw/awf-config.json + /tmp/gh-aw/sandbox/firewall/logs/ + /tmp/gh-aw/sandbox/firewall/audit/ + /tmp/gh-aw/sandbox/firewall/awf-reflect.json + if-no-files-found: ignore + + conclusion: + needs: + - activation + - agent + - detection + - safe_outputs + if: > + always() && (needs.agent.result != 'skipped' || needs.activation.outputs.lockdown_check_failed == 'true' || + needs.activation.outputs.stale_lock_file_failed == 'true' || needs.activation.outputs.daily_ai_credits_exceeded == 'true') + runs-on: ubuntu-slim + permissions: + contents: read + issues: write + pull-requests: write + concurrency: + group: "gh-aw-conclusion-dockerfile-readiness" + cancel-in-progress: false + queue: max + env: + GH_AW_RUNTIME_FEATURES: ${{ vars.GH_AW_RUNTIME_FEATURES }} + outputs: + incomplete_count: ${{ steps.report_incomplete.outputs.incomplete_count }} + noop_message: ${{ steps.noop.outputs.noop_message }} + tools_reported: ${{ steps.missing_tool.outputs.tools_reported }} + total_count: ${{ steps.missing_tool.outputs.total_count }} + steps: + - name: Setup Scripts + id: setup + uses: github/gh-aw-actions/setup@ba6380cc6e5be5d21677bebe04d52fb48e3abec7 # v0.81.6 + with: + destination: ${{ runner.temp }}/gh-aw/actions + job-name: ${{ github.job }} + trace-id: ${{ needs.activation.outputs.setup-trace-id }} + parent-span-id: ${{ needs.activation.outputs.setup-parent-span-id || needs.activation.outputs.setup-span-id }} + env: + GH_AW_SETUP_WORKFLOW_NAME: "Dockerfile Readiness Report" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/dockerfile-readiness.lock.yml@${{ github.ref }} + GH_AW_INFO_VERSION: "1.0.65" + GH_AW_INFO_AWF_VERSION: "v0.27.11" + GH_AW_INFO_ENGINE_ID: "copilot" + - name: Download agent output artifact + id: download-agent-output + continue-on-error: true + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: agent + path: /tmp/gh-aw/ + - name: Setup agent output environment variable + id: setup-agent-output-env + if: steps.download-agent-output.outcome == 'success' + run: | + mkdir -p /tmp/gh-aw/ + find "/tmp/gh-aw/" -type f -print + echo "GH_AW_AGENT_OUTPUT=/tmp/gh-aw/agent_output.json" >> "$GITHUB_OUTPUT" + - name: Collect usage artifact files + if: always() + continue-on-error: true + run: | + mkdir -p /tmp/gh-aw/usage/agent /tmp/gh-aw/usage/detection + echo "Usage artifact source file status:" + for file in /tmp/gh-aw/aw_info.json /tmp/gh-aw/aw-info.jsonl /tmp/gh-aw/agent_usage.json /tmp/gh-aw/agent_usage.jsonl /tmp/gh-aw/detection_usage.jsonl /tmp/gh-aw/github_rate_limits.jsonl /tmp/gh-aw/sandbox/firewall-audit-logs/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/sandbox/firewall/logs/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/sandbox/firewall/audit/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/threat-detection/sandbox/firewall-audit-logs/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/threat-detection/sandbox/firewall/logs/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/threat-detection/sandbox/firewall/audit/api-proxy-logs/token-usage.jsonl; do + [ -f "$file" ] && echo "FOUND: $file" || echo "MISSING: $file" + done + [ -f /tmp/gh-aw/aw_info.json ] && cp /tmp/gh-aw/aw_info.json /tmp/gh-aw/usage/aw_info.json || true + [ -f /tmp/gh-aw/aw-info.jsonl ] && cp /tmp/gh-aw/aw-info.jsonl /tmp/gh-aw/usage/aw-info.jsonl || true + [ -f /tmp/gh-aw/agent_usage.json ] && cp /tmp/gh-aw/agent_usage.json /tmp/gh-aw/usage/agent_usage.json || true + [ -f /tmp/gh-aw/agent_usage.jsonl ] && cp /tmp/gh-aw/agent_usage.jsonl /tmp/gh-aw/usage/agent_usage.jsonl || true + [ -f /tmp/gh-aw/detection_usage.jsonl ] && cp /tmp/gh-aw/detection_usage.jsonl /tmp/gh-aw/usage/detection_usage.jsonl || true + [ -f /tmp/gh-aw/github_rate_limits.jsonl ] && cp /tmp/gh-aw/github_rate_limits.jsonl /tmp/gh-aw/usage/github_rate_limits.jsonl || true + [ -s /tmp/gh-aw/sandbox/firewall-audit-logs/api-proxy-logs/token-usage.jsonl ] && cp /tmp/gh-aw/sandbox/firewall-audit-logs/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/usage/agent/token_usage.jsonl || true + [ -s /tmp/gh-aw/sandbox/firewall/audit/api-proxy-logs/token-usage.jsonl ] && cp /tmp/gh-aw/sandbox/firewall/audit/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/usage/agent/token_usage.jsonl || true + [ -s /tmp/gh-aw/sandbox/firewall/logs/api-proxy-logs/token-usage.jsonl ] && cp /tmp/gh-aw/sandbox/firewall/logs/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/usage/agent/token_usage.jsonl || true + [ -s /tmp/gh-aw/threat-detection/sandbox/firewall-audit-logs/api-proxy-logs/token-usage.jsonl ] && cp /tmp/gh-aw/threat-detection/sandbox/firewall-audit-logs/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/usage/detection/token_usage.jsonl || true + [ -s /tmp/gh-aw/threat-detection/sandbox/firewall/audit/api-proxy-logs/token-usage.jsonl ] && cp /tmp/gh-aw/threat-detection/sandbox/firewall/audit/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/usage/detection/token_usage.jsonl || true + [ -s /tmp/gh-aw/threat-detection/sandbox/firewall/logs/api-proxy-logs/token-usage.jsonl ] && cp /tmp/gh-aw/threat-detection/sandbox/firewall/logs/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/usage/detection/token_usage.jsonl || true + [ -f /tmp/gh-aw/usage/agent/token_usage.jsonl ] || : > /tmp/gh-aw/usage/agent/token_usage.jsonl + [ -f /tmp/gh-aw/usage/detection/token_usage.jsonl ] || : > /tmp/gh-aw/usage/detection/token_usage.jsonl + mkdir -p /tmp/gh-aw/usage/activity + node ${{ runner.temp }}/gh-aw/actions/generate_usage_activity_summary.cjs + find /tmp/gh-aw/usage -type f -print | sort + - name: Upload usage artifact + if: always() + continue-on-error: true + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: usage + path: | + /tmp/gh-aw/usage/aw_info.json + /tmp/gh-aw/usage/aw-info.jsonl + /tmp/gh-aw/usage/agent_usage.json + /tmp/gh-aw/usage/agent_usage.jsonl + /tmp/gh-aw/usage/detection_usage.jsonl + /tmp/gh-aw/usage/github_rate_limits.jsonl + /tmp/gh-aw/usage/agent/token_usage.jsonl + /tmp/gh-aw/usage/detection/token_usage.jsonl + /tmp/gh-aw/usage/activity/summary.json + if-no-files-found: ignore + - name: Restore daily AIC usage cache + id: restore-daily-aic-cache-conclusion + if: always() + continue-on-error: true + uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + key: agentic-workflow-usage-dockerfilereadiness-${{ github.run_id }} + restore-keys: agentic-workflow-usage-dockerfilereadiness- + path: /tmp/gh-aw/agentic-workflow-usage-cache.jsonl + - name: Write daily AIC usage cache entry + id: write-daily-aic-cache + if: always() + continue-on-error: true + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + github-token: ${{ github.token }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context); + const { main } = require('${{ runner.temp }}/gh-aw/actions/write_daily_aic_usage_cache.cjs'); + await main(); + - name: Save daily AIC usage cache + id: save-daily-aic-cache + if: always() + continue-on-error: true + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + key: agentic-workflow-usage-dockerfilereadiness-${{ github.run_id }} + path: /tmp/gh-aw/agentic-workflow-usage-cache.jsonl + - name: Upload daily AIC usage cache artifact + id: upload-daily-aic-cache + if: always() + continue-on-error: true + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: aic-usage-cache + path: /tmp/gh-aw/agentic-workflow-usage-cache.jsonl + if-no-files-found: ignore + retention-days: 7 + - name: Process no-op messages + id: noop + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} + GH_AW_NOOP_MAX: "1" + GH_AW_WORKFLOW_NAME: "Dockerfile Readiness Report" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/${{ github.repository }}/blob/${{ github.ref_name }}/.github/workflows/dockerfile-readiness.md" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} + GH_AW_NOOP_REPORT_AS_ISSUE: "false" + GH_AW_AIC: ${{ needs.agent.outputs.aic }} + GH_AW_THREAT_DETECTION_AIC: ${{ needs.detection.outputs.aic }} + GH_AW_AMBIENT_CONTEXT: ${{ needs.agent.outputs.ambient_context }} + GH_AW_WORKFLOW_ID: "dockerfile-readiness" + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/handle_noop_message.cjs'); + await main(); + - name: Log detection run + id: detection_runs + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} + GH_AW_WORKFLOW_NAME: "Dockerfile Readiness Report" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/${{ github.repository }}/blob/${{ github.ref_name }}/.github/workflows/dockerfile-readiness.md" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + GH_AW_DETECTION_CONCLUSION: ${{ needs.detection.outputs.detection_conclusion }} + GH_AW_DETECTION_REASON: ${{ needs.detection.outputs.detection_reason }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/handle_detection_runs.cjs'); + await main(); + - name: Record missing tool + id: missing_tool + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} + GH_AW_MISSING_TOOL_CREATE_ISSUE: "true" + GH_AW_WORKFLOW_NAME: "Dockerfile Readiness Report" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/${{ github.repository }}/blob/${{ github.ref_name }}/.github/workflows/dockerfile-readiness.md" + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/missing_tool.cjs'); + await main(); + - name: Record incomplete + id: report_incomplete + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} + GH_AW_REPORT_INCOMPLETE_CREATE_ISSUE: "true" + GH_AW_WORKFLOW_NAME: "Dockerfile Readiness Report" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/${{ github.repository }}/blob/${{ github.ref_name }}/.github/workflows/dockerfile-readiness.md" + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/report_incomplete_handler.cjs'); + await main(); + - name: Handle agent failure + id: handle_agent_failure + if: always() + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} + GH_AW_WORKFLOW_NAME: "Dockerfile Readiness Report" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/${{ github.repository }}/blob/${{ github.ref_name }}/.github/workflows/dockerfile-readiness.md" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} + GH_AW_WORKFLOW_ID: "dockerfile-readiness" + GH_AW_ACTION_FAILURE_ISSUE_EXPIRES_HOURS: "168" + GH_AW_ENGINE_ID: "copilot" + GH_AW_CHECKOUT_PR_SUCCESS: ${{ needs.agent.outputs.checkout_pr_success }} + GH_AW_EFFECTIVE_TOKENS: ${{ needs.agent.outputs.effective_tokens || '' }} + GH_AW_AI_CREDITS_RATE_LIMIT_ERROR: ${{ needs.agent.outputs.ai_credits_rate_limit_error || 'false' }} + GH_AW_UNKNOWN_MODEL_AI_CREDITS: ${{ needs.agent.outputs.unknown_model_ai_credits || 'false' }} + GH_AW_AIC: ${{ needs.agent.outputs.aic }} + GH_AW_THREAT_DETECTION_AIC: ${{ needs.detection.outputs.aic }} + GH_AW_MAX_AI_CREDITS: ${{ vars.GH_AW_DEFAULT_MAX_AI_CREDITS || '1000' }} + GH_AW_INFERENCE_ACCESS_ERROR: ${{ needs.agent.outputs.inference_access_error }} + GH_AW_MCP_POLICY_ERROR: ${{ needs.agent.outputs.mcp_policy_error }} + GH_AW_AGENTIC_ENGINE_TIMEOUT: ${{ needs.agent.outputs.agentic_engine_timeout }} + GH_AW_MODEL_NOT_SUPPORTED_ERROR: ${{ needs.agent.outputs.model_not_supported_error }} + GH_AW_ENGINE_API_HOSTS: "api.enterprise.githubcopilot.com,api.githubcopilot.com,api.business.githubcopilot.com,api.individual.githubcopilot.com" + GH_AW_LOCKDOWN_CHECK_FAILED: ${{ needs.activation.outputs.lockdown_check_failed }} + GH_AW_STALE_LOCK_FILE_FAILED: ${{ needs.activation.outputs.stale_lock_file_failed }} + GH_AW_DAILY_AI_CREDITS_EXCEEDED: ${{ needs.activation.outputs.daily_ai_credits_exceeded }} + GH_AW_DAILY_AI_CREDITS_TOTAL_EFFECTIVE_TOKENS: ${{ needs.activation.outputs.daily_ai_credits_total_effective_tokens }} + GH_AW_DAILY_AI_CREDITS_THRESHOLD: ${{ needs.activation.outputs.daily_ai_credits_threshold }} + GH_AW_GROUP_REPORTS: "false" + GH_AW_FAILURE_REPORT_AS_ISSUE: "true" + GH_AW_MISSING_TOOL_REPORT_AS_FAILURE: "true" + GH_AW_MISSING_DATA_REPORT_AS_FAILURE: "true" + GH_AW_TIMEOUT_MINUTES: "60" + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/handle_agent_failure.cjs'); + await main(); + + detection: + needs: + - activation + - agent + if: always() && needs.agent.result != 'skipped' + runs-on: ubuntu-latest + permissions: + contents: read + copilot-requests: write + env: + GH_AW_RUNTIME_FEATURES: ${{ vars.GH_AW_RUNTIME_FEATURES }} + outputs: + aic: ${{ steps.parse_detection_token_usage.outputs.aic }} + detection_conclusion: ${{ steps.detection_conclusion.outputs.conclusion }} + detection_reason: ${{ steps.detection_conclusion.outputs.reason }} + detection_success: ${{ steps.detection_conclusion.outputs.success }} + steps: + - name: Setup Scripts + id: setup + uses: github/gh-aw-actions/setup@ba6380cc6e5be5d21677bebe04d52fb48e3abec7 # v0.81.6 + with: + destination: ${{ runner.temp }}/gh-aw/actions + job-name: ${{ github.job }} + trace-id: ${{ needs.activation.outputs.setup-trace-id }} + parent-span-id: ${{ needs.activation.outputs.setup-parent-span-id || needs.activation.outputs.setup-span-id }} + env: + GH_AW_SETUP_WORKFLOW_NAME: "Dockerfile Readiness Report" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/dockerfile-readiness.lock.yml@${{ github.ref }} + GH_AW_INFO_VERSION: "1.0.65" + GH_AW_INFO_AWF_VERSION: "v0.27.11" + GH_AW_INFO_ENGINE_ID: "copilot" + - name: Download agent output artifact + id: download-agent-output + continue-on-error: true + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: agent + path: /tmp/gh-aw/ + - name: Setup agent output environment variable + id: setup-agent-output-env + if: steps.download-agent-output.outcome == 'success' + run: | + mkdir -p /tmp/gh-aw/ + find "/tmp/gh-aw/" -type f -print + echo "GH_AW_AGENT_OUTPUT=/tmp/gh-aw/agent_output.json" >> "$GITHUB_OUTPUT" + - name: Checkout repository for patch context + if: needs.agent.outputs.has_patch == 'true' + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false + # --- Threat Detection --- + - name: Clean stale firewall files from agent artifact + run: | + rm -rf /tmp/gh-aw/sandbox/firewall/logs + rm -rf /tmp/gh-aw/sandbox/firewall/audit + - name: Download container images + run: bash "${RUNNER_TEMP}/gh-aw/actions/download_docker_images.sh" ghcr.io/github/gh-aw-firewall/agent:0.27.11@sha256:979723c628182da7729333f2208bb249fd25ddee579645cf9a3892d681a929c7 ghcr.io/github/gh-aw-firewall/api-proxy:0.27.11@sha256:807e4831999b44513b0a66e5859d478dc4da7ae74ab1918cec967d513f95bf9d ghcr.io/github/gh-aw-firewall/squid:0.27.11@sha256:ff27ea0525ad953a6adee28a5fbe9d2e22be47dbec755c15767af4ea3f91df7d + - name: Check if detection needed + id: detection_guard + if: always() + env: + OUTPUT_TYPES: ${{ needs.agent.outputs.output_types }} + HAS_PATCH: ${{ needs.agent.outputs.has_patch }} + run: | + if [[ -n "$OUTPUT_TYPES" || "$HAS_PATCH" == "true" ]]; then + echo "run_detection=true" >> "$GITHUB_OUTPUT" + echo "Detection will run: output_types=$OUTPUT_TYPES, has_patch=$HAS_PATCH" + else + echo "run_detection=false" >> "$GITHUB_OUTPUT" + echo "Detection skipped: no agent outputs or patches to analyze" + fi + - name: Clear MCP Config for detection + if: always() && steps.detection_guard.outputs.run_detection == 'true' + run: | + rm -f "${RUNNER_TEMP}/gh-aw/mcp-config/mcp-servers.json" + rm -f "$HOME/.copilot/mcp-config.json" + rm -f "$GITHUB_WORKSPACE/.gemini/settings.json" + - name: Prepare threat detection files + if: always() && steps.detection_guard.outputs.run_detection == 'true' + run: | + mkdir -p /tmp/gh-aw/threat-detection/aw-prompts + rm -f /tmp/gh-aw/agent_usage.json + cp /tmp/gh-aw/aw-prompts/prompt.txt /tmp/gh-aw/threat-detection/aw-prompts/prompt.txt 2>/dev/null || true + if [ ! -s /tmp/gh-aw/threat-detection/aw-prompts/prompt.txt ]; then + echo "::warning::ERR_VALIDATION: Missing or empty detection context prompt at /tmp/gh-aw/threat-detection/aw-prompts/prompt.txt. Ensure the agent artifact includes /tmp/gh-aw/aw-prompts/prompt.txt. Detection will continue with fallback workflow context." + fi + cp /tmp/gh-aw/agent_output.json /tmp/gh-aw/threat-detection/agent_output.json 2>/dev/null || true + for f in /tmp/gh-aw/aw-*.patch; do + [ -f "$f" ] && cp "$f" /tmp/gh-aw/threat-detection/ 2>/dev/null || true + done + for f in /tmp/gh-aw/aw-*.bundle; do + [ -f "$f" ] && cp "$f" /tmp/gh-aw/threat-detection/ 2>/dev/null || true + done + echo "Prepared threat detection files:" + ls -la /tmp/gh-aw/threat-detection/ 2>/dev/null || true + - name: Setup threat detection + if: always() && steps.detection_guard.outputs.run_detection == 'true' + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + WORKFLOW_NAME: "Dockerfile Readiness Report" + WORKFLOW_DESCRIPTION: "No description provided" + HAS_PATCH: ${{ needs.agent.outputs.has_patch }} + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/setup_threat_detection.cjs'); + await main(); + - name: Ensure threat-detection directory and log + if: always() && steps.detection_guard.outputs.run_detection == 'true' + run: | + mkdir -p /tmp/gh-aw/threat-detection + touch /tmp/gh-aw/threat-detection/detection.log + - name: Setup Node.js + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 + with: + node-version: '24' + package-manager-cache: false + - name: Install GitHub Copilot CLI + run: bash "${RUNNER_TEMP}/gh-aw/actions/install_copilot_cli.sh" 1.0.65 + env: + GH_HOST: github.com + - name: Install AWF binary + run: bash "${RUNNER_TEMP}/gh-aw/actions/install_awf_binary.sh" v0.27.11 + - name: Execute GitHub Copilot CLI + if: always() && steps.detection_guard.outputs.run_detection == 'true' + continue-on-error: true + id: detection_agentic_execution + # Copilot CLI tool arguments (sorted): + timeout-minutes: 20 + run: | + set -o pipefail + printf '%s' "$(date +%s%3N)" > /tmp/gh-aw/agent_cli_start_ms.txt + trap 'rm -f "$HOME/.copilot/settings.json"' EXIT + mkdir -p "$HOME/.copilot" + printf '%s' '{"builtInAgents":{"rubberDuck":false}}' > "$HOME/.copilot/settings.json" + export XDG_CONFIG_HOME="$HOME" + touch /tmp/gh-aw/agent-step-summary.md + GH_AW_NODE_BIN=$(command -v node 2>/dev/null || true) + export GH_AW_NODE_BIN + export COPILOT_API_KEY="$COPILOT_DUMMY_BYOK" + (umask 177 && touch /tmp/gh-aw/threat-detection/detection.log) + GH_AW_MAX_AI_CREDITS="${GH_AW_MAX_AI_CREDITS:-400}" + printf '%s\n' "{\"\$schema\":\"https://github.com/github/gh-aw-firewall/releases/download/v0.27.11/awf-config.schema.json\",\"network\":{\"allowDomains\":[\"api.business.githubcopilot.com\",\"api.enterprise.githubcopilot.com\",\"api.github.com\",\"api.githubcopilot.com\",\"api.individual.githubcopilot.com\",\"github.com\",\"host.docker.internal\",\"registry.npmjs.org\",\"telemetry.enterprise.githubcopilot.com\"]},\"apiProxy\":{\"enabled\":true,\"enableTokenSteering\":true,\"maxRuns\":500,\"maxAiCredits\":${GH_AW_MAX_AI_CREDITS},\"maxCacheMisses\":5},\"container\":{\"imageTag\":\"0.27.11,squid=sha256:ff27ea0525ad953a6adee28a5fbe9d2e22be47dbec755c15767af4ea3f91df7d,agent=sha256:979723c628182da7729333f2208bb249fd25ddee579645cf9a3892d681a929c7,api-proxy=sha256:807e4831999b44513b0a66e5859d478dc4da7ae74ab1918cec967d513f95bf9d\"}}" > "${RUNNER_TEMP}/gh-aw/awf-config.json" + cp "${RUNNER_TEMP}/gh-aw/awf-config.json" /tmp/gh-aw/awf-config.json + export GH_AW_MODELS_JSON_PATH="/tmp/gh-aw/models.json" + GH_AW_DOCKER_HOST="" + if [[ "${DOCKER_HOST:-}" =~ ^tcp:// ]]; then + GH_AW_DOCKER_HOST="${DOCKER_HOST}" + fi + GH_AW_DOCKER_HOST_PATH_PREFIX_ARGS="" + if [[ "${DOCKER_HOST:-}" =~ ^tcp:// ]]; then + GH_AW_DOCKER_HOST_PATH_PREFIX_ARGS="--docker-host-path-prefix /tmp/gh-aw" + _GH_AW_CHROOT_JSON=$(jq -c --arg src /tmp/gh-aw --arg user "$(id -un)" --argjson uid "$(id -u)" --argjson gid "$(id -g)" --arg home /tmp/gh-aw/home '.chroot={"binariesSourcePath":$src,"identity":{"user":$user,"uid":$uid,"gid":$gid,"home":$home}}' "${RUNNER_TEMP}/gh-aw/awf-config.json") || { echo "chroot config patch failed" >&2; exit 1; } + printf '%s\n' "$_GH_AW_CHROOT_JSON" > "${RUNNER_TEMP}/gh-aw/awf-config.json" + printf '%s\n' "$_GH_AW_CHROOT_JSON" > "/tmp/gh-aw/awf-config.json" + fi + GH_AW_TOOL_CACHE_MOUNT="" + GH_AW_TOOL_CACHE="${RUNNER_TOOL_CACHE:?RUNNER_TOOL_CACHE must be set}" + if [ -d "$GH_AW_TOOL_CACHE" ]; then + if [[ "$GH_AW_TOOL_CACHE" != /opt/* ]]; then + GH_AW_TOOL_CACHE_MOUNT="$GH_AW_TOOL_CACHE:$GH_AW_TOOL_CACHE:ro" + fi + fi + # shellcheck disable=SC1003,SC2086 + sudo -E awf --config "${RUNNER_TEMP}/gh-aw/awf-config.json" --container-workdir "${GITHUB_WORKSPACE}" --mount "${RUNNER_TEMP}/gh-aw:${RUNNER_TEMP}/gh-aw:ro" --mount "${RUNNER_TEMP}/gh-aw:/host${RUNNER_TEMP}/gh-aw:ro" ${GH_AW_TOOL_CACHE_MOUNT:+--mount "$GH_AW_TOOL_CACHE_MOUNT"} ${GH_AW_DOCKER_HOST:+--docker-host "$GH_AW_DOCKER_HOST"} ${GH_AW_DOCKER_HOST_PATH_PREFIX_ARGS} --env-all --exclude-env COPILOT_GITHUB_TOKEN --log-level info --proxy-logs-dir /tmp/gh-aw/sandbox/firewall/logs --audit-dir /tmp/gh-aw/sandbox/firewall/audit --enable-host-access --allow-host-ports 80,443,8080 --skip-pull \ + -- /bin/bash -c 'set +o histexpand; : "${RUNNER_TOOL_CACHE:?RUNNER_TOOL_CACHE must be set}"; GH_AW_TOOL_CACHE="$RUNNER_TOOL_CACHE"; export PATH="$(find "$GH_AW_TOOL_CACHE" -maxdepth 5 -type d -name bin 2>/dev/null | tr '\''\n'\'' '\'':'\'')$PATH"; [ -n "$GOROOT" ] && export PATH="$GOROOT/bin:$PATH" || true && GH_AW_NODE_EXEC="${GH_AW_NODE_BIN:-}"; if [ -z "$GH_AW_NODE_EXEC" ] || [ ! -x "$GH_AW_NODE_EXEC" ]; then GH_AW_NODE_EXEC="$(command -v node 2>/dev/null || true)"; fi; if [ -z "$GH_AW_NODE_EXEC" ]; then echo "node runtime missing on this runner — check runtimes.node in workflow YAML" >&2; exit 127; fi; GH_AW_NPM_GLOBAL_ROOT="$(npm root -g 2>/dev/null || true)"; if [ -n "$GH_AW_NPM_GLOBAL_ROOT" ]; then export NODE_PATH="${GH_AW_NPM_GLOBAL_ROOT}${NODE_PATH:+:${NODE_PATH}}"; fi; "$GH_AW_NODE_EXEC" ${RUNNER_TEMP}/gh-aw/actions/copilot_harness.cjs /usr/local/bin/copilot --add-dir /tmp/gh-aw/ --log-level all --log-dir /tmp/gh-aw/sandbox/agent/logs/ --disable-builtin-mcps --no-ask-user --allow-all-tools --add-dir "${GITHUB_WORKSPACE}" --prompt-file /tmp/gh-aw/aw-prompts/prompt.txt' 2>&1 | tee -a /tmp/gh-aw/threat-detection/detection.log + env: + AWF_REFLECT_ENABLED: 1 + COPILOT_AGENT_RUNNER_TYPE: STANDALONE + COPILOT_DUMMY_BYOK: dummy-byok-key-for-offline-mode + COPILOT_GITHUB_TOKEN: ${{ github.token }} + COPILOT_MODEL: ${{ vars.GH_AW_MODEL_DETECTION_COPILOT || vars.GH_AW_DEFAULT_MODEL_COPILOT || 'claude-sonnet-4.6' }} + GH_AW_LLM_PROVIDER: github + GH_AW_MAX_AI_CREDITS: ${{ vars.GH_AW_DEFAULT_DETECTION_MAX_AI_CREDITS || '400' }} + GH_AW_MAX_TURNS: ${{ vars.GH_AW_DEFAULT_MAX_TURNS || '' }} + GH_AW_PHASE: detection + GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt + GH_AW_TIMEOUT_MINUTES: 20 + GH_AW_VERSION: v0.81.6 + GITHUB_API_URL: ${{ github.api_url }} + GITHUB_AW: true + GITHUB_COPILOT_INTEGRATION_ID: agentic-workflows + GITHUB_HEAD_REF: ${{ github.head_ref }} + GITHUB_REF_NAME: ${{ github.ref_name }} + GITHUB_SERVER_URL: ${{ github.server_url }} + GITHUB_STEP_SUMMARY: /tmp/gh-aw/agent-step-summary.md + GITHUB_WORKSPACE: ${{ github.workspace }} + GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com + GIT_AUTHOR_NAME: github-actions[bot] + GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com + GIT_COMMITTER_NAME: github-actions[bot] + RUNNER_TEMP: ${{ runner.temp }} + S2STOKENS: true + TRACEPARENT: ${{ env.GITHUB_AW_OTEL_TRACE_ID != '' && env.GITHUB_AW_OTEL_PARENT_SPAN_ID != '' && format('00-{0}-{1}-01', env.GITHUB_AW_OTEL_TRACE_ID, env.GITHUB_AW_OTEL_PARENT_SPAN_ID) || '' }} + - name: Parse threat detection token usage for step summary + id: parse_detection_token_usage + if: always() + continue-on-error: true + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_AW_TOKEN_USAGE_SUMMARY_TITLE: Threat Detection Token Usage + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_token_usage.cjs'); + await main(); + - name: Upload threat detection log + if: always() && steps.detection_guard.outputs.run_detection == 'true' + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: detection + path: /tmp/gh-aw/threat-detection/detection.log + if-no-files-found: ignore + - name: Parse and conclude threat detection + id: detection_conclusion + if: always() + continue-on-error: true + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + RUN_DETECTION: ${{ steps.detection_guard.outputs.run_detection }} + DETECTION_AGENTIC_EXECUTION_OUTCOME: ${{ steps.detection_agentic_execution.outcome }} + GH_AW_DETECTION_CONTINUE_ON_ERROR: "true" + with: + script: | + try { + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_threat_detection_results.cjs'); + await main(); + } catch (loadErr) { + const continueOnError = process.env.GH_AW_DETECTION_CONTINUE_ON_ERROR !== 'false'; + const detectionExecutionFailed = process.env.DETECTION_AGENTIC_EXECUTION_OUTCOME === 'failure'; + const msg = 'ERR_SYSTEM: \u274C Unexpected error loading threat detection module: ' + (loadErr && loadErr.message ? loadErr.message : String(loadErr)); + core.error(msg); + core.setOutput('reason', 'parse_error'); + if (continueOnError && !detectionExecutionFailed) { + core.warning('\u26A0\uFE0F ' + msg); + core.setOutput('conclusion', 'warning'); + core.setOutput('success', 'false'); + } else { + core.setOutput('conclusion', 'failure'); + core.setOutput('success', 'false'); + core.setFailed(msg); + } + } + + pre_activation: + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.id == github.repository_id + runs-on: ubuntu-slim + env: + GH_AW_RUNTIME_FEATURES: ${{ vars.GH_AW_RUNTIME_FEATURES }} + outputs: + activated: ${{ steps.check_membership.outputs.is_team_member == 'true' }} + matched_command: '' + setup-parent-span-id: ${{ steps.setup.outputs.parent-span-id || steps.setup.outputs.span-id }} + setup-span-id: ${{ steps.setup.outputs.span-id }} + setup-trace-id: ${{ steps.setup.outputs.trace-id }} + steps: + - name: Setup Scripts + id: setup + uses: github/gh-aw-actions/setup@ba6380cc6e5be5d21677bebe04d52fb48e3abec7 # v0.81.6 + with: + destination: ${{ runner.temp }}/gh-aw/actions + job-name: ${{ github.job }} + env: + GH_AW_SETUP_WORKFLOW_NAME: "Dockerfile Readiness Report" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/dockerfile-readiness.lock.yml@${{ github.ref }} + GH_AW_INFO_VERSION: "1.0.65" + GH_AW_INFO_AWF_VERSION: "v0.27.11" + GH_AW_INFO_ENGINE_ID: "copilot" + - name: Check team membership for workflow + id: check_membership + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_AW_REQUIRED_ROLES: "admin,maintainer,write" + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/check_membership.cjs'); + await main(); + + safe_outputs: + needs: + - activation + - agent + - detection + if: (!cancelled()) && needs.agent.result != 'skipped' && needs.detection.result == 'success' + runs-on: ubuntu-slim + permissions: + contents: read + issues: write + pull-requests: write + timeout-minutes: 45 + env: + GH_AW_AGENT_AIC: ${{ needs.agent.outputs.aic }} + GH_AW_AIC: ${{ needs.agent.outputs.aic }} + GH_AW_AMBIENT_CONTEXT: ${{ needs.agent.outputs.ambient_context }} + GH_AW_CALLER_WORKFLOW_ID: "${{ github.repository }}/dockerfile-readiness" + GH_AW_DETECTION_CONCLUSION: ${{ needs.detection.outputs.detection_conclusion }} + GH_AW_DETECTION_REASON: ${{ needs.detection.outputs.detection_reason }} + GH_AW_EFFECTIVE_TOKENS: ${{ needs.agent.outputs.effective_tokens }} + GH_AW_ENGINE_ID: "copilot" + GH_AW_ENGINE_MODEL: ${{ needs.agent.outputs.model }} + GH_AW_ENGINE_VERSION: "1.0.65" + GH_AW_RUNTIME_FEATURES: ${{ vars.GH_AW_RUNTIME_FEATURES }} + GH_AW_THREAT_DETECTION_AIC: ${{ needs.detection.outputs.aic }} + GH_AW_WORKFLOW_ID: "dockerfile-readiness" + GH_AW_WORKFLOW_NAME: "Dockerfile Readiness Report" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/${{ github.repository }}/blob/${{ github.ref_name }}/.github/workflows/dockerfile-readiness.md" + outputs: + code_push_failure_count: ${{ steps.process_safe_outputs.outputs.code_push_failure_count }} + code_push_failure_errors: ${{ steps.process_safe_outputs.outputs.code_push_failure_errors }} + comment_id: ${{ steps.process_safe_outputs.outputs.comment_id }} + comment_url: ${{ steps.process_safe_outputs.outputs.comment_url }} + create_discussion_error_count: ${{ steps.process_safe_outputs.outputs.create_discussion_error_count }} + create_discussion_errors: ${{ steps.process_safe_outputs.outputs.create_discussion_errors }} + process_safe_outputs_processed_count: ${{ steps.process_safe_outputs.outputs.processed_count }} + process_safe_outputs_temporary_id_map: ${{ steps.process_safe_outputs.outputs.temporary_id_map }} + steps: + - name: Setup Scripts + id: setup + uses: github/gh-aw-actions/setup@ba6380cc6e5be5d21677bebe04d52fb48e3abec7 # v0.81.6 + with: + destination: ${{ runner.temp }}/gh-aw/actions + job-name: ${{ github.job }} + trace-id: ${{ needs.activation.outputs.setup-trace-id }} + parent-span-id: ${{ needs.activation.outputs.setup-parent-span-id || needs.activation.outputs.setup-span-id }} + env: + GH_AW_SETUP_WORKFLOW_NAME: "Dockerfile Readiness Report" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/dockerfile-readiness.lock.yml@${{ github.ref }} + GH_AW_INFO_VERSION: "1.0.65" + GH_AW_INFO_AWF_VERSION: "v0.27.11" + GH_AW_INFO_ENGINE_ID: "copilot" + - name: Download agent output artifact + id: download-agent-output + continue-on-error: true + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: agent + path: /tmp/gh-aw/ + - name: Setup agent output environment variable + id: setup-agent-output-env + if: steps.download-agent-output.outcome == 'success' + run: | + mkdir -p /tmp/gh-aw/ + find "/tmp/gh-aw/" -type f -print + echo "GH_AW_AGENT_OUTPUT=/tmp/gh-aw/agent_output.json" >> "$GITHUB_OUTPUT" + - name: Configure GH_HOST for enterprise compatibility + id: ghes-host-config + shell: bash + run: | # zizmor: ignore[github-env] - GITHUB_SERVER_URL is set by GitHub Actions, not user input. + # Derive GH_HOST from GITHUB_SERVER_URL so the gh CLI targets the correct + # GitHub instance (GHES/GHEC). On github.com this is a harmless no-op. + GH_HOST="${GITHUB_SERVER_URL#https://}" + GH_HOST="${GH_HOST#http://}" + echo "GH_HOST=${GH_HOST}" >> "$GITHUB_ENV" + - name: Process Safe Outputs + id: process_safe_outputs + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} + GH_AW_COMMENT_ID: ${{ needs.activation.outputs.comment_id }} + GH_AW_ALLOWED_DOMAINS: "api.business.githubcopilot.com,api.enterprise.githubcopilot.com,api.github.com,api.githubcopilot.com,api.individual.githubcopilot.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,github.com,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,ppa.launchpad.net,raw.githubusercontent.com,registry.npmjs.org,s.symcb.com,s.symcd.com,security.ubuntu.com,telemetry.enterprise.githubcopilot.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com" + GITHUB_SERVER_URL: ${{ github.server_url }} + GITHUB_API_URL: ${{ github.api_url }} + GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: "{\"add_comment\":{\"hide_older_comments\":true,\"max\":1},\"create_report_incomplete_issue\":{},\"missing_data\":{},\"missing_tool\":{},\"noop\":{\"max\":1,\"report-as-issue\":\"false\"},\"report_incomplete\":{}}" + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require('${{ runner.temp }}/gh-aw/actions/safe_output_handler_manager.cjs'); + await main(); + - name: Upload Safe Outputs Items + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: safe-outputs-items + path: | + /tmp/gh-aw/safe-output-items.jsonl + /tmp/gh-aw/temporary-id-map.json + if-no-files-found: ignore diff --git a/.github/workflows/dockerfile-readiness.md b/.github/workflows/dockerfile-readiness.md new file mode 100644 index 0000000000000000000000000000000000000000..265b947cfd796b237dfb883d29fd85399033c0c1 --- /dev/null +++ b/.github/workflows/dockerfile-readiness.md @@ -0,0 +1,345 @@ +--- +on: + pull_request: + paths: + - '*/jdk/**' + - '*/jre/**' + workflow_dispatch: + inputs: + pr-number: + description: 'PR number to analyze' + required: true + type: number + +permissions: + contents: read + pull-requests: read + copilot-requests: write + +safe-outputs: + add-comment: + hide-older-comments: true + noop: + report-as-issue: false + +checkout: + fetch-depth: 0 + +concurrency: + group: dockerfile-readiness-${{ github.ref }} + cancel-in-progress: true + +timeout-minutes: 60 + +steps: + - name: Set up Python + uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 + with: + python-version: '3.x' + - name: Install dependencies + run: pip install -r requirements.txt + - name: Generate current manifest + run: python3 dockerhub_doc_config_update.py eclipse-temurin + - name: Fetch official upstream manifest + run: | + curl -sSfL \ + https://raw.githubusercontent.com/docker-library/official-images/master/library/eclipse-temurin \ + -o official-eclipse-temurin +--- + +# Dockerfile Readiness Report + +You are a release-readiness analysis agent for the Eclipse Adoptium containers +repository. Your job is to compare the **locally generated manifest** +(`eclipse-temurin`) against the **upstream published manifest** +(`official-eclipse-temurin`) and produce a clear, version-grouped readiness +summary as a PR comment. + +## Context + +This repository generates Docker images for Eclipse Temurin OpenJDK builds. +The build pipeline works as follows: + +1. `generate_dockerfiles.py` creates Dockerfiles under `///` + directories using the configuration in `config/temurin.yml` and data from the + Adoptium API. +2. `dockerhub_doc_config_update.py` reads those Dockerfiles and produces a + manifest file (`eclipse-temurin`) that describes every image entry: its tags, + architectures, git commit, and directory. +3. The upstream published manifest (`official-eclipse-temurin`) is what is + currently live on Docker Hub via the docker-library/official-images repository. + +Each manifest entry (block) looks like: + +``` +Tags: 21.0.7_6-jdk-noble, 21-jdk-noble, 21-noble +SharedTags: 21.0.7_6-jdk, 21-jdk, 21 +Architectures: amd64, arm64v8, ppc64le, riscv64, s390x +GitCommit: abc123 +Directory: 21/jdk/ubuntu/noble +``` + +The **upstream manifest** (`official-eclipse-temurin`) defines the **expected** set — +it is the source of truth for what is currently published on Docker Hub. It contains +entries grouped by version, each with a set of distros, architectures, and a git commit. +The locally generated manifest (`eclipse-temurin`) represents what this PR *wants* to +publish. Comparing them reveals what changed, what's new, and what's missing. + +Architecture name mapping between config/Dockerfiles and the manifest: +- `x64` / `amd64` / `x86_64` → `amd64` +- `aarch64` / `arm64` → `arm64v8` +- `arm` / `armhf` → `arm32v7` +- `ppc64le` / `ppc64el` → `ppc64le` +- `s390x` → `s390x` +- `riscv64` → `riscv64` +- Windows entries always show `windows-amd64` + +## Instructions + +### Step 1: Parse both manifests + +Read the files `eclipse-temurin` (local/PR version) and `official-eclipse-temurin` +(upstream). Parse them into structured data. Each block is separated by a blank +line. Extract from each block: +- **Tags** (the first tag line) +- **Architectures** (comma-separated list) +- **Directory** (e.g., `21/jdk/ubuntu/noble`) +- **GitCommit** + +From the Directory field, derive: +- **Version** (e.g., `21`) +- **Package type** (`jdk` or `jre`) +- **Distro** (e.g., `ubuntu/noble`, `alpine/3.23`, `ubi/ubi10-minimal`, `windows/nanoserver-ltsc2022`) + +### Distro family grouping + +Several distro variants within the same OS family ship **identical binaries** and +differ only in the base image. Group these into a single row in the report to +reduce noise: + +| Family | Variants (examples) | Group label | +|--------|---------------------|-------------| +| **Alpine** | `alpine/3.21`, `alpine/3.22`, `alpine/3.23` | `alpine` | +| **UBI** | `ubi/ubi9-minimal`, `ubi/ubi10-minimal` | `ubi` | +| **Windows** | `windows/nanoserver-ltsc2022`, `windows/nanoserver-ltsc2025`, `windows/windowsservercore-ltsc2022`, `windows/windowsservercore-ltsc2025` | `windows` | + +**Ubuntu is the exception** — different Ubuntu releases support different +architecture sets (e.g., `noble` adds `riscv64` which `jammy` does not have), +so each Ubuntu release must remain a separate row. + +When grouping: +- A family group is **✅ Complete** only if *every* variant in the group is complete. +- If any variant is missing or has missing architectures, the group is not complete. + List the specific variants that are incomplete in the Notes column. +- For stale-version detection, all variants in a group must be at the same Java + version. If any variant is stale, mark the group as stale and note which + variants are behind. + +### Step 2: Read deprecation rules from config + +Read `config/temurin.yml` to understand distro deprecation rules. Each distro +entry may have a `deprecated: N` field meaning it is skipped for versions >= N. +For example, `deprecated: 25` on `ubi/ubi9-minimal` means versions 25 and above +will not have ubi9-minimal images. + +When a version exists in the local manifest but not upstream (i.e. it is a **new +version**), check which distros have been **intentionally skipped** due to +deprecation. Include a "Skipped (deprecated)" section in the report for that +version so reviewers can confirm the omissions are deliberate. + +### Step 3: Compare local vs upstream per version + +JDK and JRE are always published together as a pair, so treat them as a single +unit per distro. Apply the distro family grouping from Step 1 — collapse Alpine, +UBI, and Windows variants into single family rows, keeping Ubuntu releases +separate. For each Java version (8, 11, 17, 21, 25, 26, etc.), compare +the local manifest against the upstream manifest: + +1. **Matching entries** (same Directory in both): Have architectures been added + or removed? Has the Java version (from tags) changed? Has the GitCommit + changed? + +2. **New entries** (in local but not upstream): New distro variants, new + versions, or new architecture additions. + + **Predicting expected architectures for new distros**: When an entry is new + (exists in local but has no matching upstream entry), do NOT compare its + architectures against a global or theoretical architecture list. Instead, + predict the expected architectures by looking at **other distros in the same + family and same Java version**. For example: + - A new `ubuntu/resolute` entry for JDK 8 should be compared against the + existing `ubuntu/noble` and `ubuntu/jammy` entries for JDK 8 — if those + only ship `amd64, arm32v7, arm64v8, ppc64le`, then those are the expected + architectures for `ubuntu/resolute` too. Do NOT flag `riscv64` or `s390x` + as missing if no other Ubuntu for that JDK version ships them. + - A new `alpine/3.24` should look at `alpine/3.23`, `alpine/3.22`, etc. for + the same Java version. + - A new `ubi/ubi11-minimal` should look at `ubi/ubi10-minimal`, + `ubi/ubi9-minimal` for the same Java version. + - For an entirely new Java version with no upstream entries at all, use the + entries within that same version to cross-check each other (e.g., compare + all Ubuntu entries against each other within that version). + + This ensures architecture expectations are grounded in what is actually + published for that JDK version, not in a superset of all possible arches. + +3. **Removed entries** (in upstream but not local): Distros being dropped, + deprecated variants removed. + +4. **Architecture changes**: For each entry that exists in both, list any + architectures added or removed compared to upstream. + +5. **Per-entry version consistency**: Extract the specific Java version string + from the Tags of **each individual entry** (not just the first one you see). + Within a Java major version, if some entries show a new Java version while + others still show the old version, the entries at the old version are + **stale** — they have not been updated yet. This commonly happens with + Windows entries, which are built and published on a separate schedule from + Linux entries. + + **Critical rule**: An entry that is stale (still at the old Java version) + must NOT be marked "✅ Complete", even if its architectures match upstream + exactly. Matching upstream means it has not been modified in this PR, not + that it is ready. Mark such entries as: + `⏳ Not yet updated (still at )` + +### Step 4: Determine readiness per version + +First, check whether the version has **any changes at all** compared to upstream. +A version has **no updates** if ALL of the following are true for every entry: +- The Java version string in the tags is identical to upstream +- The set of architectures is identical to upstream +- No entries were added or removed + +A version with no updates must be marked **⏭️ No Updates** — do NOT mark it as +"Ready to Ship". This is critical: "Ready to Ship" implies the version was updated +and the update is complete, which is misleading when nothing changed. Use this +status to signal to reviewers that this version was not touched by the PR. + +A version is **Ready to Ship** only if ALL of the following are true: +- There is at least one change from upstream (version bump, GitCommit change, new entry, or architecture change) +- Every distro/arch entry that exists upstream also exists locally (nothing dropped unintentionally) +- For every entry in both manifests, the local architectures include all architectures listed upstream (no regressions) +- The Java version in the tags is **identical across every single entry** for + that major version — including all Linux AND all Windows entries. If Linux + entries show `17.0.19_10` but Windows entries still show `17.0.18_8`, the + version is NOT consistent and CANNOT be marked Ready to Ship. +- Both jdk and jre entries exist for all distros that had them upstream (they are always published as a pair) +- All windows variants (servercore + nanoserver for each LTSC version) present upstream are also present locally + +A version is **Partially Ready** if: +- Some entries match upstream but others have missing architectures +- The jdk is present but jre is missing for some distros (or vice versa) +- New distros/arches have been added but some local entries are missing architectures that upstream has +- Some entries have been bumped to the new Java version but others are still at + the old version (e.g. Linux updated but Windows stale). In this case the + summary must explicitly list which entries are stale and at which version. + +A version is **Not Ready** if: +- Most upstream entries are missing from the local manifest +- Architecture coverage has regressed significantly +- No Dockerfiles exist yet for this version + +### Step 5: Produce the summary + +Output a clear markdown report. Use this structure: + +```markdown +## Dockerfile Readiness Report + +### Summary + +| Version | Status | Java Version | Missing Distros | Missing Arches | Notes | +|---------|--------|-------------|-----------------|----------------|-------| +| 8 | ⏭️ No Updates | 8u482-b08 | — | — | Unchanged from upstream | +| 11 | ⚠️ Partial | 11.0.30_7 | — | noble: riscv64 | New arch not yet built | +| 21 | ✅ Ready | 21.0.7_6 | — | — | Version bumped from 21.0.6_7 | +| 17 | ⚠️ Partial | 17.0.19_10 | — | noble: arm64v8, s390x | Linux bumped; Windows stale at 17.0.18_8 | +| 25 | ❌ Not Ready | 25.0.2_10 | alpine/3.23 (jre) | noble: s390x | First release, ubi9-minimal skipped (deprecated) | + +### Version Details + +#### JDK 8 — ⏭️ No Updates + +No changes detected — Java version, architectures, and GitCommit are all +identical to upstream. This version was not updated in this PR. + +#### JDK 17 — ⚠️ Partially Ready + +**Java Version:** `17.0.19_10` (upstream: `17.0.18_8` — version bump) + +| Distro | Arches | Entry Version | Status | +|--------|--------|--------------|--------| +| alpine | amd64 | 17.0.19_10 | ✅ Complete (3.21, 3.22, 3.23) | +| ubuntu/noble | amd64, ppc64le | 17.0.19_10 | ⚠️ Missing arm32v7, arm64v8, riscv64, s390x | +| ubuntu/jammy | amd64, arm32v7, arm64v8, ppc64le, s390x | 17.0.19_10 | ✅ Complete | +| ubi | amd64, arm64v8, ppc64le, s390x | 17.0.19_10 | ✅ Complete (ubi9-minimal, ubi10-minimal) | +| windows | windows-amd64 | 17.0.18_8 | ⏳ Not yet updated — all 4 variants still at 17.0.18_8 | + +**Changes from upstream:** +- Version bumped from 17.0.18_8 to 17.0.19_10 (Linux only — Windows not yet updated) +- GitCommit changed (Dockerfiles updated) + +#### JDK 21 — ✅ Ready to Ship + +**Java Version:** `21.0.7_6` (upstream: `21.0.6_7` — version bump) + +| Distro | Arches | Entry Version | Status | +|--------|--------|--------------|--------| +| alpine | amd64, arm64v8 | 21.0.7_6 | ✅ Complete (3.21, 3.22, 3.23) | +| ubuntu/noble | amd64, arm32v7, arm64v8, ppc64le, riscv64, s390x | 21.0.7_6 | ✅ Complete | +| ubuntu/jammy | amd64, arm32v7, arm64v8, ppc64le, s390x | 21.0.7_6 | ✅ Complete | +| ubi | amd64, arm64v8, ppc64le, s390x | 21.0.7_6 | ✅ Complete (ubi9-minimal, ubi10-minimal) | +| windows | windows-amd64 | 21.0.7_6 | ✅ Complete (all 4 variants) | + +**Changes from upstream:** +- Version bumped from 21.0.6_7 to 21.0.7_6 +- GitCommit changed (Dockerfiles updated) + +#### JDK 25 — ❌ Not Ready (new version) + +**Skipped distros (deprecated in config/temurin.yml):** +- `ubi/ubi9-minimal` — deprecated for versions >= 25 +- `alpine/3.21` — deprecated for versions >= 26 (still included for 25) + +(repeat for each version) +``` + +### Important rules + +- Always group by Java version number (8, 11, 17, 21, 25, 26). +- JDK and JRE are always published together. Show one row per distro (not + separate rows for jdk/jre). Only flag an issue if one of the pair is missing. +- Group Alpine, UBI, and Windows variants into a single row per family. List + the individual variants covered in the Status column (e.g., + "✅ Complete (3.21, 3.22, 3.23)"). Keep each Ubuntu release as its own row + because Ubuntu releases differ in supported architectures. +- Clearly highlight any architecture that is in the config but missing from the + manifest — these are **unpublished architectures** that haven't been built yet. +- Clearly highlight any architecture in the manifest that is NOT in the config — + these are **new architectures** that have been added. +- If a version exists in local but not upstream, mark it as a **new version**. +- If the Java version string changed between upstream and local, call it out as a + **version bump**. +- Be precise about which specific distro + arch combinations are missing. +- **Architecture expectations for new distros must be derived from sibling + distros** in the same Java version, not from a global architecture list. + Different Java versions support different architecture sets (e.g., JDK 8 + does not ship `riscv64` or `s390x` on Ubuntu, while JDK 21 does). Always + use sibling distros within the same version as the baseline. +- **Stale entry detection**: When a version bump has occurred, check EVERY entry's + Tags to extract its individual Java version. If an entry's Java version matches + the OLD upstream version (not the new bumped version), it is **stale** — it has + not been updated in this PR. This is critical for Windows entries, which are + often built separately. Stale entries must be marked `⏳ Not yet updated` in + the detail table and called out in the summary. Never mark a stale entry as + "✅ Complete". +- For new versions not yet upstream, read `config/temurin.yml` and list which + distros are intentionally skipped due to `deprecated` rules. This helps + reviewers distinguish deliberate omissions from missing builds. +- Do NOT recommend blocking the merge or waiting for missing architectures. + This repository uses automated PRs that are auto-merged when CI passes. + Missing architectures will be added in subsequent automated PRs — the order + in which architectures appear does not matter. The report is purely + informational to help reviewers understand the current state. +- Post the report as a PR comment. diff --git a/.github/workflows/sanity.yml b/.github/workflows/sanity.yml new file mode 100644 index 0000000000000000000000000000000000000000..7e362ccedc5a79906ed70b5397d6c6cb4ca37a60 --- /dev/null +++ b/.github/workflows/sanity.yml @@ -0,0 +1,17 @@ +name: Sanity + +on: + pull_request: + +permissions: + contents: read + +jobs: + sanity: + name: Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Run Sanity Check Script + run: "bash sanity.sh" diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml new file mode 100644 index 0000000000000000000000000000000000000000..5d17586b632751d7fe188aaf7f18cdefa82c0603 --- /dev/null +++ b/.github/workflows/scorecards.yml @@ -0,0 +1,71 @@ +# This workflow uses actions that are not certified by GitHub. They are provided +# by a third-party and are governed by separate terms of service, privacy +# policy, and support documentation. + +name: Scorecard supply-chain security +on: + # For Branch-Protection check. Only the default branch is supported. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection + branch_protection_rule: + # To guarantee Maintained check is occasionally updated. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained + schedule: + - cron: '20 7 * * 2' + push: + branches: ["main"] + +# Declare default permissions as read only. +permissions: read-all + +jobs: + analysis: + name: Scorecard analysis + runs-on: ubuntu-latest + permissions: + # Needed to upload the results to code-scanning dashboard. + security-events: write + # Needed to publish results and get a badge (see publish_results below). + id-token: write + contents: read + actions: read + + steps: + - name: "Checkout code" + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: "Run analysis" + uses: ossf/scorecard-action@2d1146689b8cda280b9bc96326124645441f03bc # v2.4.4 + with: + results_file: results.sarif + results_format: sarif + # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: + # - you want to enable the Branch-Protection check on a *public* repository, or + # - you are installing Scorecards on a *private* repository + # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat. + # repo_token: ${{ secrets.SCORECARD_TOKEN }} + + # Public repositories: + # - Publish results to OpenSSF REST API for easy access by consumers + # - Allows the repository to include the Scorecard badge. + # - See https://github.com/ossf/scorecard-action#publishing-results. + # For private repositories: + # - `publish_results` will always be set to `false`, regardless + # of the value entered here. + publish_results: true + + # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF + # format to the repository Actions tab. + - name: "Upload artifact" + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: SARIF file + path: results.sarif + retention-days: 5 + + # Upload the results to GitHub's code scanning dashboard. + - name: "Upload to code-scanning" + uses: github/codeql-action/upload-sarif@d1ba80a13dd99fba24a470575428917156a28b43 # v4.37.5 + with: + sarif_file: results.sarif diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml new file mode 100644 index 0000000000000000000000000000000000000000..82136ec93351deed45bc2124394e98a9d5bc682f --- /dev/null +++ b/.github/workflows/test-pr.yml @@ -0,0 +1,96 @@ +name: Test PR + +on: + pull_request: + +defaults: + run: + shell: 'bash -Eeuo pipefail -x {0}' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: read-all + +jobs: + changes: + name: Detect Changes + runs-on: ubuntu-latest + outputs: + should_test: ${{ steps.filter.outputs.code }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3 + id: filter + with: + filters: | + code: + - '**/*.py' + - '.github/workflows/test-pr.yml' + - 'docker_templates/**' + - 'config/**' + - '**/Dockerfile' + - '**/entrypoint.sh‎' + - 'requirements.txt' + + generate-jobs: + name: Generate Jobs + needs: changes + if: needs.changes.outputs.should_test == 'true' + runs-on: ubuntu-latest + outputs: + strategy: ${{ steps.generate-jobs.outputs.strategy }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - run: pip install pyyaml + - uses: docker-library/bashbrew@a519e31d2ed9cb229ff38ab4488e78bfa09d7a2a # v0.1.14 + - id: generate-jobs + name: Generate Jobs + run: | + export GENERATE_STACKBREW_LIBRARY='python3 dockerhub_doc_config_update.py /dev/stdout' + export GITHUB_REPOSITORY="eclipse-temurin" + strategy="$("$BASHBREW_SCRIPTS/github-actions/generate.sh")" + echo "strategy=$strategy" >> "$GITHUB_OUTPUT" + jq . <<<"$strategy" # sanity check / debugging aid + test: + needs: generate-jobs + if: needs.generate-jobs.result == 'success' + strategy: ${{ fromJson(needs.generate-jobs.outputs.strategy) }} + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + # Temporary workaround for https://github.com/actions/runner-images/issues/13729 + - name: Docker issue workaround + if: contains(matrix.os, 'windows') + shell: pwsh + run: | + $dockerState = Get-Service -Name "docker" + if ($dockerState.Status -ne "Running") { + Start-Service -Name "docker" + } + - name: Prepare Environment + run: ${{ matrix.runs.prepare }} + - name: Pull Dependencies + run: ${{ matrix.runs.pull }} + - name: Build ${{ matrix.name }} + run: ${{ matrix.runs.build }} + - name: Test ${{ matrix.name }} + run: ${{ matrix.runs.test }} + - name: '"docker images"' + run: ${{ matrix.runs.images }} + + conclusion: + name: Test PR Conclusion + needs: [changes, test] + runs-on: ubuntu-latest + if: always() + steps: + - name: Result + run: | + if [[ "${{ needs.changes.outputs.should_test }}" != "true" ]]; then + echo "No relevant changes detected, skipping tests" + exit 0 + fi + ${{ needs.test.result == 'success' }} diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml new file mode 100644 index 0000000000000000000000000000000000000000..c639808e66ec441f9bd466bf99e95dce49c575aa --- /dev/null +++ b/.github/workflows/updater.yml @@ -0,0 +1,41 @@ +name: Dockerfile Updater +on: + workflow_dispatch: + schedule: + # Runs every half hour + - cron: "*/30 * * * *" + +permissions: read-all + +jobs: + update_dockerfile: + permissions: + contents: write + pull-requests: write + if: startsWith(github.repository, 'adoptium/') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: "3.x" + + - name: Install dependencies + run: "pip3 install -r requirements.txt" + + - name: Run updater + run: "python3 generate_dockerfiles.py --force" + + - uses: gr2m/create-or-update-pull-request-action@b65137ca591da0b9f43bad7b24df13050ea45d1b # v1.10.1 + env: + GITHUB_TOKEN: ${{ secrets.ADOPTIUM_TEMURIN_BOT_TOKEN }} + with: + title: "Update Dockerfiles" + body: "This is an automatically generated pull request, it will be automatically merged if all the CI tests pass." + branch: "dockerfile_bot" + commit-message: "dockerfile: automated nightly updates" + labels: automerge + author: "eclipse-temurin-bot " diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..906d3ec0ee3f001906637daa998536249172d4b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +.idea +.idea/vcs.xml +*_shasums_latest.sh +*_build_time_latest.sh +manifest_commands.sh +hadolint/ +shellcheck/ +eclipse-temurin +official-eclipse-temurin +*hotspot.txt +library/ +.vscode/ +__pycache__/ +/adoptium_cache.sqlite +lib/ +bin/ +pyvenv.cfg diff --git a/.test/config.sh b/.test/config.sh new file mode 100644 index 0000000000000000000000000000000000000000..f52df2cc4d8f74e72a16f41d6c5f5e02762bfc0f --- /dev/null +++ b/.test/config.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +imageTests[openjdk]+=' + java-ca-certificates-update +' + +globalExcludeTests+=( + # nanoserver/windowsservercore: updating local store with additional certificates is not implemented + [openjdk:nanoserver_java-ca-certificates-update]=1 + [openjdk:windowsservercore_java-ca-certificates-update]=1 +) diff --git a/.test/tests/java-ca-certificates-update/certs/.dockerbuilder.crt b/.test/tests/java-ca-certificates-update/certs/.dockerbuilder.crt new file mode 100644 index 0000000000000000000000000000000000000000..73838f46daab4b99987ba1326ab455a0a819cf55 --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs/.dockerbuilder.crt @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDRTCCAi2gAwIBAgIUIfl8I/yasxlsTEc30PLLRuleiCswDQYJKoZIhvcNAQEL +BQAwMTEXMBUGCgmSJomT8ixkARkWB1RlbXVyaW4xFjAUBgNVBAMMDURvY2tlckJ1 +aWxkZXIwIBcNMjMwNjEyMTgyNDE1WhgPMzAwMzA4MTQxODI0MTVaMDExFzAVBgoJ +kiaJk/IsZAEZFgdUZW11cmluMRYwFAYDVQQDDA1Eb2NrZXJCdWlsZGVyMIIBIjAN +BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArfOgmluNXEIE7BWvt7jGgdZW/y5s +N78FcpZdM8Z2FatvjJKvNmJ9OkkkOSNBhGKAWpHn19JMNdQ2nEmTHMetg0hiSqRI +hBceAY4lDfOzxAyZGGpVzL9U1B9mOrX5O3EedF5AVvl0NZVjEwswuGaUa3zZBAKy +Z5Vv/z8Lw2uYIs/dtw8lcpEAb78BZ8bAhhhl+X+tTGK8agibLGQJT9l/JxS3pXyw +me4YaKQQRgvuqOTEt+x+0aA5E2EUTOGq0Li+i1ranf6ou5Dz/Y6LtXwT/j2bf4ZR +w2YHpYZL54UEtMWES2KAjsZ3u4DCxUIEfW8EgxUIhcepIDP1h05A3fSiWQIDAQAB +o1MwUTAdBgNVHQ4EFgQUr0VirSzDQTuNgGjDxRkxPFrjUKcwHwYDVR0jBBgwFoAU +r0VirSzDQTuNgGjDxRkxPFrjUKcwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0B +AQsFAAOCAQEAlo6ZSAIKSUWqRygyNg9oWuLGfWMW//dZjU1MKBYVpM4Mry/aMD5d +kMQj9hm+zXhNYN01yLh/cdPKCQ/r1KP6lmCtZHp50Xe8HEnIymRYx0KMAcqYLjnT +DXwCPqtWvJ1do65vVJRN70CuF8T1JNFhPdirrAiuU7bhGPABfnbek7yNkTYgUSdb +WpV/WOFPh9Dl24vNl1/Cti+pQThlCgHF/+dVndFHN9FOOG8k8ohYkLwL+ZzKfOiZ +CVWn2mWk2EhcuTlg/3zkXmwjfzFTdXMhS1sdfJNReaY/omJ91euxB0c8iYZV4wuU +ghx+GJ14nO7RJNHNX4k+BBPxy3f56+cYrg== +-----END CERTIFICATE----- diff --git a/.test/tests/java-ca-certificates-update/certs/.dockerbuilder.key b/.test/tests/java-ca-certificates-update/certs/.dockerbuilder.key new file mode 100644 index 0000000000000000000000000000000000000000..4226cb968f6d50b7cdce112ea7256806c7e4a026 --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs/.dockerbuilder.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCt86CaW41cQgTs +Fa+3uMaB1lb/Lmw3vwVyll0zxnYVq2+Mkq82Yn06SSQ5I0GEYoBakefX0kw11Dac +SZMcx62DSGJKpEiEFx4BjiUN87PEDJkYalXMv1TUH2Y6tfk7cR50XkBW+XQ1lWMT +CzC4ZpRrfNkEArJnlW//PwvDa5giz923DyVykQBvvwFnxsCGGGX5f61MYrxqCJss +ZAlP2X8nFLelfLCZ7hhopBBGC+6o5MS37H7RoDkTYRRM4arQuL6LWtqd/qi7kPP9 +jou1fBP+PZt/hlHDZgelhkvnhQS0xYRLYoCOxne7gMLFQgR9bwSDFQiFx6kgM/WH +TkDd9KJZAgMBAAECggEAAi4knsKpKn/xAATZO2LaFBcGZ0ji64Od/cduMB+w67PG +yxAsmNsnqX3GBzROq3+GOdG3LPCSastNNZduJq/HAuH69Ly15E1GNOvzQXHtmHZg +SzAhVqwK6WS3sI0xgZdOSSmZl1glkXqyRPMV333OUZbn68GykD331c8UZpTi5tlx +qdOSEWwXQyVXh2mTT8uWWvqJm8OVaSUEo0KPNhsfWliINAXaDvlFle18wb0sQvAK +d/49VMmEoQMocHcXas5jVHZZzxwQ8gV+cA1nFOzOEOYX1IyHjJdfEUWT7Pa3LEjg +rPjEe/KiA3X9mVmofRG0Gvl8YjMiUEOBF/p9hgUxfQKBgQDY3oBUpkwhy3lRw2nu +PublbozVZi12hrEPIlqLSIda6i0hbCA2E5VBykuP7z0VnQOiHQWQPJ77BYEzR6xw +Z/PoJJL8knxtqVg9FsQlcsseDNW2THp53vf/Fiy4t+GoJZ7yezVyYI7RzngDPnCw +buiYUsd9+uKo8+Gs0fnZGSuRvQKBgQDNVrS2/A8NKRv/3cddNqEN4m16pVmAJg8G +Ww7t40W9c/lPW2SBH7wpEUW37N3b8lv1A8L24nJSbqiMjIkFxWroeOeFFEzKWp9r +BlFUu0kn5oAOI1NJOEOmjR9+SslDXetKDJpon60GYWJ8ke5jfaYUTEWIxUXRYOsX +mg8+L2iGzQKBgQCrzWiAptU9GIJdoZ8znCUysKdlDvMJKJ7vzFlKagTAoy9pgMzr +ygu9+NJvjikoDCEqti8IGt4fIjc+NpOG4PM6fm7rI+jqvvMmQfjVaeE7RxOuvVtx +XI++RwTauOFNYbBPjAfFOnUqBJTSjQ6c1t/we/OJ+8y/56RqUlXKBMSdSQKBgQDD +Wz2dZduwCq9/0/FL5qB9hDHiYJPxDsR2qIVgoDyGjWLhNDM/ggDTFYK+BNXi3wbL +6aNAnZpkgLFM3puyaOtYd0bVXsXcMzG+cglI0tI76tlkGgmv/J6oQ1V2IxKuTBmB +ntH8vgWwr1Ay8efasf0jDJmPERhmpo2kK8daw2Hv9QKBgAaxusMUdCSBu5YwI6u4 +6d0nN6WdY2aVcgQXbhJEpsaxT9KqN+LP5wZNf08hyUiO4zSrfVOapOS+10Ng1EYi +YQi8SjQd5deIc/jKKT5k9lCRcfhDq7YQo5pZbUgzDDuxod0WduvBnrf4zAl+K32V +1HI3wrgh88qBEGASVY8y6rDH +-----END PRIVATE KEY----- diff --git a/.test/tests/java-ca-certificates-update/certs/.dockerbuilder2.crt b/.test/tests/java-ca-certificates-update/certs/.dockerbuilder2.crt new file mode 100644 index 0000000000000000000000000000000000000000..45861b02a758ad6d438f5ce2815e908eae5563c9 --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs/.dockerbuilder2.crt @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDRzCCAi+gAwIBAgIUZuRSLr7riMCDUFHVQKYQh/abmZQwDQYJKoZIhvcNAQEL +BQAwMjEXMBUGCgmSJomT8ixkARkWB1RlbXVyaW4xFzAVBgNVBAMMDkRvY2tlckJ1 +aWxkZXIyMCAXDTI0MDcyNDIxMDk0NloYDzMwMDQwOTI1MjEwOTQ2WjAyMRcwFQYK +CZImiZPyLGQBGRYHVGVtdXJpbjEXMBUGA1UEAwwORG9ja2VyQnVpbGRlcjIwggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDSs004yyVW4dEREZgTGbN1Dzbc ++VcRXUCfVCuiWFeT8a8oHZrbtNxCXD6whcGvLHsjszJKUCseDLCnSlHIpU6Ax7tP +WGsUhY6Zl8I+JzeB/8tYpyNRCLlm2Rp5Iv4oOX2btKYoUy+oFkWP+N8d1taRSrhR +vbPz+FwFSrtQwuT+grQP9yWO0qFrHL5Vjckg0BjELMYZ4rUx4KsV+JsmCf6oPDt4 +b+gnMoZebumKTJ53Ej/Kh0Z30s+UHR9WlbZ9KEyuBifgErw/USqpibaQbG1UTX1f +5LealeITduNWcXIAkQYHddCyt8YRtO9oVrxxVdFmCtU4qUHlov7kxAdOC/KTAgMB +AAGjUzBRMB0GA1UdDgQWBBQ1oKojBf5qgkezUk6axrz3CjdHmzAfBgNVHSMEGDAW +gBQ1oKojBf5qgkezUk6axrz3CjdHmzAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3 +DQEBCwUAA4IBAQCDUUOV23QzoqeGs7CKHXg+Mvxn6E4Tm395c0RKJRiHXEueQ2JD +e7ywfb11f/vGyudWVKe1wiRuMP4U8G6V3m6C/CSJrz1J3N9fvN23iPaZIh1O0vSr +xOz5UmiSsRW8BEQYCvF8CoWim1fG+KjtRhO6QqKLtK11j6TwZaUBIvSwK+OZKSuw +q8SuBRXNrIJvH0bonOXcuivOkruU0aRdizIG5Ed0OV2PVfbw2gu7Om83ADbVuSOV +noMwGjDVzVRAs8lu4ijuAryshVQK0LkImrwp+YkhRkFus0HWJqi/Ox+BHZt3BiFs +ATt9J3LCLazvP6LGr4rlZixJqM2ZC7dP0lOl +-----END CERTIFICATE----- diff --git a/.test/tests/java-ca-certificates-update/certs/.dockerbuilder2.key b/.test/tests/java-ca-certificates-update/certs/.dockerbuilder2.key new file mode 100644 index 0000000000000000000000000000000000000000..b4fce7f803646983af22b020a0825e06e2ba17bd --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs/.dockerbuilder2.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDSs004yyVW4dER +EZgTGbN1Dzbc+VcRXUCfVCuiWFeT8a8oHZrbtNxCXD6whcGvLHsjszJKUCseDLCn +SlHIpU6Ax7tPWGsUhY6Zl8I+JzeB/8tYpyNRCLlm2Rp5Iv4oOX2btKYoUy+oFkWP ++N8d1taRSrhRvbPz+FwFSrtQwuT+grQP9yWO0qFrHL5Vjckg0BjELMYZ4rUx4KsV ++JsmCf6oPDt4b+gnMoZebumKTJ53Ej/Kh0Z30s+UHR9WlbZ9KEyuBifgErw/USqp +ibaQbG1UTX1f5LealeITduNWcXIAkQYHddCyt8YRtO9oVrxxVdFmCtU4qUHlov7k +xAdOC/KTAgMBAAECggEAANIrB8nVtFbjVrmdnEqVs8drnITzVmYN+gxhaSTiQwuq +9dWyjY6+omPYVma94GKADlR7oXd+7cyLks65rrXRCdi0PaKw6vox9WdkMCY803zr +BWrouq0Hq1W0y3x3WOjrSyjOiTgdwhBDlLH1Vk/tV/VwybOa4dMeRKveFkNmbXKU +ZeR62r95vob4F5Ui6CWqSDRXFSml8VvBkU+6RAm697Lm5JQKoOuUueR9/L5z2Y0Z +rpGeBQ2tbbRIAvQWG3PhQirDqduL2e8aUs/RG8jGmbAnB9LoWJtaBEgLoza6221F +vboRWDLG5yZorXeGHT169+LQQ84rtwyjbQkvKjcP1QKBgQD632J17fWqK5cBaU2c +2bxAwS8aoqzPgBkAD2E8/VBEmJfjUAH5KVNuF9oeO/ho6JUOHoAWxMeu9v0ikynb +wnznQXlgieJCockJaTx1fkE/+W38uRXLK1TBSHFB7QdhPJbdeOh0jbsxNoX3wCAW +jQDUf2CoVdt+326II71IhDnnbQKBgQDXAbpkEWMYnWbl+WmSwGGud2AO7Uaw6ZQK +e83/zKQYcLsGHVMEJ41i2Lrd+VGJjK1eHUyOxHYg4Cel4cG5P7sU45yhehHVAeau +Z8KzQbB8BGcyMUoQFMIK5AXIiVdgTvt+aoKMEfXSAuZi1g5ATSS6zBoXWxlJyQ4b +R1MqOvMB/wKBgAw/3A7mD5i/iCAJhECkYQzIYgRq7QU0vAPEvHq94611xfTTc0U3 +P1ugzoWrZ/W3ZY/K7XYvJZDlfnaxuNmCJZclG0gbc3DNdYOAH/OctpLpGvW8E9RX +yUumveD6MeINk1A9FxyZzwoYH3J5bxeqyt+VWKLfjlgjkMIU/KkNy8YBAoGAbU2G +mTqxmyDh38YE4sMEpbIwVkZP6r5EMXQxDHrXbUlZ+sjLnFATM44kqZYG2pt2w2K3 +udisiRgLb+wuFOQOUpdH2Ft7V0NpJ36+X2zksJd4cu7VzQkQgILdYc5YajCc7+5r +wZOb2ZD52IMjqZLOOlxqYzc/yt/4WOvQnqZrRbcCgYBQopNwh9Hx9SBIHkkZkq1Z +iiPZl05khB/Vw76hABwjMillQd+nOJNf4kymIiOzfThEw/a4kam1zWvN0kq9Guu/ +YMvd73sqcudB5IWIjdqq0lKML2rcoBGqKGj5dFZt6Un/jqbi5nHeoMubrZkXUdG8 +PDtV2BTZDwmo+btPF//U5Q== +-----END PRIVATE KEY----- diff --git a/.test/tests/java-ca-certificates-update/certs/README.md b/.test/tests/java-ca-certificates-update/certs/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8874ae8bc5dd90351a5755603b2912d606ce7323 --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs/README.md @@ -0,0 +1,9 @@ +These certificate/key pairs has been generated with + +``` shell +$ openssl req -nodes -new -x509 -days 358000 -subj "/DC=Temurin/CN=DockerBuilder" -keyout certs/.dockerbuilder.key -out certs/.dockerbuilder.crt +$ openssl req -nodes -new -x509 -days 358000 -subj "/DC=Temurin/CN=DockerBuilder2" -keyout certs/.dockerbuilder2.key -out certs/.dockerbuilder2.crt +$ cat certs/.dockerbuilder.crt certs/.dockerbuilder2.crt > certs/multi-cert.crt +``` + + and are only used for testing diff --git a/.test/tests/java-ca-certificates-update/certs/multi-cert.crt b/.test/tests/java-ca-certificates-update/certs/multi-cert.crt new file mode 100644 index 0000000000000000000000000000000000000000..66293f662230a98858e69b352742f9b73296509d --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs/multi-cert.crt @@ -0,0 +1,40 @@ +-----BEGIN CERTIFICATE----- +MIIDRTCCAi2gAwIBAgIUIfl8I/yasxlsTEc30PLLRuleiCswDQYJKoZIhvcNAQEL +BQAwMTEXMBUGCgmSJomT8ixkARkWB1RlbXVyaW4xFjAUBgNVBAMMDURvY2tlckJ1 +aWxkZXIwIBcNMjMwNjEyMTgyNDE1WhgPMzAwMzA4MTQxODI0MTVaMDExFzAVBgoJ +kiaJk/IsZAEZFgdUZW11cmluMRYwFAYDVQQDDA1Eb2NrZXJCdWlsZGVyMIIBIjAN +BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArfOgmluNXEIE7BWvt7jGgdZW/y5s +N78FcpZdM8Z2FatvjJKvNmJ9OkkkOSNBhGKAWpHn19JMNdQ2nEmTHMetg0hiSqRI +hBceAY4lDfOzxAyZGGpVzL9U1B9mOrX5O3EedF5AVvl0NZVjEwswuGaUa3zZBAKy +Z5Vv/z8Lw2uYIs/dtw8lcpEAb78BZ8bAhhhl+X+tTGK8agibLGQJT9l/JxS3pXyw +me4YaKQQRgvuqOTEt+x+0aA5E2EUTOGq0Li+i1ranf6ou5Dz/Y6LtXwT/j2bf4ZR +w2YHpYZL54UEtMWES2KAjsZ3u4DCxUIEfW8EgxUIhcepIDP1h05A3fSiWQIDAQAB +o1MwUTAdBgNVHQ4EFgQUr0VirSzDQTuNgGjDxRkxPFrjUKcwHwYDVR0jBBgwFoAU +r0VirSzDQTuNgGjDxRkxPFrjUKcwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0B +AQsFAAOCAQEAlo6ZSAIKSUWqRygyNg9oWuLGfWMW//dZjU1MKBYVpM4Mry/aMD5d +kMQj9hm+zXhNYN01yLh/cdPKCQ/r1KP6lmCtZHp50Xe8HEnIymRYx0KMAcqYLjnT +DXwCPqtWvJ1do65vVJRN70CuF8T1JNFhPdirrAiuU7bhGPABfnbek7yNkTYgUSdb +WpV/WOFPh9Dl24vNl1/Cti+pQThlCgHF/+dVndFHN9FOOG8k8ohYkLwL+ZzKfOiZ +CVWn2mWk2EhcuTlg/3zkXmwjfzFTdXMhS1sdfJNReaY/omJ91euxB0c8iYZV4wuU +ghx+GJ14nO7RJNHNX4k+BBPxy3f56+cYrg== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDRzCCAi+gAwIBAgIUZuRSLr7riMCDUFHVQKYQh/abmZQwDQYJKoZIhvcNAQEL +BQAwMjEXMBUGCgmSJomT8ixkARkWB1RlbXVyaW4xFzAVBgNVBAMMDkRvY2tlckJ1 +aWxkZXIyMCAXDTI0MDcyNDIxMDk0NloYDzMwMDQwOTI1MjEwOTQ2WjAyMRcwFQYK +CZImiZPyLGQBGRYHVGVtdXJpbjEXMBUGA1UEAwwORG9ja2VyQnVpbGRlcjIwggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDSs004yyVW4dEREZgTGbN1Dzbc ++VcRXUCfVCuiWFeT8a8oHZrbtNxCXD6whcGvLHsjszJKUCseDLCnSlHIpU6Ax7tP +WGsUhY6Zl8I+JzeB/8tYpyNRCLlm2Rp5Iv4oOX2btKYoUy+oFkWP+N8d1taRSrhR +vbPz+FwFSrtQwuT+grQP9yWO0qFrHL5Vjckg0BjELMYZ4rUx4KsV+JsmCf6oPDt4 +b+gnMoZebumKTJ53Ej/Kh0Z30s+UHR9WlbZ9KEyuBifgErw/USqpibaQbG1UTX1f +5LealeITduNWcXIAkQYHddCyt8YRtO9oVrxxVdFmCtU4qUHlov7kxAdOC/KTAgMB +AAGjUzBRMB0GA1UdDgQWBBQ1oKojBf5qgkezUk6axrz3CjdHmzAfBgNVHSMEGDAW +gBQ1oKojBf5qgkezUk6axrz3CjdHmzAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3 +DQEBCwUAA4IBAQCDUUOV23QzoqeGs7CKHXg+Mvxn6E4Tm395c0RKJRiHXEueQ2JD +e7ywfb11f/vGyudWVKe1wiRuMP4U8G6V3m6C/CSJrz1J3N9fvN23iPaZIh1O0vSr +xOz5UmiSsRW8BEQYCvF8CoWim1fG+KjtRhO6QqKLtK11j6TwZaUBIvSwK+OZKSuw +q8SuBRXNrIJvH0bonOXcuivOkruU0aRdizIG5Ed0OV2PVfbw2gu7Om83ADbVuSOV +noMwGjDVzVRAs8lu4ijuAryshVQK0LkImrwp+YkhRkFus0HWJqi/Ox+BHZt3BiFs +ATt9J3LCLazvP6LGr4rlZixJqM2ZC7dP0lOl +-----END CERTIFICATE----- diff --git a/.test/tests/java-ca-certificates-update/certs_duplicate_cn/cert1.crt b/.test/tests/java-ca-certificates-update/certs_duplicate_cn/cert1.crt new file mode 100644 index 0000000000000000000000000000000000000000..50e111da9d1adefa3dc3d21446116fb1c00e4436 --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs_duplicate_cn/cert1.crt @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICzDCCAbSgAwIBAgIBATANBgkqhkiG9w0BAQsFADAYMRYwFAYDVQQDDA1kb2Nr +ZXJidWlsZGVyMB4XDTI0MDgyNzA5MDIwMFoXDTI1MDgyNzA5MDIwMFowGDEWMBQG +A1UEAwwNZG9ja2VyYnVpbGRlcjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC +ggEBANIIAbZXdD1qOy/cdaLN0p7emnRUMgMhhL91F7/GA3LBCyURSBTNuaI2ibq+ +BxUjldsv8HOaesLG0Au4iaggnMK6YPHThDOqOw6ME4ghAD/10l6lHf+kTRvN4eC9 +bv3H1jieejVFIgienFfuFKcsNCFKPp4Rh7+D5HHJ3wtBVfaLT4K4q46Qlvkow7s8 +cQ3WSdvpsLDZo7cN1fRWMNHhDFbIs/DGkbhZUAxxUkUoUPyn+zvpRTY6QXoAQe57 +ed9qhhXQcpbHtHN8ecTenC2KEXQuGC0/KaqEJgTqE5W7Ihg0EvGeYpzdSt6ELSFx +WL3COwk/xTCcIqBPSiYmwPMKmd0CAwEAAaMhMB8wHQYDVR0OBBYEFCspyA0xL4b+ +2/cDj4tGqxI9L0/KMA0GCSqGSIb3DQEBCwUAA4IBAQC/UmqrbRfvmK5YX6uCBVA0 +SczwSuQRM7Zgi8PMCKLH4NvoeP6cYnAc46uaO3sp9iAv/LCw7Rw7A/LvZWmVCYPp +AstB6kI7nTDHULRGEk3aUar7B8uAVbMNF9V8iOnlk2G2qTvHMW9I4rGtQKqK6YXd +0m2XZ6UOEzNBPKDHqFfNOYpo1qts5CDLynGIX0tFTSlks5BMrV13xn/4giRj4UHY +bmElscCTfR/anNxGIBUp7dqGsv4zOeCE6kac4vsENyS+x+a8W0yveTY+TQnfKalT +KjZXCkPsZp2vZY6eCv2/09L94nXGMB40NDVOaDD/d2fZuQPadRTsF4AqEt9CsN5n +-----END CERTIFICATE----- diff --git a/.test/tests/java-ca-certificates-update/certs_duplicate_cn/cert2.crt b/.test/tests/java-ca-certificates-update/certs_duplicate_cn/cert2.crt new file mode 100644 index 0000000000000000000000000000000000000000..c4cb6c73ef50233804e6cb3e847124a201566937 --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs_duplicate_cn/cert2.crt @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICzDCCAbSgAwIBAgIBAjANBgkqhkiG9w0BAQsFADAYMRYwFAYDVQQDDA1kb2Nr +ZXJidWlsZGVyMB4XDTI0MDgyNzA5MDIwNFoXDTI1MDgyNzA5MDIwNFowGDEWMBQG +A1UEAwwNZG9ja2VyYnVpbGRlcjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC +ggEBANIIAbZXdD1qOy/cdaLN0p7emnRUMgMhhL91F7/GA3LBCyURSBTNuaI2ibq+ +BxUjldsv8HOaesLG0Au4iaggnMK6YPHThDOqOw6ME4ghAD/10l6lHf+kTRvN4eC9 +bv3H1jieejVFIgienFfuFKcsNCFKPp4Rh7+D5HHJ3wtBVfaLT4K4q46Qlvkow7s8 +cQ3WSdvpsLDZo7cN1fRWMNHhDFbIs/DGkbhZUAxxUkUoUPyn+zvpRTY6QXoAQe57 +ed9qhhXQcpbHtHN8ecTenC2KEXQuGC0/KaqEJgTqE5W7Ihg0EvGeYpzdSt6ELSFx +WL3COwk/xTCcIqBPSiYmwPMKmd0CAwEAAaMhMB8wHQYDVR0OBBYEFCspyA0xL4b+ +2/cDj4tGqxI9L0/KMA0GCSqGSIb3DQEBCwUAA4IBAQAbEOXj4VHl3BvmoLEw3ykk +5c4CZwTuKOm7gh6MJB6iPZIord/LyjLoMh/Mbhy5uNNKxyA53aeZzsc3q35Uks9K +Tm02Pz6LQ3gMBvXQ/FfFu1+RXHbDOD5I9enrEsXTx4PGylFv8/9LqBfGiFGxPy6a +C8s8d22AZsL1P6iwxNoQgfBSSqZhH/mKJyYqFwlqBmo/PQTVt2noWP6afBOfUs4W +AGaeJUexLAem487MlPuzaSAr397zhvCVt7GNAkMwzU2KxH9auJ/5NFy1YyDSgsa0 +9rcy1gZGzJdOR2AbOZ1FXXqsw91S5SAzb+qR54KIusJ4ON+bPaQc7ZtnNKvbnBxG +-----END CERTIFICATE----- diff --git a/.test/tests/java-ca-certificates-update/certs_no_cn/README.md b/.test/tests/java-ca-certificates-update/certs_no_cn/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7bae9d8afbe584e9f9e153604bc078f5cab5a8b6 --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs_no_cn/README.md @@ -0,0 +1,13 @@ +These certificates reproduce the scenario where multiple CA certificates have **no CN** and share a +non-unique serial number (`00`). The alias cannot be derived from CN+serial, so the import script falls +back to a SHA-256 fingerprint based alias (`adoptium_`). They have been generated with + +``` shell +$ openssl req -nodes -new -x509 -days 3650 -set_serial 0 -subj "/C=US/O=Acme No CN Authority/OU=Acme No CN Authority Root CA" -keyout /dev/null -out certs_no_cn/ca_a.crt +$ openssl req -nodes -new -x509 -days 3650 -set_serial 0 -subj "/C=US/O=Globex No CN Authority/OU=Globex No CN Authority Root CA" -keyout /dev/null -out certs_no_cn/ca_b.crt +$ openssl req -nodes -new -x509 -days 3650 -set_serial 0 -subj "/C=US/O=Initech No CN Authority/OU=Initech No CN Authority Root CA" -keyout /dev/null -out certs_no_cn/ca_c.crt +``` + +The private keys are discarded (`-keyout /dev/null`); only the certificates are needed for testing. +The fingerprint based aliases asserted by `CMD4` in `run.sh` are derived from these exact files, so +regenerating the certificates requires updating those alias values. diff --git a/.test/tests/java-ca-certificates-update/certs_no_cn/ca_a.crt b/.test/tests/java-ca-certificates-update/certs_no_cn/ca_a.crt new file mode 100644 index 0000000000000000000000000000000000000000..d6fd4339dcc1cd2216bd14352b818b7b2e32698a --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs_no_cn/ca_a.crt @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDdDCCAlygAwIBAgIBADANBgkqhkiG9w0BAQsFADBTMQswCQYDVQQGEwJVUzEd +MBsGA1UECgwUQWNtZSBObyBDTiBBdXRob3JpdHkxJTAjBgNVBAsMHEFjbWUgTm8g +Q04gQXV0aG9yaXR5IFJvb3QgQ0EwHhcNMjYwNjEzMDY0NzM0WhcNMzYwNjEwMDY0 +NzM0WjBTMQswCQYDVQQGEwJVUzEdMBsGA1UECgwUQWNtZSBObyBDTiBBdXRob3Jp +dHkxJTAjBgNVBAsMHEFjbWUgTm8gQ04gQXV0aG9yaXR5IFJvb3QgQ0EwggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDljZbIVjM4+a1gEw0m/2PB7pFjhx0G +LHrxZYdpJcOCMVNuLBejQdBbn43c/bsXM7PAVEBp6f1HUtpzC03JgjQ2jPfOrrWE +4vAzV/F6+2ToSTjlXpHpsCY2cZf2EF+rmX6TNM3DJ1lrJeOnU+RRtZjrK+Nf7CBA +jtEuCdKJi1HhvB7sSdMBjS81MPIaHtDSshMYj/LkgRHTaG7z18NUqswxixdNHBa1 +PMN2vZLtyvreKkaTrU5TS3jGpxoovBbrFRHWzXRswWu//kz/T2/EDHf4FR0cBxAo +ohaqBlacCtDX/hFtv8G1xn0LiFjBGt0S9tEfI4jxyL4L/Pl8QBppr4LxAgMBAAGj +UzBRMB0GA1UdDgQWBBR8oz0s9rWMswXudi3BJjhIMfovozAfBgNVHSMEGDAWgBR8 +oz0s9rWMswXudi3BJjhIMfovozAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB +CwUAA4IBAQAKKOryZSiIJskpYoT2wCgLR+PVjGmYeblkduHXt6LGaJ+2vZ6CBuWw +9TcIsfBTKbsooNvB4Bo/D+ipElee3cGB4EuFtcbsZRjYHXCBwTC7NWD8I3iRb5Ed +j+6cFCbYcf8dwq6x1B977rbFPFPw33n2wF4vzvxSp/a8Jnfs/SZoGlH1ygosOojM +P0L37eTcFqfK1+QSrGaNpNflmg9c4KdwznPOpOIUsWtNi17h8ysGJd38H8mTTT0h +hP/k4ImkkoCek6alLNQgzDyZZkk7KUAhtZulDr6RD2HPQE8Io9jx5shZPdvi8gG0 +OfZm+BuP0HihWYEmcM1NhH5bTWj7A1rQ +-----END CERTIFICATE----- diff --git a/.test/tests/java-ca-certificates-update/certs_no_cn/ca_b.crt b/.test/tests/java-ca-certificates-update/certs_no_cn/ca_b.crt new file mode 100644 index 0000000000000000000000000000000000000000..e643a99bdad1fdfdb3e09d014797721bc7ef6c13 --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs_no_cn/ca_b.crt @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDfDCCAmSgAwIBAgIBADANBgkqhkiG9w0BAQsFADBXMQswCQYDVQQGEwJVUzEf +MB0GA1UECgwWR2xvYmV4IE5vIENOIEF1dGhvcml0eTEnMCUGA1UECwweR2xvYmV4 +IE5vIENOIEF1dGhvcml0eSBSb290IENBMB4XDTI2MDYxMzA2NDczNFoXDTM2MDYx +MDA2NDczNFowVzELMAkGA1UEBhMCVVMxHzAdBgNVBAoMFkdsb2JleCBObyBDTiBB +dXRob3JpdHkxJzAlBgNVBAsMHkdsb2JleCBObyBDTiBBdXRob3JpdHkgUm9vdCBD +QTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALzW9CF0/KwvUHBXlnYp +f0Ay8HEWDnyAP6u9kZPL8TlFmDYK0o47HelcC2puXqxzFN1ovUnz5RQFGzHbY2kk +VCw2r1vYnQPpWxWyX/1Vf9ZsQ5nqoqIoFmOMFKimBnASxqwposcq3Bh4rpKoTKHe +nkT12j1PUOXJ6WZH/grSykUJbOODnIrjNeHznb1/nSB3Q+kJkAooRoeUsOch6Ou/ +WVQJ3p9Dfe5Ua5PosY9plUAemRUNgwvhlW19IErJp1pxYrARrX4ywOs7ALHrnG+j +Og2g7AJuvIyrD3bNiKUSzsHnahcr0Dmn2CQzNld/5Zq2kNFKdOr4Sz9OJAOij547 +KWECAwEAAaNTMFEwHQYDVR0OBBYEFBvG31fq4BLu3eeCriuoJaMalqPBMB8GA1Ud +IwQYMBaAFBvG31fq4BLu3eeCriuoJaMalqPBMA8GA1UdEwEB/wQFMAMBAf8wDQYJ +KoZIhvcNAQELBQADggEBAIWmNL61yrgc41L4/86Ir2Uv8o5sBcCddPE4O3gs69O6 +asZOjgd6rnuYe0KbCAlvvpR2K+ISSMewuWeROUnMddqvNj7LlCg4SE2zzH/ua3Kn +FRyRBlrFc4VrNcyXMY4lM3eCtzpjNjbMfoqPlChV6zVKJut6lvM03x6AL9gdQdNb +GA39eu0U9ijU7CSBaBmfoX6DSGDbkXgob2Rz+zoo/gP7XZbShfYoaEPHbcnmdbGx +yJecb4gkXpp5kmIUi64kQW/G/fC4W8TQanf2sbLzFpBExTsJGmRUPhd3w238hb1Y +dCrs3XcXspaBoc6JclonIwTHwp5n3I4HPBctXRs4LO8= +-----END CERTIFICATE----- diff --git a/.test/tests/java-ca-certificates-update/certs_no_cn/ca_c.crt b/.test/tests/java-ca-certificates-update/certs_no_cn/ca_c.crt new file mode 100644 index 0000000000000000000000000000000000000000..255c2bbb33f335286c61ef0a206583bcec1a1f93 --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs_no_cn/ca_c.crt @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDgDCCAmigAwIBAgIBADANBgkqhkiG9w0BAQsFADBZMQswCQYDVQQGEwJVUzEg +MB4GA1UECgwXSW5pdGVjaCBObyBDTiBBdXRob3JpdHkxKDAmBgNVBAsMH0luaXRl +Y2ggTm8gQ04gQXV0aG9yaXR5IFJvb3QgQ0EwHhcNMjYwNjEzMDY0OTM3WhcNMzYw +NjEwMDY0OTM3WjBZMQswCQYDVQQGEwJVUzEgMB4GA1UECgwXSW5pdGVjaCBObyBD +TiBBdXRob3JpdHkxKDAmBgNVBAsMH0luaXRlY2ggTm8gQ04gQXV0aG9yaXR5IFJv +b3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCYLDKqnuKPIDH1 +kIgiqmAHMHmRUqE2gik9XyTo72LTfqPVU8xz+QoTnXj8+WURH0UjqhBTBXQHHH48 +vi3n49Ofos5ZyJhYVd/kUSCjf1TWljt+9QLGKIIgwYMNURTV8iIK2cT9zP1wYj4k +3pT4M/zIqQW6ao/NrgjM0w31Ex0kpL/AlF/f9iKIzlbM0tyNUoaTw8wwBOu/tZOK +mozW6/aWaYhDUU85xeO53pt0uaX7Ba1pCCiOyFZGg8Jndq1H85YUgg69s7/5gXDJ +CibLY6OXtqyCC59spiq1NRtNkF0E/Sogrwgcl7diVp6R66UY8OXQifiMb014rBNI +isF9hYqrAgMBAAGjUzBRMB0GA1UdDgQWBBSQYgaxaZ0kOpSL9SovuGr2yzE7lzAf +BgNVHSMEGDAWgBSQYgaxaZ0kOpSL9SovuGr2yzE7lzAPBgNVHRMBAf8EBTADAQH/ +MA0GCSqGSIb3DQEBCwUAA4IBAQBscYQHEh+9unOgVcgCkY73qtOf7x/DL7O0mPUc +hjAsZfG/v+Y1UuxBNJMEpzC9JZwqveInBZB+RqYAoprK1h/JsnGYUGFlN+uO4jBI +wWJwXF36kmaIPJDmQIU5iOjOU8jEnE6I3i12XmJxpZPMG6/++HjECuRUDEUCkmlc +VcDwENmWoSpR4DKEdDM3BzevsZekyF7TnHxlPRlhx9qlYUQdFcZqSvY8RSSPFA2c +G/KpTEHJ47ZI88y9Oyw22UzkDXPswGLsyHsMDVGyGaVUo4MuNUb6ehU/pyPdL76a +zoXW8gA8j+1yJBHE8IBwdqjSuPYLZJKcAoWgC3dTLfZ5qinp +-----END CERTIFICATE----- diff --git a/.test/tests/java-ca-certificates-update/certs_same_cn_serial/README.md b/.test/tests/java-ca-certificates-update/certs_same_cn_serial/README.md new file mode 100644 index 0000000000000000000000000000000000000000..bb1048c729cf7dc10e48fa67a0233f24d0aaad9a --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs_same_cn_serial/README.md @@ -0,0 +1,14 @@ +These certificates reproduce the scenario where multiple CA certificates share **both the same CN and the +same serial number**. Neither the CN nor the CN+serial combination can disambiguate them, so the import +script appends the SHA-256 fingerprint to the alias (`_`). They have been generated with + +``` shell +$ openssl req -nodes -new -x509 -days 3650 -set_serial 4096 -subj "/DC=Temurin/CN=IdenticalCA" -keyout /dev/null -out certs_same_cn_serial/cert1.crt +$ openssl req -nodes -new -x509 -days 3650 -set_serial 4096 -subj "/DC=Temurin/CN=IdenticalCA" -keyout /dev/null -out certs_same_cn_serial/cert2.crt +$ openssl req -nodes -new -x509 -days 3650 -set_serial 4096 -subj "/DC=Temurin/CN=IdenticalCA" -keyout /dev/null -out certs_same_cn_serial/cert3.crt +``` + +Each command uses a fresh keypair, so the three certificates have identical subject and serial but distinct +fingerprints. The private keys are discarded (`-keyout /dev/null`); only the certificates are needed for +testing. The fingerprint based aliases asserted by `CMD5` in `run.sh` are derived from these exact files, so +regenerating the certificates requires updating those alias values. diff --git a/.test/tests/java-ca-certificates-update/certs_same_cn_serial/cert1.crt b/.test/tests/java-ca-certificates-update/certs_same_cn_serial/cert1.crt new file mode 100644 index 0000000000000000000000000000000000000000..d14db8f11ca09c8bec12c917ba1d0e27a92f4dbc --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs_same_cn_serial/cert1.crt @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDLTCCAhWgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwLzEXMBUGCgmSJomT8ixk +ARkWB1RlbXVyaW4xFDASBgNVBAMMC0lkZW50aWNhbENBMB4XDTI2MDYxMzA3MjEz +MVoXDTM2MDYxMDA3MjEzMVowLzEXMBUGCgmSJomT8ixkARkWB1RlbXVyaW4xFDAS +BgNVBAMMC0lkZW50aWNhbENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC +AQEAwxmIauD2o/kzfUCZr+ZxKzhLiAO0pIjd2/sJOuzIrUMvpqCd5WNUXpaHEJa0 +na9rvjHUWPzQ5if0qUp9ErZ7PPPeM1f1RwhpwhmDnBsUxo6mglQbBrSFOahf2yDk +IfP0mA04vryCXmZy+oMIe4G/CaNLlsGBE+qLHWrE5kZT6F0KxDhpLZXPI+iGGX3q +VAsllXEqReFZA2pjubyVY3ZvHmkaYFVFaqlys0mVK2U7a30h0x4y/hEWVShiMrFP +ihkRi+V1FwZ44XVigvaFML0zzQhK/UO3Y7g2k+EhEQyUpO8DmKDi6Yyhxa8X++gS +5WDziWzjOwLOcvHKk3gF9ilg1wIDAQABo1MwUTAdBgNVHQ4EFgQUSZh8QxQKpajq +hAZt1IYtFo7Ht18wHwYDVR0jBBgwFoAUSZh8QxQKpajqhAZt1IYtFo7Ht18wDwYD +VR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAZYdpVnVv9eZdgCu/5/8w ++y29mv8zh3cAL0cqiy/rL1BYwioi7mSQ+9qdO3+srxXb9bY88Ys34d3KZMoZMi2K +3ny+KcqdMHvi4YPcCF5JQtVTxaVvY+D+Ox7Vlxn/9gG7cWlb0JP/n2gXoP+xCeAs +jVieQVOF7R2ojBm4rgx27gaJNi9IWu/eAld/Z7FFfpoTYCdfv3Zu/ABhMfoTYYEk +qLe3xBw/lvWdKZqiveAIM0og4jBdiXbbVlY30gj+56durzRh/PaSM6neSPW21j1P +AT2W7O2qVCuSlOFqwVy4ziB92bEIUb10c/kSEtqxZ8oggYOsjVuAmegR2VzULj+T +3A== +-----END CERTIFICATE----- diff --git a/.test/tests/java-ca-certificates-update/certs_same_cn_serial/cert2.crt b/.test/tests/java-ca-certificates-update/certs_same_cn_serial/cert2.crt new file mode 100644 index 0000000000000000000000000000000000000000..6f36a143b7e1e9695b6270ee28291695c3f3ee58 --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs_same_cn_serial/cert2.crt @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDLTCCAhWgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwLzEXMBUGCgmSJomT8ixk +ARkWB1RlbXVyaW4xFDASBgNVBAMMC0lkZW50aWNhbENBMB4XDTI2MDYxMzA3MjEz +MVoXDTM2MDYxMDA3MjEzMVowLzEXMBUGCgmSJomT8ixkARkWB1RlbXVyaW4xFDAS +BgNVBAMMC0lkZW50aWNhbENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC +AQEAlrIki8aHo2EB5c8np+BxLVKMI2jhC6qpyVHkfc2UJTvrKZfBB95skdhiNj07 +8rFPPdbBMbMP31yvVVcQYBHp31hz9canjRWet2Octl6uUdALZIqfVHmXjPrBpisK +OEoAQZGkLFI/z0MeoiKT/O91jDiId25Z0BuWjo7iaJPOzad9lrqH7q993hRV0M96 +B49C/5Pj8Wt34SAO4uiATvFhZP9cwOWg27byZokMUecwVHQZS9JSVV9qSD2BCiFN +9JyIF1dt7mn4Km4O4I3qearfhJFXKSz1b6uKFesjt6sxV3B4zz23xfQFk5nwPo82 +H/BWQ/JHTqlKNqFhi4TYy2Ks9QIDAQABo1MwUTAdBgNVHQ4EFgQUiYJXCOWVMfmZ +j0xGbJZaeIOnZ+owHwYDVR0jBBgwFoAUiYJXCOWVMfmZj0xGbJZaeIOnZ+owDwYD +VR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEASI6EfbhACALsTRWb1/Wg +LkBknuFJGf9Iy/cIaWfxVI/16bkPrpZmfCYAhh9lHfhzUQfPuZuzSwYaWlHXBDxS +GKFrPyW3OM8KAiEo1XsO17EsbgD0rYCFRn603na/RZ9fshsU928Y0HY1y2zlNSeG +Kp4rZAXf7KnBHWULOaRZVCq5TsKCU/7gV0jo55odtqVwBNkBlPTIQEtgryZpRcQ4 +eknTtWk4JMw4G1Qfa5x/L1ltzjV5WuybHP2+NGcCvzpO3/hdvFt0a2UuTPurp15h +Ouv/NTuTylUsb8MldxWU5MfTeht9kEri2UQRvFhytIvpSa1kroris8Gn4rjBzwlX +oQ== +-----END CERTIFICATE----- diff --git a/.test/tests/java-ca-certificates-update/certs_same_cn_serial/cert3.crt b/.test/tests/java-ca-certificates-update/certs_same_cn_serial/cert3.crt new file mode 100644 index 0000000000000000000000000000000000000000..afcb146f4b2e8942075ee600ab3c8a8dfdfdad68 --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs_same_cn_serial/cert3.crt @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDLTCCAhWgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwLzEXMBUGCgmSJomT8ixk +ARkWB1RlbXVyaW4xFDASBgNVBAMMC0lkZW50aWNhbENBMB4XDTI2MDYxMzA3MjIy +MFoXDTM2MDYxMDA3MjIyMFowLzEXMBUGCgmSJomT8ixkARkWB1RlbXVyaW4xFDAS +BgNVBAMMC0lkZW50aWNhbENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC +AQEAjhaJ/Ucgq3pDR16jm5HWENKDkRRD8Mfxo1eZqXFQApQZjG+apl12X2ZQFJFo +vz8PrmDZmV7qXwJqgydKjly2DTm8Ubbd/PmGlCj9QkLNkKBIAe+ZJ/9VU93zaBOO +5uVryF4eKCl6MVqidV0te70Cj6vxgTw32dBcjt5jvvOkY5hZFskBGfDXqI5tM1VY +2F1GgyvTSW8kDftTbp/zGEAjOqvg4djQyDW5Y3RIeSHCQJQopo2IwrCpoGs064kt +d6MBoTDITqdwxErzM4KSVBOL3CBLwqKt8dwKySJnXS1qWv7s8lvmIBYiFqXbY+2L +9o/b7kppO9kvhPhS9pMv+M2H+QIDAQABo1MwUTAdBgNVHQ4EFgQUQvpg5ptg/OlA +SDqQh9eGo5rMT6YwHwYDVR0jBBgwFoAUQvpg5ptg/OlASDqQh9eGo5rMT6YwDwYD +VR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAFmcHwFu1xaxZ2OCvMkpT +zwy2/RDNvODyjymGR2XFFsTkkAmQscvQVLGE/570Gk+G2AorFrqRTEQm3jDRXamC +Kc8/KYVPIA7IMczGWKg0AWm+1yVGGYFHFer8LuTJoZmeCLpS/GatshVPbDxuim8f +6uwpZ3S+chGEtOD/uyNRO7CdX5trBsQoFt8qcW9ZXRDgEMEdVnIRf8kS0MAdX1nj +vYdK5GQv1cL93fUyiCceu7EO189IbY7oy6zQ1eVal+BRU00kMltd3kviZ4DaeLFW +69t9+BSgrlKohSNI6JMpm6gOGBHZ04NEFKbXNYDdpVByBtkKTjVU+80whfwWZDd8 +Og== +-----END CERTIFICATE----- diff --git a/.test/tests/java-ca-certificates-update/certs_symlink/.dockerbuilder.crt b/.test/tests/java-ca-certificates-update/certs_symlink/.dockerbuilder.crt new file mode 100644 index 0000000000000000000000000000000000000000..73838f46daab4b99987ba1326ab455a0a819cf55 --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs_symlink/.dockerbuilder.crt @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDRTCCAi2gAwIBAgIUIfl8I/yasxlsTEc30PLLRuleiCswDQYJKoZIhvcNAQEL +BQAwMTEXMBUGCgmSJomT8ixkARkWB1RlbXVyaW4xFjAUBgNVBAMMDURvY2tlckJ1 +aWxkZXIwIBcNMjMwNjEyMTgyNDE1WhgPMzAwMzA4MTQxODI0MTVaMDExFzAVBgoJ +kiaJk/IsZAEZFgdUZW11cmluMRYwFAYDVQQDDA1Eb2NrZXJCdWlsZGVyMIIBIjAN +BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArfOgmluNXEIE7BWvt7jGgdZW/y5s +N78FcpZdM8Z2FatvjJKvNmJ9OkkkOSNBhGKAWpHn19JMNdQ2nEmTHMetg0hiSqRI +hBceAY4lDfOzxAyZGGpVzL9U1B9mOrX5O3EedF5AVvl0NZVjEwswuGaUa3zZBAKy +Z5Vv/z8Lw2uYIs/dtw8lcpEAb78BZ8bAhhhl+X+tTGK8agibLGQJT9l/JxS3pXyw +me4YaKQQRgvuqOTEt+x+0aA5E2EUTOGq0Li+i1ranf6ou5Dz/Y6LtXwT/j2bf4ZR +w2YHpYZL54UEtMWES2KAjsZ3u4DCxUIEfW8EgxUIhcepIDP1h05A3fSiWQIDAQAB +o1MwUTAdBgNVHQ4EFgQUr0VirSzDQTuNgGjDxRkxPFrjUKcwHwYDVR0jBBgwFoAU +r0VirSzDQTuNgGjDxRkxPFrjUKcwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0B +AQsFAAOCAQEAlo6ZSAIKSUWqRygyNg9oWuLGfWMW//dZjU1MKBYVpM4Mry/aMD5d +kMQj9hm+zXhNYN01yLh/cdPKCQ/r1KP6lmCtZHp50Xe8HEnIymRYx0KMAcqYLjnT +DXwCPqtWvJ1do65vVJRN70CuF8T1JNFhPdirrAiuU7bhGPABfnbek7yNkTYgUSdb +WpV/WOFPh9Dl24vNl1/Cti+pQThlCgHF/+dVndFHN9FOOG8k8ohYkLwL+ZzKfOiZ +CVWn2mWk2EhcuTlg/3zkXmwjfzFTdXMhS1sdfJNReaY/omJ91euxB0c8iYZV4wuU +ghx+GJ14nO7RJNHNX4k+BBPxy3f56+cYrg== +-----END CERTIFICATE----- diff --git a/.test/tests/java-ca-certificates-update/certs_symlink/.dockerbuilder.key b/.test/tests/java-ca-certificates-update/certs_symlink/.dockerbuilder.key new file mode 100644 index 0000000000000000000000000000000000000000..4226cb968f6d50b7cdce112ea7256806c7e4a026 --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs_symlink/.dockerbuilder.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCt86CaW41cQgTs +Fa+3uMaB1lb/Lmw3vwVyll0zxnYVq2+Mkq82Yn06SSQ5I0GEYoBakefX0kw11Dac +SZMcx62DSGJKpEiEFx4BjiUN87PEDJkYalXMv1TUH2Y6tfk7cR50XkBW+XQ1lWMT +CzC4ZpRrfNkEArJnlW//PwvDa5giz923DyVykQBvvwFnxsCGGGX5f61MYrxqCJss +ZAlP2X8nFLelfLCZ7hhopBBGC+6o5MS37H7RoDkTYRRM4arQuL6LWtqd/qi7kPP9 +jou1fBP+PZt/hlHDZgelhkvnhQS0xYRLYoCOxne7gMLFQgR9bwSDFQiFx6kgM/WH +TkDd9KJZAgMBAAECggEAAi4knsKpKn/xAATZO2LaFBcGZ0ji64Od/cduMB+w67PG +yxAsmNsnqX3GBzROq3+GOdG3LPCSastNNZduJq/HAuH69Ly15E1GNOvzQXHtmHZg +SzAhVqwK6WS3sI0xgZdOSSmZl1glkXqyRPMV333OUZbn68GykD331c8UZpTi5tlx +qdOSEWwXQyVXh2mTT8uWWvqJm8OVaSUEo0KPNhsfWliINAXaDvlFle18wb0sQvAK +d/49VMmEoQMocHcXas5jVHZZzxwQ8gV+cA1nFOzOEOYX1IyHjJdfEUWT7Pa3LEjg +rPjEe/KiA3X9mVmofRG0Gvl8YjMiUEOBF/p9hgUxfQKBgQDY3oBUpkwhy3lRw2nu +PublbozVZi12hrEPIlqLSIda6i0hbCA2E5VBykuP7z0VnQOiHQWQPJ77BYEzR6xw +Z/PoJJL8knxtqVg9FsQlcsseDNW2THp53vf/Fiy4t+GoJZ7yezVyYI7RzngDPnCw +buiYUsd9+uKo8+Gs0fnZGSuRvQKBgQDNVrS2/A8NKRv/3cddNqEN4m16pVmAJg8G +Ww7t40W9c/lPW2SBH7wpEUW37N3b8lv1A8L24nJSbqiMjIkFxWroeOeFFEzKWp9r +BlFUu0kn5oAOI1NJOEOmjR9+SslDXetKDJpon60GYWJ8ke5jfaYUTEWIxUXRYOsX +mg8+L2iGzQKBgQCrzWiAptU9GIJdoZ8znCUysKdlDvMJKJ7vzFlKagTAoy9pgMzr +ygu9+NJvjikoDCEqti8IGt4fIjc+NpOG4PM6fm7rI+jqvvMmQfjVaeE7RxOuvVtx +XI++RwTauOFNYbBPjAfFOnUqBJTSjQ6c1t/we/OJ+8y/56RqUlXKBMSdSQKBgQDD +Wz2dZduwCq9/0/FL5qB9hDHiYJPxDsR2qIVgoDyGjWLhNDM/ggDTFYK+BNXi3wbL +6aNAnZpkgLFM3puyaOtYd0bVXsXcMzG+cglI0tI76tlkGgmv/J6oQ1V2IxKuTBmB +ntH8vgWwr1Ay8efasf0jDJmPERhmpo2kK8daw2Hv9QKBgAaxusMUdCSBu5YwI6u4 +6d0nN6WdY2aVcgQXbhJEpsaxT9KqN+LP5wZNf08hyUiO4zSrfVOapOS+10Ng1EYi +YQi8SjQd5deIc/jKKT5k9lCRcfhDq7YQo5pZbUgzDDuxod0WduvBnrf4zAl+K32V +1HI3wrgh88qBEGASVY8y6rDH +-----END PRIVATE KEY----- diff --git a/.test/tests/java-ca-certificates-update/certs_symlink/.dockerbuilder2.crt b/.test/tests/java-ca-certificates-update/certs_symlink/.dockerbuilder2.crt new file mode 100644 index 0000000000000000000000000000000000000000..45861b02a758ad6d438f5ce2815e908eae5563c9 --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs_symlink/.dockerbuilder2.crt @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDRzCCAi+gAwIBAgIUZuRSLr7riMCDUFHVQKYQh/abmZQwDQYJKoZIhvcNAQEL +BQAwMjEXMBUGCgmSJomT8ixkARkWB1RlbXVyaW4xFzAVBgNVBAMMDkRvY2tlckJ1 +aWxkZXIyMCAXDTI0MDcyNDIxMDk0NloYDzMwMDQwOTI1MjEwOTQ2WjAyMRcwFQYK +CZImiZPyLGQBGRYHVGVtdXJpbjEXMBUGA1UEAwwORG9ja2VyQnVpbGRlcjIwggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDSs004yyVW4dEREZgTGbN1Dzbc ++VcRXUCfVCuiWFeT8a8oHZrbtNxCXD6whcGvLHsjszJKUCseDLCnSlHIpU6Ax7tP +WGsUhY6Zl8I+JzeB/8tYpyNRCLlm2Rp5Iv4oOX2btKYoUy+oFkWP+N8d1taRSrhR +vbPz+FwFSrtQwuT+grQP9yWO0qFrHL5Vjckg0BjELMYZ4rUx4KsV+JsmCf6oPDt4 +b+gnMoZebumKTJ53Ej/Kh0Z30s+UHR9WlbZ9KEyuBifgErw/USqpibaQbG1UTX1f +5LealeITduNWcXIAkQYHddCyt8YRtO9oVrxxVdFmCtU4qUHlov7kxAdOC/KTAgMB +AAGjUzBRMB0GA1UdDgQWBBQ1oKojBf5qgkezUk6axrz3CjdHmzAfBgNVHSMEGDAW +gBQ1oKojBf5qgkezUk6axrz3CjdHmzAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3 +DQEBCwUAA4IBAQCDUUOV23QzoqeGs7CKHXg+Mvxn6E4Tm395c0RKJRiHXEueQ2JD +e7ywfb11f/vGyudWVKe1wiRuMP4U8G6V3m6C/CSJrz1J3N9fvN23iPaZIh1O0vSr +xOz5UmiSsRW8BEQYCvF8CoWim1fG+KjtRhO6QqKLtK11j6TwZaUBIvSwK+OZKSuw +q8SuBRXNrIJvH0bonOXcuivOkruU0aRdizIG5Ed0OV2PVfbw2gu7Om83ADbVuSOV +noMwGjDVzVRAs8lu4ijuAryshVQK0LkImrwp+YkhRkFus0HWJqi/Ox+BHZt3BiFs +ATt9J3LCLazvP6LGr4rlZixJqM2ZC7dP0lOl +-----END CERTIFICATE----- diff --git a/.test/tests/java-ca-certificates-update/certs_symlink/.dockerbuilder2.key b/.test/tests/java-ca-certificates-update/certs_symlink/.dockerbuilder2.key new file mode 100644 index 0000000000000000000000000000000000000000..b4fce7f803646983af22b020a0825e06e2ba17bd --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs_symlink/.dockerbuilder2.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDSs004yyVW4dER +EZgTGbN1Dzbc+VcRXUCfVCuiWFeT8a8oHZrbtNxCXD6whcGvLHsjszJKUCseDLCn +SlHIpU6Ax7tPWGsUhY6Zl8I+JzeB/8tYpyNRCLlm2Rp5Iv4oOX2btKYoUy+oFkWP ++N8d1taRSrhRvbPz+FwFSrtQwuT+grQP9yWO0qFrHL5Vjckg0BjELMYZ4rUx4KsV ++JsmCf6oPDt4b+gnMoZebumKTJ53Ej/Kh0Z30s+UHR9WlbZ9KEyuBifgErw/USqp +ibaQbG1UTX1f5LealeITduNWcXIAkQYHddCyt8YRtO9oVrxxVdFmCtU4qUHlov7k +xAdOC/KTAgMBAAECggEAANIrB8nVtFbjVrmdnEqVs8drnITzVmYN+gxhaSTiQwuq +9dWyjY6+omPYVma94GKADlR7oXd+7cyLks65rrXRCdi0PaKw6vox9WdkMCY803zr +BWrouq0Hq1W0y3x3WOjrSyjOiTgdwhBDlLH1Vk/tV/VwybOa4dMeRKveFkNmbXKU +ZeR62r95vob4F5Ui6CWqSDRXFSml8VvBkU+6RAm697Lm5JQKoOuUueR9/L5z2Y0Z +rpGeBQ2tbbRIAvQWG3PhQirDqduL2e8aUs/RG8jGmbAnB9LoWJtaBEgLoza6221F +vboRWDLG5yZorXeGHT169+LQQ84rtwyjbQkvKjcP1QKBgQD632J17fWqK5cBaU2c +2bxAwS8aoqzPgBkAD2E8/VBEmJfjUAH5KVNuF9oeO/ho6JUOHoAWxMeu9v0ikynb +wnznQXlgieJCockJaTx1fkE/+W38uRXLK1TBSHFB7QdhPJbdeOh0jbsxNoX3wCAW +jQDUf2CoVdt+326II71IhDnnbQKBgQDXAbpkEWMYnWbl+WmSwGGud2AO7Uaw6ZQK +e83/zKQYcLsGHVMEJ41i2Lrd+VGJjK1eHUyOxHYg4Cel4cG5P7sU45yhehHVAeau +Z8KzQbB8BGcyMUoQFMIK5AXIiVdgTvt+aoKMEfXSAuZi1g5ATSS6zBoXWxlJyQ4b +R1MqOvMB/wKBgAw/3A7mD5i/iCAJhECkYQzIYgRq7QU0vAPEvHq94611xfTTc0U3 +P1ugzoWrZ/W3ZY/K7XYvJZDlfnaxuNmCJZclG0gbc3DNdYOAH/OctpLpGvW8E9RX +yUumveD6MeINk1A9FxyZzwoYH3J5bxeqyt+VWKLfjlgjkMIU/KkNy8YBAoGAbU2G +mTqxmyDh38YE4sMEpbIwVkZP6r5EMXQxDHrXbUlZ+sjLnFATM44kqZYG2pt2w2K3 +udisiRgLb+wuFOQOUpdH2Ft7V0NpJ36+X2zksJd4cu7VzQkQgILdYc5YajCc7+5r +wZOb2ZD52IMjqZLOOlxqYzc/yt/4WOvQnqZrRbcCgYBQopNwh9Hx9SBIHkkZkq1Z +iiPZl05khB/Vw76hABwjMillQd+nOJNf4kymIiOzfThEw/a4kam1zWvN0kq9Guu/ +YMvd73sqcudB5IWIjdqq0lKML2rcoBGqKGj5dFZt6Un/jqbi5nHeoMubrZkXUdG8 +PDtV2BTZDwmo+btPF//U5Q== +-----END PRIVATE KEY----- diff --git a/.test/tests/java-ca-certificates-update/certs_symlink/.multi-cert.crt b/.test/tests/java-ca-certificates-update/certs_symlink/.multi-cert.crt new file mode 100644 index 0000000000000000000000000000000000000000..66293f662230a98858e69b352742f9b73296509d --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs_symlink/.multi-cert.crt @@ -0,0 +1,40 @@ +-----BEGIN CERTIFICATE----- +MIIDRTCCAi2gAwIBAgIUIfl8I/yasxlsTEc30PLLRuleiCswDQYJKoZIhvcNAQEL +BQAwMTEXMBUGCgmSJomT8ixkARkWB1RlbXVyaW4xFjAUBgNVBAMMDURvY2tlckJ1 +aWxkZXIwIBcNMjMwNjEyMTgyNDE1WhgPMzAwMzA4MTQxODI0MTVaMDExFzAVBgoJ +kiaJk/IsZAEZFgdUZW11cmluMRYwFAYDVQQDDA1Eb2NrZXJCdWlsZGVyMIIBIjAN +BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArfOgmluNXEIE7BWvt7jGgdZW/y5s +N78FcpZdM8Z2FatvjJKvNmJ9OkkkOSNBhGKAWpHn19JMNdQ2nEmTHMetg0hiSqRI +hBceAY4lDfOzxAyZGGpVzL9U1B9mOrX5O3EedF5AVvl0NZVjEwswuGaUa3zZBAKy +Z5Vv/z8Lw2uYIs/dtw8lcpEAb78BZ8bAhhhl+X+tTGK8agibLGQJT9l/JxS3pXyw +me4YaKQQRgvuqOTEt+x+0aA5E2EUTOGq0Li+i1ranf6ou5Dz/Y6LtXwT/j2bf4ZR +w2YHpYZL54UEtMWES2KAjsZ3u4DCxUIEfW8EgxUIhcepIDP1h05A3fSiWQIDAQAB +o1MwUTAdBgNVHQ4EFgQUr0VirSzDQTuNgGjDxRkxPFrjUKcwHwYDVR0jBBgwFoAU +r0VirSzDQTuNgGjDxRkxPFrjUKcwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0B +AQsFAAOCAQEAlo6ZSAIKSUWqRygyNg9oWuLGfWMW//dZjU1MKBYVpM4Mry/aMD5d +kMQj9hm+zXhNYN01yLh/cdPKCQ/r1KP6lmCtZHp50Xe8HEnIymRYx0KMAcqYLjnT +DXwCPqtWvJ1do65vVJRN70CuF8T1JNFhPdirrAiuU7bhGPABfnbek7yNkTYgUSdb +WpV/WOFPh9Dl24vNl1/Cti+pQThlCgHF/+dVndFHN9FOOG8k8ohYkLwL+ZzKfOiZ +CVWn2mWk2EhcuTlg/3zkXmwjfzFTdXMhS1sdfJNReaY/omJ91euxB0c8iYZV4wuU +ghx+GJ14nO7RJNHNX4k+BBPxy3f56+cYrg== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDRzCCAi+gAwIBAgIUZuRSLr7riMCDUFHVQKYQh/abmZQwDQYJKoZIhvcNAQEL +BQAwMjEXMBUGCgmSJomT8ixkARkWB1RlbXVyaW4xFzAVBgNVBAMMDkRvY2tlckJ1 +aWxkZXIyMCAXDTI0MDcyNDIxMDk0NloYDzMwMDQwOTI1MjEwOTQ2WjAyMRcwFQYK +CZImiZPyLGQBGRYHVGVtdXJpbjEXMBUGA1UEAwwORG9ja2VyQnVpbGRlcjIwggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDSs004yyVW4dEREZgTGbN1Dzbc ++VcRXUCfVCuiWFeT8a8oHZrbtNxCXD6whcGvLHsjszJKUCseDLCnSlHIpU6Ax7tP +WGsUhY6Zl8I+JzeB/8tYpyNRCLlm2Rp5Iv4oOX2btKYoUy+oFkWP+N8d1taRSrhR +vbPz+FwFSrtQwuT+grQP9yWO0qFrHL5Vjckg0BjELMYZ4rUx4KsV+JsmCf6oPDt4 +b+gnMoZebumKTJ53Ej/Kh0Z30s+UHR9WlbZ9KEyuBifgErw/USqpibaQbG1UTX1f +5LealeITduNWcXIAkQYHddCyt8YRtO9oVrxxVdFmCtU4qUHlov7kxAdOC/KTAgMB +AAGjUzBRMB0GA1UdDgQWBBQ1oKojBf5qgkezUk6axrz3CjdHmzAfBgNVHSMEGDAW +gBQ1oKojBf5qgkezUk6axrz3CjdHmzAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3 +DQEBCwUAA4IBAQCDUUOV23QzoqeGs7CKHXg+Mvxn6E4Tm395c0RKJRiHXEueQ2JD +e7ywfb11f/vGyudWVKe1wiRuMP4U8G6V3m6C/CSJrz1J3N9fvN23iPaZIh1O0vSr +xOz5UmiSsRW8BEQYCvF8CoWim1fG+KjtRhO6QqKLtK11j6TwZaUBIvSwK+OZKSuw +q8SuBRXNrIJvH0bonOXcuivOkruU0aRdizIG5Ed0OV2PVfbw2gu7Om83ADbVuSOV +noMwGjDVzVRAs8lu4ijuAryshVQK0LkImrwp+YkhRkFus0HWJqi/Ox+BHZt3BiFs +ATt9J3LCLazvP6LGr4rlZixJqM2ZC7dP0lOl +-----END CERTIFICATE----- diff --git a/.test/tests/java-ca-certificates-update/certs_symlink/README.md b/.test/tests/java-ca-certificates-update/certs_symlink/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8874ae8bc5dd90351a5755603b2912d606ce7323 --- /dev/null +++ b/.test/tests/java-ca-certificates-update/certs_symlink/README.md @@ -0,0 +1,9 @@ +These certificate/key pairs has been generated with + +``` shell +$ openssl req -nodes -new -x509 -days 358000 -subj "/DC=Temurin/CN=DockerBuilder" -keyout certs/.dockerbuilder.key -out certs/.dockerbuilder.crt +$ openssl req -nodes -new -x509 -days 358000 -subj "/DC=Temurin/CN=DockerBuilder2" -keyout certs/.dockerbuilder2.key -out certs/.dockerbuilder2.crt +$ cat certs/.dockerbuilder.crt certs/.dockerbuilder2.crt > certs/multi-cert.crt +``` + + and are only used for testing diff --git a/.test/tests/java-ca-certificates-update/custom-entrypoint.sh b/.test/tests/java-ca-certificates-update/custom-entrypoint.sh new file mode 100755 index 0000000000000000000000000000000000000000..9d6897754e1fcb31f3e140773aa18c2a94451652 --- /dev/null +++ b/.test/tests/java-ca-certificates-update/custom-entrypoint.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +exec "$@" diff --git a/.test/tests/java-ca-certificates-update/expected-std-out.txt b/.test/tests/java-ca-certificates-update/expected-std-out.txt new file mode 100644 index 0000000000000000000000000000000000000000..570d69f322c8f34619b1d86261478cd9b968903a --- /dev/null +++ b/.test/tests/java-ca-certificates-update/expected-std-out.txt @@ -0,0 +1 @@ +010101000001000000010101000001000000 diff --git a/.test/tests/java-ca-certificates-update/run.sh b/.test/tests/java-ca-certificates-update/run.sh new file mode 100755 index 0000000000000000000000000000000000000000..21f131c27f8681c162142e5d82eb49e417f1334b --- /dev/null +++ b/.test/tests/java-ca-certificates-update/run.sh @@ -0,0 +1,186 @@ +#!/bin/bash + +set -o pipefail + +testDir="$(readlink -f "$(dirname "$BASH_SOURCE")")" +runDir="$(dirname "$(readlink -f "$BASH_SOURCE")")" + +# CMD1 in each run is just a `date` to make sure nothing is broken with or without the entrypoint +CMD1=date + +# CMD2 in each run is to check for the `dockerbuilder` certificate in the Java keystore. Entrypoint exports $JRE_CACERTS_PATH to +# point to the Java keystore. +CMD2=(sh -c "keytool -list -keystore \"\$JRE_CACERTS_PATH\" -storepass changeit -alias dockerbuilder && keytool -list -keystore \"\$JRE_CACERTS_PATH\" -storepass changeit -alias dockerbuilder2") + +# CMD3 is looking for certificates with same CN, script appends the SHA-256 fingerprint to avoid alias conflict. +# certs_duplicate_cn/cert1.crt will be imported first with alias dockerbuilder +# certs_duplicate_cn/cert2.crt will be imported later with alias dockerbuilder_ +ALIAS_DUP_CN="dockerbuilder_127f5ee7608fc59ee4c9ae4ae59f7a1fff101eb33ac9509a64907067ad9ba6f5" +CMD3=(sh -c "keytool -list -keystore \"\$JRE_CACERTS_PATH\" -storepass changeit -alias dockerbuilder && keytool -list -keystore \"\$JRE_CACERTS_PATH\" -storepass changeit -alias $ALIAS_DUP_CN") + +# CMD4 covers certificates that have no CN and share a non-unique serial number (00). These cannot be +# disambiguated by CN+serial, so the script derives a unique alias from the SHA-256 fingerprint: +# adoptium_. All three certs in certs_no_cn (ca_a/ca_b/ca_c) must import under their distinct +# fingerprint aliases. +ALIAS_NO_CN_A="adoptium_27b513b1e7f0f61a23c2b4e3135bf606b7b81339a126bfebd86a306e69406eef" +ALIAS_NO_CN_B="adoptium_f4a91cab0ad6e7fe0c41d4827b44a89b21234425b0f973d9cbb63bfa09688b92" +ALIAS_NO_CN_C="adoptium_3418bd65082762a1a37ab63b19dbe5b17db17472900eaa192a72499cadfd845e" +CMD4=(sh -c "keytool -list -keystore \"\$JRE_CACERTS_PATH\" -storepass changeit -alias $ALIAS_NO_CN_A && keytool -list -keystore \"\$JRE_CACERTS_PATH\" -storepass changeit -alias $ALIAS_NO_CN_B && keytool -list -keystore \"\$JRE_CACERTS_PATH\" -storepass changeit -alias $ALIAS_NO_CN_C") + +# CMD5 covers certificates that share BOTH the same CN (IdenticalCA) and the same serial number. Neither CN +# nor CN+serial can disambiguate them, so the script appends the SHA-256 fingerprint. The first cert imports +# as the bare CN, the others as CN_. All three certs in certs_same_cn_serial must be present. +ALIAS_SAME_A="IdenticalCA" +ALIAS_SAME_B="IdenticalCA_528d3da80a18ace9cd569595363d592d7a13b67f582149434c88a6c77e43c457" +ALIAS_SAME_C="IdenticalCA_01d2a1ff022af410deb620d298f11b3eae13e114519d84ca46513fa5a1837f0d" +CMD5=(sh -c "keytool -list -keystore \"\$JRE_CACERTS_PATH\" -storepass changeit -alias $ALIAS_SAME_A && keytool -list -keystore \"\$JRE_CACERTS_PATH\" -storepass changeit -alias $ALIAS_SAME_B && keytool -list -keystore \"\$JRE_CACERTS_PATH\" -storepass changeit -alias $ALIAS_SAME_C") + +# For a custom entrypoint test, we need to create a new image. This image will get cleaned up at the end of the script +# by the `finish` trap function. +TESTIMAGE=$1.test + +function finish { + docker rmi "$TESTIMAGE" >&/dev/null +} +trap finish EXIT HUP INT TERM + +# But first, we need to create an image with an overridden entrypoint +docker build -t "$1.test" "$runDir" -f - <&/dev/null +FROM $1 +COPY custom-entrypoint.sh / +ENTRYPOINT ["/custom-entrypoint.sh"] +EOF + +# NB: In this script, we need to use `docker run` explicitly, since the normally used `run-in-container.sh` overwrites +# the entrypoint. + +# +# PHASE 1: Root containers +# + +# Test run 1: No added certificates and environment variable is not set. We expect CMD1 to succeed and CMD2 to fail. +docker run --rm "$1" $CMD1 >&/dev/null +echo -n $? +docker run --rm "$1" "${CMD2[@]}" >&/dev/null +echo -n $? + +# Test run 2: No added certificates, but the environment variable is set. Since there are no certificates, we still +# expect CMD1 to succeed and CMD2 to fail. +docker run --rm -e USE_SYSTEM_CA_CERTS=1 "$1" $CMD1 >&/dev/null +echo -n $? +docker run --rm -e USE_SYSTEM_CA_CERTS=1 "$1" "${CMD2[@]}" >&/dev/null +echo -n $? + +# Test run 3: Certificates are mounted, but the environment variable is not set, i.e. certificate importing should not +# be activated. We expect CMD1 to succeed and CMD2 to fail. +docker run --rm --volume=$testDir/certs:/certificates "$1" $CMD1 >&/dev/null +echo -n $? +docker run --rm --volume=$testDir/certs:/certificates "$1" "${CMD2[@]}" >&/dev/null +echo -n $? + +# Test run 4: Certificates are mounted and the environment variable is set. We expect both CMD1 and CMD2 to succeed. +docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs:/certificates "$1" $CMD1 >&/dev/null +echo -n $? +docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs:/certificates "$1" "${CMD2[@]}" >&/dev/null +echo -n $? + +# Test run 5: Certificates are mounted and are symlinks (e.g. in Kubernetes as `Secret`s or `ConfigMap`s) and the +# environment variable is set. We expect both CMD1 and CMD2 to succeed. +docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_symlink:/certificates "$1" $CMD1 >&/dev/null +echo -n $? +docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_symlink:/certificates "$1" "${CMD2[@]}" >&/dev/null +echo -n $? + +# Test run 6: Certificates are mounted and the environment variable is set, but the entrypoint is overridden. We expect +# CMD1 to succeed and CMD2 to fail. +docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs:/certificates "$TESTIMAGE" $CMD1 >&/dev/null +echo -n $? +docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs:/certificates "$TESTIMAGE" "${CMD2[@]}" >&/dev/null +echo -n $? + +# Test run 7: Two certificates with the same CN are mounted and the environment variable is set. +# We expect both CMD1 to succeed and CMD3 to find both certificates. +docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_duplicate_cn:/certificates "$1" $CMD1 >&/dev/null +echo -n $? +docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_duplicate_cn:/certificates "$1" "${CMD3[@]}" >&/dev/null +echo -n $? + +# Test run 8: Two certificates with no CN and the same serial number (00) are mounted and the environment +# variable is set. We expect CMD1 to succeed and CMD4 to find both fingerprint-based aliases. +docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_no_cn:/certificates "$1" $CMD1 >&/dev/null +echo -n $? +docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_no_cn:/certificates "$1" "${CMD4[@]}" >&/dev/null +echo -n $? + +# Test run 9: Three certificates with identical CN and identical serial number are mounted and the +# environment variable is set. We expect CMD1 to succeed and CMD5 to find all three fingerprint-based aliases. +docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_same_cn_serial:/certificates "$1" $CMD1 >&/dev/null +echo -n $? +docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_same_cn_serial:/certificates "$1" "${CMD5[@]}" >&/dev/null +echo -n $? + +# +# PHASE 2: Non-root containers +# + +# Test run 1: No added certificates and environment variable is not set. We expect CMD1 to succeed and CMD2 to fail. +docker run --read-only --user 1000:1000 --rm "$1" $CMD1 >&/dev/null +echo -n $? +docker run --read-only --user 1000:1000 --rm "$1" "${CMD2[@]}" >&/dev/null +echo -n $? + +# Test run 2: No added certificates, but the environment variable is set. Since there are no certificates, we still +# expect CMD1 to succeed and CMD2 to fail. +docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 "$1" $CMD1 >&/dev/null +echo -n $? +docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 "$1" "${CMD2[@]}" >&/dev/null +echo -n $? + +# Test run 3: Certificates are mounted, but the environment variable is not set, i.e. certificate importing should not +# be activated. We expect CMD1 to succeed and CMD2 to fail. +docker run --read-only --user 1000:1000 --rm --volume=$testDir/certs:/certificates "$1" $CMD1 >&/dev/null +echo -n $? +docker run --read-only --user 1000:1000 --rm --volume=$testDir/certs:/certificates "$1" "${CMD2[@]}" >&/dev/null +echo -n $? + +# Test run 4: Certificates are mounted and the environment variable is set. We expect both CMD1 and CMD2 to succeed. +docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs:/certificates "$1" $CMD1 >&/dev/null +echo -n $? +docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs:/certificates "$1" "${CMD2[@]}" >&/dev/null +echo -n $? + +# Test run 5: Certificates are mounted and are symlinks (e.g. in Kubernetes as `Secret`s or `ConfigMap`s) and the +# environment variable is set. We expect both CMD1 and CMD2 to succeed. +docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_symlink:/certificates "$1" $CMD1 >&/dev/null +echo -n $? +docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_symlink:/certificates "$1" "${CMD2[@]}" >&/dev/null +echo -n $? + +# Test run 6: Certificates are mounted and the environment variable is set, but the entrypoint is overridden. We expect +# CMD1 to succeed and CMD2 to fail. +# +docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs:/certificates "$TESTIMAGE" $CMD1 >&/dev/null +echo -n $? +docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs:/certificates "$TESTIMAGE" "${CMD2[@]}" >&/dev/null +echo -n $? + +# Test run 7: Two certificates with the same CN are mounted and the environment variable is set. +# We expect both CMD1 to succeed and CMD3 to find both certificates. +docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_duplicate_cn:/certificates "$1" $CMD1 >&/dev/null +echo -n $? +docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_duplicate_cn:/certificates "$1" "${CMD3[@]}" >&/dev/null +echo -n $? + +# Test run 8: Two certificates with no CN and the same serial number (00) are mounted and the environment +# variable is set. We expect CMD1 to succeed and CMD4 to find both fingerprint-based aliases. +docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_no_cn:/certificates "$1" $CMD1 >&/dev/null +echo -n $? +docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_no_cn:/certificates "$1" "${CMD4[@]}" >&/dev/null +echo -n $? + +# Test run 9: Three certificates with identical CN and identical serial number are mounted and the +# environment variable is set. We expect CMD1 to succeed and CMD5 to find all three fingerprint-based aliases. +docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_same_cn_serial:/certificates "$1" $CMD1 >&/dev/null +echo -n $? +docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_same_cn_serial:/certificates "$1" "${CMD5[@]}" >&/dev/null +echo -n $? diff --git a/11/jdk/alpine/3.21/Dockerfile b/11/jdk/alpine/3.21/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bf235f086296edb3c93489c97ca4800379287f63 --- /dev/null +++ b/11/jdk/alpine/3.21/Dockerfile @@ -0,0 +1,90 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.21 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='be9831861b7a4b5fc8ec0d9540d462230f6b9bd6c7ee29585ec1ce52d1435d6c'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_x64_alpine-linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/11/jdk/alpine/3.21/entrypoint.sh b/11/jdk/alpine/3.21/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/11/jdk/alpine/3.21/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/11/jdk/alpine/3.22/Dockerfile b/11/jdk/alpine/3.22/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8bc956373ca64d13434fa13b2501384acf816252 --- /dev/null +++ b/11/jdk/alpine/3.22/Dockerfile @@ -0,0 +1,90 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.22 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='be9831861b7a4b5fc8ec0d9540d462230f6b9bd6c7ee29585ec1ce52d1435d6c'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_x64_alpine-linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/11/jdk/alpine/3.22/entrypoint.sh b/11/jdk/alpine/3.22/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/11/jdk/alpine/3.22/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/11/jdk/alpine/3.23/Dockerfile b/11/jdk/alpine/3.23/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8d7a5568f5146cb13c13a55c1bf76041b5f73467 --- /dev/null +++ b/11/jdk/alpine/3.23/Dockerfile @@ -0,0 +1,90 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.23 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='be9831861b7a4b5fc8ec0d9540d462230f6b9bd6c7ee29585ec1ce52d1435d6c'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_x64_alpine-linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/11/jdk/alpine/3.23/entrypoint.sh b/11/jdk/alpine/3.23/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/11/jdk/alpine/3.23/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/11/jdk/alpine/3.24/Dockerfile b/11/jdk/alpine/3.24/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2dd4af6a03513db6261bebf7e5d689dc7a0e7484 --- /dev/null +++ b/11/jdk/alpine/3.24/Dockerfile @@ -0,0 +1,90 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.24 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='be9831861b7a4b5fc8ec0d9540d462230f6b9bd6c7ee29585ec1ce52d1435d6c'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_x64_alpine-linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/11/jdk/alpine/3.24/entrypoint.sh b/11/jdk/alpine/3.24/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/11/jdk/alpine/3.24/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/11/jdk/ubi/ubi10-minimal/Dockerfile b/11/jdk/ubi/ubi10-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..736734e1b5ae36ab524a90f32f866300686a0087 --- /dev/null +++ b/11/jdk/ubi/ubi10-minimal/Dockerfile @@ -0,0 +1,103 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi10-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + # Required for gpg in multi-arch-install + gnupg2 \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='66a7d4af3572d920b0f1b01710ffa79888d4ddd1b784632e33a3d711aa7d1e63'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_aarch64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='e662ceae8e93c1754f31f444a2fc7089add9a77b62d8aea29af50409ca111cec'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + s390x) \ + ESUM='9efb3c1430d363f7ba5b4262aa427ca30a5f466cd8107352223308fc73d1b0a3'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='5906e0339e9322a688b2375eaf40666e00a16e008b0067b0a9f9e4b6c5033720'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/11/jdk/ubi/ubi10-minimal/entrypoint.sh b/11/jdk/ubi/ubi10-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fb2948890a10dda817bec84a42a47cf5cdaf6ba --- /dev/null +++ b/11/jdk/ubi/ubi10-minimal/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/11/jdk/ubi/ubi9-minimal/Dockerfile b/11/jdk/ubi/ubi9-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..eea565e90b9c236f347a95df3f0df7ab847c1139 --- /dev/null +++ b/11/jdk/ubi/ubi9-minimal/Dockerfile @@ -0,0 +1,101 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi9-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='66a7d4af3572d920b0f1b01710ffa79888d4ddd1b784632e33a3d711aa7d1e63'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_aarch64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='e662ceae8e93c1754f31f444a2fc7089add9a77b62d8aea29af50409ca111cec'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + s390x) \ + ESUM='9efb3c1430d363f7ba5b4262aa427ca30a5f466cd8107352223308fc73d1b0a3'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='5906e0339e9322a688b2375eaf40666e00a16e008b0067b0a9f9e4b6c5033720'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/11/jdk/ubi/ubi9-minimal/entrypoint.sh b/11/jdk/ubi/ubi9-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fb2948890a10dda817bec84a42a47cf5cdaf6ba --- /dev/null +++ b/11/jdk/ubi/ubi9-minimal/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/11/jdk/ubuntu/jammy/Dockerfile b/11/jdk/ubuntu/jammy/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..50bd34a59922fe49fc4b3a9c5b1774b68910d523 --- /dev/null +++ b/11/jdk/ubuntu/jammy/Dockerfile @@ -0,0 +1,113 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:22.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='5906e0339e9322a688b2375eaf40666e00a16e008b0067b0a9f9e4b6c5033720'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + arm64) \ + ESUM='66a7d4af3572d920b0f1b01710ffa79888d4ddd1b784632e33a3d711aa7d1e63'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_aarch64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + armhf) \ + ESUM='abe56bf1e4aa83a676b1a4b397e80f47ad686eed9aaef3cd007d2212cadc5fb0'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_arm_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='e662ceae8e93c1754f31f444a2fc7089add9a77b62d8aea29af50409ca111cec'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + s390x) \ + ESUM='9efb3c1430d363f7ba5b4262aa427ca30a5f466cd8107352223308fc73d1b0a3'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/11/jdk/ubuntu/jammy/entrypoint.sh b/11/jdk/ubuntu/jammy/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/11/jdk/ubuntu/jammy/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/11/jdk/ubuntu/noble/Dockerfile b/11/jdk/ubuntu/noble/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7b30927f176a5ae083c3fee1ad79f6b03fee71eb --- /dev/null +++ b/11/jdk/ubuntu/noble/Dockerfile @@ -0,0 +1,113 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:24.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='5906e0339e9322a688b2375eaf40666e00a16e008b0067b0a9f9e4b6c5033720'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + arm64) \ + ESUM='66a7d4af3572d920b0f1b01710ffa79888d4ddd1b784632e33a3d711aa7d1e63'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_aarch64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + armhf) \ + ESUM='abe56bf1e4aa83a676b1a4b397e80f47ad686eed9aaef3cd007d2212cadc5fb0'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_arm_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='e662ceae8e93c1754f31f444a2fc7089add9a77b62d8aea29af50409ca111cec'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + s390x) \ + ESUM='9efb3c1430d363f7ba5b4262aa427ca30a5f466cd8107352223308fc73d1b0a3'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/11/jdk/ubuntu/noble/entrypoint.sh b/11/jdk/ubuntu/noble/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/11/jdk/ubuntu/noble/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/11/jdk/ubuntu/resolute/Dockerfile b/11/jdk/ubuntu/resolute/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..691bcb4b8c1cc89ea049c22ed63ec1411185ca28 --- /dev/null +++ b/11/jdk/ubuntu/resolute/Dockerfile @@ -0,0 +1,113 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:26.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='5906e0339e9322a688b2375eaf40666e00a16e008b0067b0a9f9e4b6c5033720'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + arm64) \ + ESUM='66a7d4af3572d920b0f1b01710ffa79888d4ddd1b784632e33a3d711aa7d1e63'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_aarch64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + armhf) \ + ESUM='abe56bf1e4aa83a676b1a4b397e80f47ad686eed9aaef3cd007d2212cadc5fb0'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_arm_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='e662ceae8e93c1754f31f444a2fc7089add9a77b62d8aea29af50409ca111cec'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + s390x) \ + ESUM='9efb3c1430d363f7ba5b4262aa427ca30a5f466cd8107352223308fc73d1b0a3'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/11/jdk/ubuntu/resolute/entrypoint.sh b/11/jdk/ubuntu/resolute/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/11/jdk/ubuntu/resolute/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/11/jdk/windows/nanoserver-ltsc2022/Dockerfile b/11/jdk/windows/nanoserver-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b76c7fe724dff90a62c7556bbfa814af2073fb7c --- /dev/null +++ b/11/jdk/windows/nanoserver-ltsc2022/Dockerfile @@ -0,0 +1,41 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-11.0.32+9 + +ENV JAVA_HOME C:\\openjdk-11 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:11.0.32_9-jdk-windowsservercore-ltsc2022 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo javac --version && javac --version \ + && echo java --version && java --version \ + && echo Complete. + +CMD ["jshell"] diff --git a/11/jdk/windows/nanoserver-ltsc2025/Dockerfile b/11/jdk/windows/nanoserver-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2b04961d6df8a289df42be8cd610d739b3177d23 --- /dev/null +++ b/11/jdk/windows/nanoserver-ltsc2025/Dockerfile @@ -0,0 +1,41 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2025 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-11.0.32+9 + +ENV JAVA_HOME C:\\openjdk-11 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:11.0.32_9-jdk-windowsservercore-ltsc2025 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo javac --version && javac --version \ + && echo java --version && java --version \ + && echo Complete. + +CMD ["jshell"] diff --git a/11/jdk/windows/windowsservercore-ltsc2022/Dockerfile b/11/jdk/windows/windowsservercore-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..da868000037e139bae3338c7db87c579b6c97d12 --- /dev/null +++ b/11/jdk/windows/windowsservercore-ltsc2022/Dockerfile @@ -0,0 +1,56 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2022 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_x64_windows_hotspot_11.0.32_9.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_x64_windows_hotspot_11.0.32_9.msi ; \ + Write-Host ('Verifying sha256 (f6079d2975e9b7f9707b18ec6a24841fa327aafa749b032c4ab74cdf9746b76e) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne 'f6079d2975e9b7f9707b18ec6a24841fa327aafa749b032c4ab74cdf9746b76e') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-11' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'javac --version'; javac --version; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' + +CMD ["jshell"] diff --git a/11/jdk/windows/windowsservercore-ltsc2025/Dockerfile b/11/jdk/windows/windowsservercore-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..074ee709a99e4b042cedf6df0edb75bec7901b71 --- /dev/null +++ b/11/jdk/windows/windowsservercore-ltsc2025/Dockerfile @@ -0,0 +1,56 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2025 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_x64_windows_hotspot_11.0.32_9.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jdk_x64_windows_hotspot_11.0.32_9.msi ; \ + Write-Host ('Verifying sha256 (f6079d2975e9b7f9707b18ec6a24841fa327aafa749b032c4ab74cdf9746b76e) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne 'f6079d2975e9b7f9707b18ec6a24841fa327aafa749b032c4ab74cdf9746b76e') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-11' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'javac --version'; javac --version; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' + +CMD ["jshell"] diff --git a/11/jre/alpine/3.21/Dockerfile b/11/jre/alpine/3.21/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5a914c4e0c702ef13d2f7fd6928f1a5203555936 --- /dev/null +++ b/11/jre/alpine/3.21/Dockerfile @@ -0,0 +1,86 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.21 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='a9745bbf185f9c10b12c8dc7c8741522702c6e201dc8419277e6011bcf717b31'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_x64_alpine-linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/11/jre/alpine/3.21/entrypoint.sh b/11/jre/alpine/3.21/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/11/jre/alpine/3.21/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/11/jre/alpine/3.22/Dockerfile b/11/jre/alpine/3.22/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1d76449ba412ab9c6571898f2bca8db725844b07 --- /dev/null +++ b/11/jre/alpine/3.22/Dockerfile @@ -0,0 +1,86 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.22 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='a9745bbf185f9c10b12c8dc7c8741522702c6e201dc8419277e6011bcf717b31'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_x64_alpine-linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/11/jre/alpine/3.22/entrypoint.sh b/11/jre/alpine/3.22/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/11/jre/alpine/3.22/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/11/jre/alpine/3.23/Dockerfile b/11/jre/alpine/3.23/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f79f2f4aa57fc9fce3a874492aed91cc5bd8513b --- /dev/null +++ b/11/jre/alpine/3.23/Dockerfile @@ -0,0 +1,86 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.23 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='a9745bbf185f9c10b12c8dc7c8741522702c6e201dc8419277e6011bcf717b31'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_x64_alpine-linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/11/jre/alpine/3.23/entrypoint.sh b/11/jre/alpine/3.23/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/11/jre/alpine/3.23/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/11/jre/alpine/3.24/Dockerfile b/11/jre/alpine/3.24/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..295c7461defe39a6cdcb95bdbda9f00f31d88189 --- /dev/null +++ b/11/jre/alpine/3.24/Dockerfile @@ -0,0 +1,86 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.24 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='a9745bbf185f9c10b12c8dc7c8741522702c6e201dc8419277e6011bcf717b31'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_x64_alpine-linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/11/jre/alpine/3.24/entrypoint.sh b/11/jre/alpine/3.24/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/11/jre/alpine/3.24/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/11/jre/ubi/ubi10-minimal/Dockerfile b/11/jre/ubi/ubi10-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d1207ea2e78da065607601891cedef81c721750a --- /dev/null +++ b/11/jre/ubi/ubi10-minimal/Dockerfile @@ -0,0 +1,99 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi10-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + # Required for gpg in multi-arch-install + gnupg2 \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='c65c7aada375e3f913ff7a9a8ce00a280b1de10a2ac1321789ac5909508cae76'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_aarch64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='3d0ae354c2378f293bc99819be54bd82694640e295f62164a6a9683d1ebeb96d'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_ppc64le_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + s390x) \ + ESUM='c3b3cd2d00d3730d16b6dba15aeaaf726706fe62bdb2a55bf5f78ed9c4178213'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_s390x_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='87ab4bf8dec10775d986957bc313816678f9227f1d033d7d6e6a1d00dace5b95'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_x64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/11/jre/ubi/ubi10-minimal/entrypoint.sh b/11/jre/ubi/ubi10-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fb2948890a10dda817bec84a42a47cf5cdaf6ba --- /dev/null +++ b/11/jre/ubi/ubi10-minimal/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/11/jre/ubi/ubi9-minimal/Dockerfile b/11/jre/ubi/ubi9-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0cbdffcd6f566a87c0f67c7afad82fa4a6a0bc66 --- /dev/null +++ b/11/jre/ubi/ubi9-minimal/Dockerfile @@ -0,0 +1,97 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi9-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='c65c7aada375e3f913ff7a9a8ce00a280b1de10a2ac1321789ac5909508cae76'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_aarch64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='3d0ae354c2378f293bc99819be54bd82694640e295f62164a6a9683d1ebeb96d'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_ppc64le_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + s390x) \ + ESUM='c3b3cd2d00d3730d16b6dba15aeaaf726706fe62bdb2a55bf5f78ed9c4178213'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_s390x_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='87ab4bf8dec10775d986957bc313816678f9227f1d033d7d6e6a1d00dace5b95'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_x64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/11/jre/ubi/ubi9-minimal/entrypoint.sh b/11/jre/ubi/ubi9-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fb2948890a10dda817bec84a42a47cf5cdaf6ba --- /dev/null +++ b/11/jre/ubi/ubi9-minimal/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/11/jre/ubuntu/jammy/Dockerfile b/11/jre/ubuntu/jammy/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f2d7ab451a301930a99dfb8ad558a20e5a915acf --- /dev/null +++ b/11/jre/ubuntu/jammy/Dockerfile @@ -0,0 +1,109 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:22.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='87ab4bf8dec10775d986957bc313816678f9227f1d033d7d6e6a1d00dace5b95'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_x64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + arm64) \ + ESUM='c65c7aada375e3f913ff7a9a8ce00a280b1de10a2ac1321789ac5909508cae76'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_aarch64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + armhf) \ + ESUM='c6b7d991b454f54f794503aabd36ebaae1647190f9a41ba72f021aa5721f2dd4'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_arm_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='3d0ae354c2378f293bc99819be54bd82694640e295f62164a6a9683d1ebeb96d'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_ppc64le_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + s390x) \ + ESUM='c3b3cd2d00d3730d16b6dba15aeaaf726706fe62bdb2a55bf5f78ed9c4178213'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_s390x_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/11/jre/ubuntu/jammy/entrypoint.sh b/11/jre/ubuntu/jammy/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/11/jre/ubuntu/jammy/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/11/jre/ubuntu/noble/Dockerfile b/11/jre/ubuntu/noble/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fb1561e8bb812983b123124baf347a6ae31a50cf --- /dev/null +++ b/11/jre/ubuntu/noble/Dockerfile @@ -0,0 +1,109 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:24.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='87ab4bf8dec10775d986957bc313816678f9227f1d033d7d6e6a1d00dace5b95'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_x64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + arm64) \ + ESUM='c65c7aada375e3f913ff7a9a8ce00a280b1de10a2ac1321789ac5909508cae76'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_aarch64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + armhf) \ + ESUM='c6b7d991b454f54f794503aabd36ebaae1647190f9a41ba72f021aa5721f2dd4'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_arm_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='3d0ae354c2378f293bc99819be54bd82694640e295f62164a6a9683d1ebeb96d'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_ppc64le_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + s390x) \ + ESUM='c3b3cd2d00d3730d16b6dba15aeaaf726706fe62bdb2a55bf5f78ed9c4178213'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_s390x_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/11/jre/ubuntu/noble/entrypoint.sh b/11/jre/ubuntu/noble/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/11/jre/ubuntu/noble/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/11/jre/ubuntu/resolute/Dockerfile b/11/jre/ubuntu/resolute/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..add44fb34a7ad7657b24d4221e205293f5e0d913 --- /dev/null +++ b/11/jre/ubuntu/resolute/Dockerfile @@ -0,0 +1,109 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:26.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='87ab4bf8dec10775d986957bc313816678f9227f1d033d7d6e6a1d00dace5b95'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_x64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + arm64) \ + ESUM='c65c7aada375e3f913ff7a9a8ce00a280b1de10a2ac1321789ac5909508cae76'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_aarch64_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + armhf) \ + ESUM='c6b7d991b454f54f794503aabd36ebaae1647190f9a41ba72f021aa5721f2dd4'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_arm_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='3d0ae354c2378f293bc99819be54bd82694640e295f62164a6a9683d1ebeb96d'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_ppc64le_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + s390x) \ + ESUM='c3b3cd2d00d3730d16b6dba15aeaaf726706fe62bdb2a55bf5f78ed9c4178213'; \ + BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_s390x_linux_hotspot_11.0.32_9.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/11/jre/ubuntu/resolute/entrypoint.sh b/11/jre/ubuntu/resolute/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/11/jre/ubuntu/resolute/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/11/jre/windows/nanoserver-ltsc2022/Dockerfile b/11/jre/windows/nanoserver-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6c94314ddaec41ced4ac978b2cc7d15704de00de --- /dev/null +++ b/11/jre/windows/nanoserver-ltsc2022/Dockerfile @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-11.0.32+9 + +ENV JAVA_HOME C:\\openjdk-11 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:11.0.32_9-jre-windowsservercore-ltsc2022 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo java --version && java --version \ + && echo Complete. diff --git a/11/jre/windows/nanoserver-ltsc2025/Dockerfile b/11/jre/windows/nanoserver-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a79c2c9211a7cbf6b33b467a9e83ed89e7334940 --- /dev/null +++ b/11/jre/windows/nanoserver-ltsc2025/Dockerfile @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2025 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-11.0.32+9 + +ENV JAVA_HOME C:\\openjdk-11 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:11.0.32_9-jre-windowsservercore-ltsc2025 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo java --version && java --version \ + && echo Complete. diff --git a/11/jre/windows/windowsservercore-ltsc2022/Dockerfile b/11/jre/windows/windowsservercore-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7818416c781f221a9e78cefd0a9d7b9c591f91a9 --- /dev/null +++ b/11/jre/windows/windowsservercore-ltsc2022/Dockerfile @@ -0,0 +1,53 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2022 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_x64_windows_hotspot_11.0.32_9.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_x64_windows_hotspot_11.0.32_9.msi ; \ + Write-Host ('Verifying sha256 (df081418748813e681157c616837a605d463c7a9cee631a3b6319ef838c4cc6e) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne 'df081418748813e681157c616837a605d463c7a9cee631a3b6319ef838c4cc6e') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-11' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' diff --git a/11/jre/windows/windowsservercore-ltsc2025/Dockerfile b/11/jre/windows/windowsservercore-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..18601204bb637244ddc33809341ea959602af9cf --- /dev/null +++ b/11/jre/windows/windowsservercore-ltsc2025/Dockerfile @@ -0,0 +1,53 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2025 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-11.0.32+9 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_x64_windows_hotspot_11.0.32_9.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32%2B9/OpenJDK11U-jre_x64_windows_hotspot_11.0.32_9.msi ; \ + Write-Host ('Verifying sha256 (df081418748813e681157c616837a605d463c7a9cee631a3b6319ef838c4cc6e) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne 'df081418748813e681157c616837a605d463c7a9cee631a3b6319ef838c4cc6e') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-11' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' diff --git a/17/jdk/alpine/3.21/Dockerfile b/17/jdk/alpine/3.21/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8a75c210a1c4c9b7e839b792f329daeca2959ced --- /dev/null +++ b/17/jdk/alpine/3.21/Dockerfile @@ -0,0 +1,93 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.21 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='c8bb5bc6984762dbce2ab7403d90832b6897c07f36f8706e4a315aa7a566d04d'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_x64_alpine-linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/17/jdk/alpine/3.21/entrypoint.sh b/17/jdk/alpine/3.21/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/17/jdk/alpine/3.21/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/17/jdk/alpine/3.22/Dockerfile b/17/jdk/alpine/3.22/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bfdf0d91661edea5dd2adf86daa4ac853b6c7838 --- /dev/null +++ b/17/jdk/alpine/3.22/Dockerfile @@ -0,0 +1,93 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.22 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='c8bb5bc6984762dbce2ab7403d90832b6897c07f36f8706e4a315aa7a566d04d'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_x64_alpine-linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/17/jdk/alpine/3.22/entrypoint.sh b/17/jdk/alpine/3.22/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/17/jdk/alpine/3.22/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/17/jdk/alpine/3.23/Dockerfile b/17/jdk/alpine/3.23/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7a9a24e7186d275d6c952472fa9554f1369c7c8f --- /dev/null +++ b/17/jdk/alpine/3.23/Dockerfile @@ -0,0 +1,93 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.23 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='c8bb5bc6984762dbce2ab7403d90832b6897c07f36f8706e4a315aa7a566d04d'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_x64_alpine-linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/17/jdk/alpine/3.23/entrypoint.sh b/17/jdk/alpine/3.23/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/17/jdk/alpine/3.23/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/17/jdk/alpine/3.24/Dockerfile b/17/jdk/alpine/3.24/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4a79609f2f6e2527c127f19fb60799afcb930937 --- /dev/null +++ b/17/jdk/alpine/3.24/Dockerfile @@ -0,0 +1,93 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.24 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='c8bb5bc6984762dbce2ab7403d90832b6897c07f36f8706e4a315aa7a566d04d'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_x64_alpine-linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/17/jdk/alpine/3.24/entrypoint.sh b/17/jdk/alpine/3.24/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/17/jdk/alpine/3.24/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/17/jdk/ubi/ubi10-minimal/Dockerfile b/17/jdk/ubi/ubi10-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8b73ef1bc2ef0ad347d889ffca8566eae5adee55 --- /dev/null +++ b/17/jdk/ubi/ubi10-minimal/Dockerfile @@ -0,0 +1,103 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi10-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + # Required for gpg in multi-arch-install + gnupg2 \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='d143936f473a4cb24e3b0e247d6d0775769d55ec9775c339540e753059a8d77a'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_aarch64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='a14127c5577dc12e058459549e5388fd47ebd1b3d8441fbd23c4d931bdcebee9'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_ppc64le_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='d5bbce66faa1482adb6ddcabc51d6c14b7c35cb11174e657d84ecb2177a4f6e9'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_s390x_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='be7668bc030d578b83d6d5ef9221d6d6729bbbca8cf94a7d52e16ac68b5a5a35'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_x64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/17/jdk/ubi/ubi10-minimal/entrypoint.sh b/17/jdk/ubi/ubi10-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fb2948890a10dda817bec84a42a47cf5cdaf6ba --- /dev/null +++ b/17/jdk/ubi/ubi10-minimal/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/17/jdk/ubi/ubi9-minimal/Dockerfile b/17/jdk/ubi/ubi9-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..58df72b514f9e121a2fc9a01c6f92b4b0b671853 --- /dev/null +++ b/17/jdk/ubi/ubi9-minimal/Dockerfile @@ -0,0 +1,101 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi9-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='d143936f473a4cb24e3b0e247d6d0775769d55ec9775c339540e753059a8d77a'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_aarch64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='a14127c5577dc12e058459549e5388fd47ebd1b3d8441fbd23c4d931bdcebee9'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_ppc64le_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='d5bbce66faa1482adb6ddcabc51d6c14b7c35cb11174e657d84ecb2177a4f6e9'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_s390x_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='be7668bc030d578b83d6d5ef9221d6d6729bbbca8cf94a7d52e16ac68b5a5a35'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_x64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/17/jdk/ubi/ubi9-minimal/entrypoint.sh b/17/jdk/ubi/ubi9-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fb2948890a10dda817bec84a42a47cf5cdaf6ba --- /dev/null +++ b/17/jdk/ubi/ubi9-minimal/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/17/jdk/ubuntu/jammy/Dockerfile b/17/jdk/ubuntu/jammy/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1b95706602e93930c62f6df5d4a3ce6bbcd35888 --- /dev/null +++ b/17/jdk/ubuntu/jammy/Dockerfile @@ -0,0 +1,116 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:22.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='be7668bc030d578b83d6d5ef9221d6d6729bbbca8cf94a7d52e16ac68b5a5a35'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_x64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + arm64) \ + ESUM='d143936f473a4cb24e3b0e247d6d0775769d55ec9775c339540e753059a8d77a'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_aarch64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + armhf) \ + ESUM='543173615a7e6e8905d99c45f9d0caeb5faf1a6dcdc25cbb5337f53e7ef06c78'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_arm_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='a14127c5577dc12e058459549e5388fd47ebd1b3d8441fbd23c4d931bdcebee9'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_ppc64le_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='d5bbce66faa1482adb6ddcabc51d6c14b7c35cb11174e657d84ecb2177a4f6e9'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_s390x_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/17/jdk/ubuntu/jammy/entrypoint.sh b/17/jdk/ubuntu/jammy/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/17/jdk/ubuntu/jammy/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/17/jdk/ubuntu/noble/Dockerfile b/17/jdk/ubuntu/noble/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..168b506ed3f55ef2f1b66d748f1972de9801dac9 --- /dev/null +++ b/17/jdk/ubuntu/noble/Dockerfile @@ -0,0 +1,120 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:24.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='be7668bc030d578b83d6d5ef9221d6d6729bbbca8cf94a7d52e16ac68b5a5a35'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_x64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + arm64) \ + ESUM='d143936f473a4cb24e3b0e247d6d0775769d55ec9775c339540e753059a8d77a'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_aarch64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + armhf) \ + ESUM='543173615a7e6e8905d99c45f9d0caeb5faf1a6dcdc25cbb5337f53e7ef06c78'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_arm_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='a14127c5577dc12e058459549e5388fd47ebd1b3d8441fbd23c4d931bdcebee9'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_ppc64le_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + riscv64) \ + ESUM='bc36e8044c88df9f4ec2967c5277d1c8fae572378c12c0bac44dcae15d3af2f7'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_riscv64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='d5bbce66faa1482adb6ddcabc51d6c14b7c35cb11174e657d84ecb2177a4f6e9'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_s390x_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/17/jdk/ubuntu/noble/entrypoint.sh b/17/jdk/ubuntu/noble/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/17/jdk/ubuntu/noble/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/17/jdk/ubuntu/resolute/Dockerfile b/17/jdk/ubuntu/resolute/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..27dea70bb5702b13b8b581ad6d40cdddfb7dda04 --- /dev/null +++ b/17/jdk/ubuntu/resolute/Dockerfile @@ -0,0 +1,116 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:26.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='be7668bc030d578b83d6d5ef9221d6d6729bbbca8cf94a7d52e16ac68b5a5a35'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_x64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + arm64) \ + ESUM='d143936f473a4cb24e3b0e247d6d0775769d55ec9775c339540e753059a8d77a'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_aarch64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + armhf) \ + ESUM='543173615a7e6e8905d99c45f9d0caeb5faf1a6dcdc25cbb5337f53e7ef06c78'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_arm_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='a14127c5577dc12e058459549e5388fd47ebd1b3d8441fbd23c4d931bdcebee9'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_ppc64le_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='d5bbce66faa1482adb6ddcabc51d6c14b7c35cb11174e657d84ecb2177a4f6e9'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_s390x_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/17/jdk/ubuntu/resolute/entrypoint.sh b/17/jdk/ubuntu/resolute/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/17/jdk/ubuntu/resolute/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/17/jdk/windows/nanoserver-ltsc2022/Dockerfile b/17/jdk/windows/nanoserver-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..717d09fc62b2a9a6b04e178a6c74d7e66582575b --- /dev/null +++ b/17/jdk/windows/nanoserver-ltsc2022/Dockerfile @@ -0,0 +1,41 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-17.0.20+8 + +ENV JAVA_HOME C:\\openjdk-17 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:17.0.20_8-jdk-windowsservercore-ltsc2022 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo javac --version && javac --version \ + && echo java --version && java --version \ + && echo Complete. + +CMD ["jshell"] diff --git a/17/jdk/windows/nanoserver-ltsc2025/Dockerfile b/17/jdk/windows/nanoserver-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a4fa8e4cecb5bc71ec99d11986987e8733a2fe52 --- /dev/null +++ b/17/jdk/windows/nanoserver-ltsc2025/Dockerfile @@ -0,0 +1,41 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2025 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-17.0.20+8 + +ENV JAVA_HOME C:\\openjdk-17 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:17.0.20_8-jdk-windowsservercore-ltsc2025 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo javac --version && javac --version \ + && echo java --version && java --version \ + && echo Complete. + +CMD ["jshell"] diff --git a/17/jdk/windows/windowsservercore-ltsc2022/Dockerfile b/17/jdk/windows/windowsservercore-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e70e400f0b681849e9deef97a24167435d7350d2 --- /dev/null +++ b/17/jdk/windows/windowsservercore-ltsc2022/Dockerfile @@ -0,0 +1,56 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2022 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_x64_windows_hotspot_17.0.20_8.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_x64_windows_hotspot_17.0.20_8.msi ; \ + Write-Host ('Verifying sha256 (1a8ec6023937b94e26691a2369e9f99dfeae3a25351a7e4f9320828aae481898) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne '1a8ec6023937b94e26691a2369e9f99dfeae3a25351a7e4f9320828aae481898') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-17' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'javac --version'; javac --version; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' + +CMD ["jshell"] diff --git a/17/jdk/windows/windowsservercore-ltsc2025/Dockerfile b/17/jdk/windows/windowsservercore-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..eda65f02191f052b12e288e03c10475ca719e1b2 --- /dev/null +++ b/17/jdk/windows/windowsservercore-ltsc2025/Dockerfile @@ -0,0 +1,56 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2025 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_x64_windows_hotspot_17.0.20_8.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jdk_x64_windows_hotspot_17.0.20_8.msi ; \ + Write-Host ('Verifying sha256 (1a8ec6023937b94e26691a2369e9f99dfeae3a25351a7e4f9320828aae481898) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne '1a8ec6023937b94e26691a2369e9f99dfeae3a25351a7e4f9320828aae481898') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-17' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'javac --version'; javac --version; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' + +CMD ["jshell"] diff --git a/17/jre/alpine/3.21/Dockerfile b/17/jre/alpine/3.21/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..235013a11601127710181578fb03e9d932b603ce --- /dev/null +++ b/17/jre/alpine/3.21/Dockerfile @@ -0,0 +1,86 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.21 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='561ea743b8481ed75bf095bff8d156943360f3a6c0ba808215b946f73fc3b89a'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_x64_alpine-linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/17/jre/alpine/3.21/entrypoint.sh b/17/jre/alpine/3.21/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/17/jre/alpine/3.21/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/17/jre/alpine/3.22/Dockerfile b/17/jre/alpine/3.22/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9cf87fe9201b21920252389491a5c50c0fae954e --- /dev/null +++ b/17/jre/alpine/3.22/Dockerfile @@ -0,0 +1,86 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.22 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='561ea743b8481ed75bf095bff8d156943360f3a6c0ba808215b946f73fc3b89a'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_x64_alpine-linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/17/jre/alpine/3.22/entrypoint.sh b/17/jre/alpine/3.22/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/17/jre/alpine/3.22/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/17/jre/alpine/3.23/Dockerfile b/17/jre/alpine/3.23/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1da276b104cf2f932b99c790f84d187c4b705d6b --- /dev/null +++ b/17/jre/alpine/3.23/Dockerfile @@ -0,0 +1,86 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.23 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='561ea743b8481ed75bf095bff8d156943360f3a6c0ba808215b946f73fc3b89a'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_x64_alpine-linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/17/jre/alpine/3.23/entrypoint.sh b/17/jre/alpine/3.23/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/17/jre/alpine/3.23/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/17/jre/alpine/3.24/Dockerfile b/17/jre/alpine/3.24/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d21ae2b20c6e25481bdd7388d6d77cb5acd03e42 --- /dev/null +++ b/17/jre/alpine/3.24/Dockerfile @@ -0,0 +1,86 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.24 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='561ea743b8481ed75bf095bff8d156943360f3a6c0ba808215b946f73fc3b89a'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_x64_alpine-linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/17/jre/alpine/3.24/entrypoint.sh b/17/jre/alpine/3.24/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/17/jre/alpine/3.24/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/17/jre/ubi/ubi10-minimal/Dockerfile b/17/jre/ubi/ubi10-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2a38e8cad142b8722d5012aee24bf1c963132fdf --- /dev/null +++ b/17/jre/ubi/ubi10-minimal/Dockerfile @@ -0,0 +1,99 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi10-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + # Required for gpg in multi-arch-install + gnupg2 \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='9d14a95e07c44bc48666625162baf40db9da4dcb192bfc3e43047790693061a2'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_aarch64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='cb3d0280a1be22db89ec81058471a8c694ea35b33d4bfc23d52c55f6be2a34f7'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_ppc64le_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='6effd0a45b0ea7ee9fccc861e7bd4dcb92a6096e7cea3ed22484231c1be82736'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_s390x_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='ef491a51a46ef90cc47fbc4abb219fde32483ff91be5ec66ddc896df43524b27'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_x64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/17/jre/ubi/ubi10-minimal/entrypoint.sh b/17/jre/ubi/ubi10-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fb2948890a10dda817bec84a42a47cf5cdaf6ba --- /dev/null +++ b/17/jre/ubi/ubi10-minimal/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/17/jre/ubi/ubi9-minimal/Dockerfile b/17/jre/ubi/ubi9-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..59547865bbee10bd980ae1deeb0a79a188ef8506 --- /dev/null +++ b/17/jre/ubi/ubi9-minimal/Dockerfile @@ -0,0 +1,97 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi9-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='9d14a95e07c44bc48666625162baf40db9da4dcb192bfc3e43047790693061a2'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_aarch64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='cb3d0280a1be22db89ec81058471a8c694ea35b33d4bfc23d52c55f6be2a34f7'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_ppc64le_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='6effd0a45b0ea7ee9fccc861e7bd4dcb92a6096e7cea3ed22484231c1be82736'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_s390x_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='ef491a51a46ef90cc47fbc4abb219fde32483ff91be5ec66ddc896df43524b27'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_x64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/17/jre/ubi/ubi9-minimal/entrypoint.sh b/17/jre/ubi/ubi9-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fb2948890a10dda817bec84a42a47cf5cdaf6ba --- /dev/null +++ b/17/jre/ubi/ubi9-minimal/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/17/jre/ubuntu/jammy/Dockerfile b/17/jre/ubuntu/jammy/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5c3ae07820740e4a46e272eb04d2e1b4e98326c9 --- /dev/null +++ b/17/jre/ubuntu/jammy/Dockerfile @@ -0,0 +1,109 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:22.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='ef491a51a46ef90cc47fbc4abb219fde32483ff91be5ec66ddc896df43524b27'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_x64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + arm64) \ + ESUM='9d14a95e07c44bc48666625162baf40db9da4dcb192bfc3e43047790693061a2'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_aarch64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + armhf) \ + ESUM='b3b1c5aa21111d9000a855008b0f08ca3f7cdd4d9ba99e2b9f0750eb82e261e5'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_arm_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='cb3d0280a1be22db89ec81058471a8c694ea35b33d4bfc23d52c55f6be2a34f7'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_ppc64le_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='6effd0a45b0ea7ee9fccc861e7bd4dcb92a6096e7cea3ed22484231c1be82736'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_s390x_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/17/jre/ubuntu/jammy/entrypoint.sh b/17/jre/ubuntu/jammy/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/17/jre/ubuntu/jammy/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/17/jre/ubuntu/noble/Dockerfile b/17/jre/ubuntu/noble/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e6f26ec73c4fed86d79500efd9acf28999ead6b5 --- /dev/null +++ b/17/jre/ubuntu/noble/Dockerfile @@ -0,0 +1,113 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:24.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='ef491a51a46ef90cc47fbc4abb219fde32483ff91be5ec66ddc896df43524b27'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_x64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + arm64) \ + ESUM='9d14a95e07c44bc48666625162baf40db9da4dcb192bfc3e43047790693061a2'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_aarch64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + armhf) \ + ESUM='b3b1c5aa21111d9000a855008b0f08ca3f7cdd4d9ba99e2b9f0750eb82e261e5'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_arm_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='cb3d0280a1be22db89ec81058471a8c694ea35b33d4bfc23d52c55f6be2a34f7'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_ppc64le_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + riscv64) \ + ESUM='9c018e609c1f851018f053bb634e14473e8c0b6532aae400a105aa4d52c84d42'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_riscv64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='6effd0a45b0ea7ee9fccc861e7bd4dcb92a6096e7cea3ed22484231c1be82736'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_s390x_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/17/jre/ubuntu/noble/entrypoint.sh b/17/jre/ubuntu/noble/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/17/jre/ubuntu/noble/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/17/jre/ubuntu/resolute/Dockerfile b/17/jre/ubuntu/resolute/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..555352de0814c3bb313ff666fd39856ea9048142 --- /dev/null +++ b/17/jre/ubuntu/resolute/Dockerfile @@ -0,0 +1,109 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:26.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='ef491a51a46ef90cc47fbc4abb219fde32483ff91be5ec66ddc896df43524b27'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_x64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + arm64) \ + ESUM='9d14a95e07c44bc48666625162baf40db9da4dcb192bfc3e43047790693061a2'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_aarch64_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + armhf) \ + ESUM='b3b1c5aa21111d9000a855008b0f08ca3f7cdd4d9ba99e2b9f0750eb82e261e5'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_arm_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='cb3d0280a1be22db89ec81058471a8c694ea35b33d4bfc23d52c55f6be2a34f7'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_ppc64le_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='6effd0a45b0ea7ee9fccc861e7bd4dcb92a6096e7cea3ed22484231c1be82736'; \ + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_s390x_linux_hotspot_17.0.20_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/17/jre/ubuntu/resolute/entrypoint.sh b/17/jre/ubuntu/resolute/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/17/jre/ubuntu/resolute/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/17/jre/windows/nanoserver-ltsc2022/Dockerfile b/17/jre/windows/nanoserver-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9a47f20fe1f36a2d60cac73d975a2a8cdc16f743 --- /dev/null +++ b/17/jre/windows/nanoserver-ltsc2022/Dockerfile @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-17.0.20+8 + +ENV JAVA_HOME C:\\openjdk-17 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:17.0.20_8-jre-windowsservercore-ltsc2022 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo java --version && java --version \ + && echo Complete. diff --git a/17/jre/windows/nanoserver-ltsc2025/Dockerfile b/17/jre/windows/nanoserver-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..36aec5e1631367b56418fc7b037811304648e160 --- /dev/null +++ b/17/jre/windows/nanoserver-ltsc2025/Dockerfile @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2025 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-17.0.20+8 + +ENV JAVA_HOME C:\\openjdk-17 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:17.0.20_8-jre-windowsservercore-ltsc2025 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo java --version && java --version \ + && echo Complete. diff --git a/17/jre/windows/windowsservercore-ltsc2022/Dockerfile b/17/jre/windows/windowsservercore-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..45be5d516f6064c6811ece78e5c436875807eda1 --- /dev/null +++ b/17/jre/windows/windowsservercore-ltsc2022/Dockerfile @@ -0,0 +1,53 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2022 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_x64_windows_hotspot_17.0.20_8.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_x64_windows_hotspot_17.0.20_8.msi ; \ + Write-Host ('Verifying sha256 (45ca8db42fb8bbfbf35b68121cf74e1f9fe36ba982b59d38f0da7802902fbace) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne '45ca8db42fb8bbfbf35b68121cf74e1f9fe36ba982b59d38f0da7802902fbace') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-17' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' diff --git a/17/jre/windows/windowsservercore-ltsc2025/Dockerfile b/17/jre/windows/windowsservercore-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f150f120c6938b9a5c6539792307403bdfc8fd16 --- /dev/null +++ b/17/jre/windows/windowsservercore-ltsc2025/Dockerfile @@ -0,0 +1,53 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2025 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-17.0.20+8 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_x64_windows_hotspot_17.0.20_8.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20%2B8/OpenJDK17U-jre_x64_windows_hotspot_17.0.20_8.msi ; \ + Write-Host ('Verifying sha256 (45ca8db42fb8bbfbf35b68121cf74e1f9fe36ba982b59d38f0da7802902fbace) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne '45ca8db42fb8bbfbf35b68121cf74e1f9fe36ba982b59d38f0da7802902fbace') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-17' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' diff --git a/21/jdk/alpine/3.21/Dockerfile b/21/jdk/alpine/3.21/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bbeddfdafb36bf2aff104c68b875369473a7ecca --- /dev/null +++ b/21/jdk/alpine/3.21/Dockerfile @@ -0,0 +1,97 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.21 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='a32f7655011640ed8fb4347fffa2588cb7538de2f2e82027845816740560e2b1'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_aarch64_alpine-linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='073a48cb87f788a0cb283d81cc6d96cbc9d671d6a60a3ba6de62e66f0ea9dd47'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_x64_alpine-linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/21/jdk/alpine/3.21/entrypoint.sh b/21/jdk/alpine/3.21/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/21/jdk/alpine/3.21/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/21/jdk/alpine/3.22/Dockerfile b/21/jdk/alpine/3.22/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e4352b1332e1dc981843b367dd9ae22a017d10c2 --- /dev/null +++ b/21/jdk/alpine/3.22/Dockerfile @@ -0,0 +1,97 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.22 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='a32f7655011640ed8fb4347fffa2588cb7538de2f2e82027845816740560e2b1'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_aarch64_alpine-linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='073a48cb87f788a0cb283d81cc6d96cbc9d671d6a60a3ba6de62e66f0ea9dd47'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_x64_alpine-linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/21/jdk/alpine/3.22/entrypoint.sh b/21/jdk/alpine/3.22/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/21/jdk/alpine/3.22/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/21/jdk/alpine/3.23/Dockerfile b/21/jdk/alpine/3.23/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3c0bf0be2567665fe86335dae52c4d78b429c922 --- /dev/null +++ b/21/jdk/alpine/3.23/Dockerfile @@ -0,0 +1,97 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.23 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='a32f7655011640ed8fb4347fffa2588cb7538de2f2e82027845816740560e2b1'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_aarch64_alpine-linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='073a48cb87f788a0cb283d81cc6d96cbc9d671d6a60a3ba6de62e66f0ea9dd47'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_x64_alpine-linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/21/jdk/alpine/3.23/entrypoint.sh b/21/jdk/alpine/3.23/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/21/jdk/alpine/3.23/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/21/jdk/alpine/3.24/Dockerfile b/21/jdk/alpine/3.24/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0510b0ad7d7b7a7c4222a5c9bbf2944c9c73a2e8 --- /dev/null +++ b/21/jdk/alpine/3.24/Dockerfile @@ -0,0 +1,97 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.24 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='a32f7655011640ed8fb4347fffa2588cb7538de2f2e82027845816740560e2b1'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_aarch64_alpine-linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='073a48cb87f788a0cb283d81cc6d96cbc9d671d6a60a3ba6de62e66f0ea9dd47'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_x64_alpine-linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/21/jdk/alpine/3.24/entrypoint.sh b/21/jdk/alpine/3.24/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/21/jdk/alpine/3.24/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/21/jdk/ubi/ubi10-minimal/Dockerfile b/21/jdk/ubi/ubi10-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..14a5a590fe80ec5e09454c6bc82c07ac68ae4003 --- /dev/null +++ b/21/jdk/ubi/ubi10-minimal/Dockerfile @@ -0,0 +1,103 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi10-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + # Required for gpg in multi-arch-install + gnupg2 \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='eba38e871b02d407897bfe017ea35352dfc1420ef6d2112425b0c67325ca509d'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_aarch64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='082dac6781cd86c1c1903608b8f354c6dc453313d81881a1e87b9a22663ac5ca'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_ppc64le_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='2a57a86afa2e461757acc6c2bd198a3fdae4393d8d37fd66b6244e713c3c42ea'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_s390x_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='e4446ff06a276155697597cc0f1b15da004ff083f4964a35271ecee567177370'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_x64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/21/jdk/ubi/ubi10-minimal/entrypoint.sh b/21/jdk/ubi/ubi10-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fb2948890a10dda817bec84a42a47cf5cdaf6ba --- /dev/null +++ b/21/jdk/ubi/ubi10-minimal/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/21/jdk/ubi/ubi9-minimal/Dockerfile b/21/jdk/ubi/ubi9-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5ce29157679145815616e4d3d012717796105e44 --- /dev/null +++ b/21/jdk/ubi/ubi9-minimal/Dockerfile @@ -0,0 +1,101 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi9-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='eba38e871b02d407897bfe017ea35352dfc1420ef6d2112425b0c67325ca509d'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_aarch64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='082dac6781cd86c1c1903608b8f354c6dc453313d81881a1e87b9a22663ac5ca'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_ppc64le_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='2a57a86afa2e461757acc6c2bd198a3fdae4393d8d37fd66b6244e713c3c42ea'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_s390x_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='e4446ff06a276155697597cc0f1b15da004ff083f4964a35271ecee567177370'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_x64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/21/jdk/ubi/ubi9-minimal/entrypoint.sh b/21/jdk/ubi/ubi9-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fb2948890a10dda817bec84a42a47cf5cdaf6ba --- /dev/null +++ b/21/jdk/ubi/ubi9-minimal/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/21/jdk/ubuntu/jammy/Dockerfile b/21/jdk/ubuntu/jammy/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e42db1d82a1da48623d47fbf5d46117b6e670661 --- /dev/null +++ b/21/jdk/ubuntu/jammy/Dockerfile @@ -0,0 +1,112 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:22.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='e4446ff06a276155697597cc0f1b15da004ff083f4964a35271ecee567177370'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_x64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + arm64) \ + ESUM='eba38e871b02d407897bfe017ea35352dfc1420ef6d2112425b0c67325ca509d'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_aarch64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='082dac6781cd86c1c1903608b8f354c6dc453313d81881a1e87b9a22663ac5ca'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_ppc64le_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='2a57a86afa2e461757acc6c2bd198a3fdae4393d8d37fd66b6244e713c3c42ea'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_s390x_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/21/jdk/ubuntu/jammy/entrypoint.sh b/21/jdk/ubuntu/jammy/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/21/jdk/ubuntu/jammy/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/21/jdk/ubuntu/noble/Dockerfile b/21/jdk/ubuntu/noble/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9cb1ccae2c0de2296927b11bad58851cfc66ade4 --- /dev/null +++ b/21/jdk/ubuntu/noble/Dockerfile @@ -0,0 +1,116 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:24.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='e4446ff06a276155697597cc0f1b15da004ff083f4964a35271ecee567177370'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_x64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + arm64) \ + ESUM='eba38e871b02d407897bfe017ea35352dfc1420ef6d2112425b0c67325ca509d'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_aarch64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='082dac6781cd86c1c1903608b8f354c6dc453313d81881a1e87b9a22663ac5ca'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_ppc64le_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + riscv64) \ + ESUM='86f836b5a94b3354f236b72339d04418fea178c41624637dd94e510f6597c372'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_riscv64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='2a57a86afa2e461757acc6c2bd198a3fdae4393d8d37fd66b6244e713c3c42ea'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_s390x_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/21/jdk/ubuntu/noble/entrypoint.sh b/21/jdk/ubuntu/noble/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/21/jdk/ubuntu/noble/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/21/jdk/ubuntu/resolute/Dockerfile b/21/jdk/ubuntu/resolute/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6bf340f9dda732edc018f1d92aeea05e79374575 --- /dev/null +++ b/21/jdk/ubuntu/resolute/Dockerfile @@ -0,0 +1,112 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:26.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='e4446ff06a276155697597cc0f1b15da004ff083f4964a35271ecee567177370'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_x64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + arm64) \ + ESUM='eba38e871b02d407897bfe017ea35352dfc1420ef6d2112425b0c67325ca509d'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_aarch64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='082dac6781cd86c1c1903608b8f354c6dc453313d81881a1e87b9a22663ac5ca'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_ppc64le_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='2a57a86afa2e461757acc6c2bd198a3fdae4393d8d37fd66b6244e713c3c42ea'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_s390x_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/21/jdk/ubuntu/resolute/entrypoint.sh b/21/jdk/ubuntu/resolute/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/21/jdk/ubuntu/resolute/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/21/jdk/windows/nanoserver-ltsc2022/Dockerfile b/21/jdk/windows/nanoserver-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e85a89acb585a073bfdcd154d08d016b5c017ba9 --- /dev/null +++ b/21/jdk/windows/nanoserver-ltsc2022/Dockerfile @@ -0,0 +1,41 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-21.0.12+8 + +ENV JAVA_HOME C:\\openjdk-21 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:21.0.12_8-jdk-windowsservercore-ltsc2022 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo javac --version && javac --version \ + && echo java --version && java --version \ + && echo Complete. + +CMD ["jshell"] diff --git a/21/jdk/windows/nanoserver-ltsc2025/Dockerfile b/21/jdk/windows/nanoserver-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a4e2f106d11c2bb7ccf93b12f9e3b371a7db9c5d --- /dev/null +++ b/21/jdk/windows/nanoserver-ltsc2025/Dockerfile @@ -0,0 +1,41 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2025 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-21.0.12+8 + +ENV JAVA_HOME C:\\openjdk-21 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:21.0.12_8-jdk-windowsservercore-ltsc2025 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo javac --version && javac --version \ + && echo java --version && java --version \ + && echo Complete. + +CMD ["jshell"] diff --git a/21/jdk/windows/windowsservercore-ltsc2022/Dockerfile b/21/jdk/windows/windowsservercore-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..025700f679676773db7b495c714ba6db4363d5f6 --- /dev/null +++ b/21/jdk/windows/windowsservercore-ltsc2022/Dockerfile @@ -0,0 +1,56 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2022 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_x64_windows_hotspot_21.0.12_8.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_x64_windows_hotspot_21.0.12_8.msi ; \ + Write-Host ('Verifying sha256 (845a30ebafdb4cbc4aff9c9d65b574a3dd154fbc5ef7f9412cd26628ffa5c22d) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne '845a30ebafdb4cbc4aff9c9d65b574a3dd154fbc5ef7f9412cd26628ffa5c22d') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-21' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'javac --version'; javac --version; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' + +CMD ["jshell"] diff --git a/21/jdk/windows/windowsservercore-ltsc2025/Dockerfile b/21/jdk/windows/windowsservercore-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..77b0f4b7a1a39f13f6bb1cf6b7efa033fc350294 --- /dev/null +++ b/21/jdk/windows/windowsservercore-ltsc2025/Dockerfile @@ -0,0 +1,56 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2025 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_x64_windows_hotspot_21.0.12_8.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_x64_windows_hotspot_21.0.12_8.msi ; \ + Write-Host ('Verifying sha256 (845a30ebafdb4cbc4aff9c9d65b574a3dd154fbc5ef7f9412cd26628ffa5c22d) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne '845a30ebafdb4cbc4aff9c9d65b574a3dd154fbc5ef7f9412cd26628ffa5c22d') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-21' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'javac --version'; javac --version; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' + +CMD ["jshell"] diff --git a/21/jre/alpine/3.21/Dockerfile b/21/jre/alpine/3.21/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cfb523a3596e08c173d6ad3ee59624ff9ad74d0c --- /dev/null +++ b/21/jre/alpine/3.21/Dockerfile @@ -0,0 +1,90 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.21 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='a4f70d2be5c55940dd60b6636643a05125e60e6c3dbc2a8402032b0346744dfa'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_aarch64_alpine-linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='9a7f8712a2741bb14e2452eed2de99f62d02e05617e27d59f1861a0cdad58486'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_x64_alpine-linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/21/jre/alpine/3.21/entrypoint.sh b/21/jre/alpine/3.21/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/21/jre/alpine/3.21/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/21/jre/alpine/3.22/Dockerfile b/21/jre/alpine/3.22/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3e6304b36928487a35339cacd11dd24e744af796 --- /dev/null +++ b/21/jre/alpine/3.22/Dockerfile @@ -0,0 +1,90 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.22 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='a4f70d2be5c55940dd60b6636643a05125e60e6c3dbc2a8402032b0346744dfa'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_aarch64_alpine-linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='9a7f8712a2741bb14e2452eed2de99f62d02e05617e27d59f1861a0cdad58486'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_x64_alpine-linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/21/jre/alpine/3.22/entrypoint.sh b/21/jre/alpine/3.22/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/21/jre/alpine/3.22/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/21/jre/alpine/3.23/Dockerfile b/21/jre/alpine/3.23/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bdaa5a5ae246d0cfdff95e85197168bd884ce908 --- /dev/null +++ b/21/jre/alpine/3.23/Dockerfile @@ -0,0 +1,90 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.23 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='a4f70d2be5c55940dd60b6636643a05125e60e6c3dbc2a8402032b0346744dfa'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_aarch64_alpine-linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='9a7f8712a2741bb14e2452eed2de99f62d02e05617e27d59f1861a0cdad58486'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_x64_alpine-linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/21/jre/alpine/3.23/entrypoint.sh b/21/jre/alpine/3.23/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/21/jre/alpine/3.23/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/21/jre/alpine/3.24/Dockerfile b/21/jre/alpine/3.24/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5a317b73d62e9010825aba5f9e7823ef7b31452e --- /dev/null +++ b/21/jre/alpine/3.24/Dockerfile @@ -0,0 +1,90 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.24 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='a4f70d2be5c55940dd60b6636643a05125e60e6c3dbc2a8402032b0346744dfa'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_aarch64_alpine-linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='9a7f8712a2741bb14e2452eed2de99f62d02e05617e27d59f1861a0cdad58486'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_x64_alpine-linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/21/jre/alpine/3.24/entrypoint.sh b/21/jre/alpine/3.24/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/21/jre/alpine/3.24/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/21/jre/ubi/ubi10-minimal/Dockerfile b/21/jre/ubi/ubi10-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..03dc704cecfaace8c4264b017d5fe0c24f7b10b5 --- /dev/null +++ b/21/jre/ubi/ubi10-minimal/Dockerfile @@ -0,0 +1,99 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi10-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + # Required for gpg in multi-arch-install + gnupg2 \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='5f9c96b656827b9d14ebeda7739e25be554fa6d25669b03847c1df6e869c0679'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_aarch64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='fe1b73886269d589336532c31c0db0d01ac7cd567313cfe3e76f02b37b58c068'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_ppc64le_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='2ec0aecaec755ffa8c7904983f89873e51c28e683de39946ba49496acae8fe96'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_s390x_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='8a379a67c91a3ae61ffb33d46e0a40c7ba35e70713c4db31cfca30492f792eff'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_x64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/21/jre/ubi/ubi10-minimal/entrypoint.sh b/21/jre/ubi/ubi10-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fb2948890a10dda817bec84a42a47cf5cdaf6ba --- /dev/null +++ b/21/jre/ubi/ubi10-minimal/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/21/jre/ubi/ubi9-minimal/Dockerfile b/21/jre/ubi/ubi9-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7f8800d73ac8d5077f0c2f4c0d123fb891153e1b --- /dev/null +++ b/21/jre/ubi/ubi9-minimal/Dockerfile @@ -0,0 +1,97 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi9-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='5f9c96b656827b9d14ebeda7739e25be554fa6d25669b03847c1df6e869c0679'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_aarch64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='fe1b73886269d589336532c31c0db0d01ac7cd567313cfe3e76f02b37b58c068'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_ppc64le_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='2ec0aecaec755ffa8c7904983f89873e51c28e683de39946ba49496acae8fe96'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_s390x_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='8a379a67c91a3ae61ffb33d46e0a40c7ba35e70713c4db31cfca30492f792eff'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_x64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/21/jre/ubi/ubi9-minimal/entrypoint.sh b/21/jre/ubi/ubi9-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fb2948890a10dda817bec84a42a47cf5cdaf6ba --- /dev/null +++ b/21/jre/ubi/ubi9-minimal/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/21/jre/ubuntu/jammy/Dockerfile b/21/jre/ubuntu/jammy/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..37ea7746232eb54e6328cfc4fc8fced99f405b50 --- /dev/null +++ b/21/jre/ubuntu/jammy/Dockerfile @@ -0,0 +1,105 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:22.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='8a379a67c91a3ae61ffb33d46e0a40c7ba35e70713c4db31cfca30492f792eff'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_x64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + arm64) \ + ESUM='5f9c96b656827b9d14ebeda7739e25be554fa6d25669b03847c1df6e869c0679'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_aarch64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='fe1b73886269d589336532c31c0db0d01ac7cd567313cfe3e76f02b37b58c068'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_ppc64le_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='2ec0aecaec755ffa8c7904983f89873e51c28e683de39946ba49496acae8fe96'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_s390x_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/21/jre/ubuntu/jammy/entrypoint.sh b/21/jre/ubuntu/jammy/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/21/jre/ubuntu/jammy/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/21/jre/ubuntu/noble/Dockerfile b/21/jre/ubuntu/noble/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b5ea13a2311d3fc31c83863c1807148f67cd1298 --- /dev/null +++ b/21/jre/ubuntu/noble/Dockerfile @@ -0,0 +1,109 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:24.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='8a379a67c91a3ae61ffb33d46e0a40c7ba35e70713c4db31cfca30492f792eff'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_x64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + arm64) \ + ESUM='5f9c96b656827b9d14ebeda7739e25be554fa6d25669b03847c1df6e869c0679'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_aarch64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='fe1b73886269d589336532c31c0db0d01ac7cd567313cfe3e76f02b37b58c068'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_ppc64le_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + riscv64) \ + ESUM='e1fabd17fd266409221323a754b0a5467a0bdc118b06302646f7b795cd49d95a'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_riscv64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='2ec0aecaec755ffa8c7904983f89873e51c28e683de39946ba49496acae8fe96'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_s390x_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/21/jre/ubuntu/noble/entrypoint.sh b/21/jre/ubuntu/noble/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/21/jre/ubuntu/noble/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/21/jre/ubuntu/resolute/Dockerfile b/21/jre/ubuntu/resolute/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..54cf2c99cfeee37c499a82c8974c989ce7bdd65d --- /dev/null +++ b/21/jre/ubuntu/resolute/Dockerfile @@ -0,0 +1,105 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:26.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='8a379a67c91a3ae61ffb33d46e0a40c7ba35e70713c4db31cfca30492f792eff'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_x64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + arm64) \ + ESUM='5f9c96b656827b9d14ebeda7739e25be554fa6d25669b03847c1df6e869c0679'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_aarch64_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='fe1b73886269d589336532c31c0db0d01ac7cd567313cfe3e76f02b37b58c068'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_ppc64le_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + s390x) \ + ESUM='2ec0aecaec755ffa8c7904983f89873e51c28e683de39946ba49496acae8fe96'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_s390x_linux_hotspot_21.0.12_8.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/21/jre/ubuntu/resolute/entrypoint.sh b/21/jre/ubuntu/resolute/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/21/jre/ubuntu/resolute/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/21/jre/windows/nanoserver-ltsc2022/Dockerfile b/21/jre/windows/nanoserver-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a32d893c0832e359757fe9e69867058fd8551f9c --- /dev/null +++ b/21/jre/windows/nanoserver-ltsc2022/Dockerfile @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-21.0.12+8 + +ENV JAVA_HOME C:\\openjdk-21 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:21.0.12_8-jre-windowsservercore-ltsc2022 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo java --version && java --version \ + && echo Complete. diff --git a/21/jre/windows/nanoserver-ltsc2025/Dockerfile b/21/jre/windows/nanoserver-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0dd683debfcfaf60258e9774aeeef588f287b9d3 --- /dev/null +++ b/21/jre/windows/nanoserver-ltsc2025/Dockerfile @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2025 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-21.0.12+8 + +ENV JAVA_HOME C:\\openjdk-21 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:21.0.12_8-jre-windowsservercore-ltsc2025 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo java --version && java --version \ + && echo Complete. diff --git a/21/jre/windows/windowsservercore-ltsc2022/Dockerfile b/21/jre/windows/windowsservercore-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..03445f87f8f144833f520ca12981f50987542013 --- /dev/null +++ b/21/jre/windows/windowsservercore-ltsc2022/Dockerfile @@ -0,0 +1,53 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2022 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_x64_windows_hotspot_21.0.12_8.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_x64_windows_hotspot_21.0.12_8.msi ; \ + Write-Host ('Verifying sha256 (173bd18e8a9e8100e5588a14c7f54496dc7a3af3bf18f992cd89ab058b45a994) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne '173bd18e8a9e8100e5588a14c7f54496dc7a3af3bf18f992cd89ab058b45a994') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-21' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' diff --git a/21/jre/windows/windowsservercore-ltsc2025/Dockerfile b/21/jre/windows/windowsservercore-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0bc677c6bc78cb5d11185f1b66fcf94836ab6b93 --- /dev/null +++ b/21/jre/windows/windowsservercore-ltsc2025/Dockerfile @@ -0,0 +1,53 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2025 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-21.0.12+8 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_x64_windows_hotspot_21.0.12_8.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jre_x64_windows_hotspot_21.0.12_8.msi ; \ + Write-Host ('Verifying sha256 (173bd18e8a9e8100e5588a14c7f54496dc7a3af3bf18f992cd89ab058b45a994) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne '173bd18e8a9e8100e5588a14c7f54496dc7a3af3bf18f992cd89ab058b45a994') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-21' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' diff --git a/25/jdk/alpine/3.21/Dockerfile b/25/jdk/alpine/3.21/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..96880924cfb5135d8203d73f7ecdb97a583819ee --- /dev/null +++ b/25/jdk/alpine/3.21/Dockerfile @@ -0,0 +1,97 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.21 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='3d1c5c7877e320c2cff8154cfca9af948089912b6efc6123bb21726b7055bc62'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_aarch64_alpine-linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='c6f3e9f975c130169283363bf0ef2fc55f45c36eacc909141ffa7189cd7bdcb7'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_x64_alpine-linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + apk add --no-cache --virtual .fetch-deps gnupg; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + apk del --no-network .fetch-deps; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/25/jdk/alpine/3.21/entrypoint.sh b/25/jdk/alpine/3.21/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/25/jdk/alpine/3.21/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/25/jdk/alpine/3.22/Dockerfile b/25/jdk/alpine/3.22/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e618d4cf364882ddef482fcb49f566df1cb27b45 --- /dev/null +++ b/25/jdk/alpine/3.22/Dockerfile @@ -0,0 +1,97 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.22 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='3d1c5c7877e320c2cff8154cfca9af948089912b6efc6123bb21726b7055bc62'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_aarch64_alpine-linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='c6f3e9f975c130169283363bf0ef2fc55f45c36eacc909141ffa7189cd7bdcb7'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_x64_alpine-linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + apk add --no-cache --virtual .fetch-deps gnupg; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + apk del --no-network .fetch-deps; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/25/jdk/alpine/3.22/entrypoint.sh b/25/jdk/alpine/3.22/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/25/jdk/alpine/3.22/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/25/jdk/alpine/3.23/Dockerfile b/25/jdk/alpine/3.23/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3bd43d7b9c480cbf2c3cf3eadb62e395271f341b --- /dev/null +++ b/25/jdk/alpine/3.23/Dockerfile @@ -0,0 +1,97 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.23 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='3d1c5c7877e320c2cff8154cfca9af948089912b6efc6123bb21726b7055bc62'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_aarch64_alpine-linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='c6f3e9f975c130169283363bf0ef2fc55f45c36eacc909141ffa7189cd7bdcb7'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_x64_alpine-linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + apk add --no-cache --virtual .fetch-deps gnupg; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + apk del --no-network .fetch-deps; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/25/jdk/alpine/3.23/entrypoint.sh b/25/jdk/alpine/3.23/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/25/jdk/alpine/3.23/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/25/jdk/alpine/3.24/Dockerfile b/25/jdk/alpine/3.24/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2b3979dce5cbde37aaf2a1683d26c9c629460683 --- /dev/null +++ b/25/jdk/alpine/3.24/Dockerfile @@ -0,0 +1,97 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.24 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='3d1c5c7877e320c2cff8154cfca9af948089912b6efc6123bb21726b7055bc62'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_aarch64_alpine-linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='c6f3e9f975c130169283363bf0ef2fc55f45c36eacc909141ffa7189cd7bdcb7'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_x64_alpine-linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + apk add --no-cache --virtual .fetch-deps gnupg; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + apk del --no-network .fetch-deps; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/25/jdk/alpine/3.24/entrypoint.sh b/25/jdk/alpine/3.24/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/25/jdk/alpine/3.24/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/25/jdk/ubi/ubi10-minimal/Dockerfile b/25/jdk/ubi/ubi10-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a40b3a5c12431e2c1a5c433eca9e2faf2c887e76 --- /dev/null +++ b/25/jdk/ubi/ubi10-minimal/Dockerfile @@ -0,0 +1,103 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi10-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + # Required for gpg in multi-arch-install + gnupg2 \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='621f7196f0b682fb557da58bec89bd7dfe5419811fe1c0ba75c9cc8432f084c7'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_aarch64_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='6b49f8289c377d4fb79ef54b612d77f969648f6ff862152f73c0be897e7c1ef8'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_ppc64le_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + s390x) \ + ESUM='24f05bf8b13cbb2fd6bdcc02da837725309d7279b5edebafb6b0994dcda262b3'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_s390x_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='e58fcdcd637b25c03ca84cbbcefc70d11efb8f4b4cbd05decc9f661769d77f94'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_x64_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/25/jdk/ubi/ubi10-minimal/entrypoint.sh b/25/jdk/ubi/ubi10-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fb2948890a10dda817bec84a42a47cf5cdaf6ba --- /dev/null +++ b/25/jdk/ubi/ubi10-minimal/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/25/jdk/ubuntu/jammy/Dockerfile b/25/jdk/ubuntu/jammy/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6fd1aba29f82d3b0f925490d86e1e06b938f7857 --- /dev/null +++ b/25/jdk/ubuntu/jammy/Dockerfile @@ -0,0 +1,114 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:22.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='e58fcdcd637b25c03ca84cbbcefc70d11efb8f4b4cbd05decc9f661769d77f94'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_x64_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + arm64) \ + ESUM='621f7196f0b682fb557da58bec89bd7dfe5419811fe1c0ba75c9cc8432f084c7'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_aarch64_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='6b49f8289c377d4fb79ef54b612d77f969648f6ff862152f73c0be897e7c1ef8'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_ppc64le_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + s390x) \ + ESUM='24f05bf8b13cbb2fd6bdcc02da837725309d7279b5edebafb6b0994dcda262b3'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_s390x_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + savedAptMark="$(apt-mark showmanual)"; \ + apt-get update; \ + apt-get install -y --no-install-recommends wget gnupg; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark > /dev/null; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/*; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/25/jdk/ubuntu/jammy/entrypoint.sh b/25/jdk/ubuntu/jammy/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/25/jdk/ubuntu/jammy/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/25/jdk/ubuntu/noble/Dockerfile b/25/jdk/ubuntu/noble/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d1cf1a225542a433086ba96aa174ca5d597ee35d --- /dev/null +++ b/25/jdk/ubuntu/noble/Dockerfile @@ -0,0 +1,118 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:24.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='e58fcdcd637b25c03ca84cbbcefc70d11efb8f4b4cbd05decc9f661769d77f94'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_x64_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + arm64) \ + ESUM='621f7196f0b682fb557da58bec89bd7dfe5419811fe1c0ba75c9cc8432f084c7'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_aarch64_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='6b49f8289c377d4fb79ef54b612d77f969648f6ff862152f73c0be897e7c1ef8'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_ppc64le_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + riscv64) \ + ESUM='c6a70ed1ebe5ff66614f71fa9070e26d5b21587f576a8cb4f818269f4f475191'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_riscv64_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + s390x) \ + ESUM='24f05bf8b13cbb2fd6bdcc02da837725309d7279b5edebafb6b0994dcda262b3'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_s390x_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + savedAptMark="$(apt-mark showmanual)"; \ + apt-get update; \ + apt-get install -y --no-install-recommends wget gnupg; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark > /dev/null; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/*; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/25/jdk/ubuntu/noble/entrypoint.sh b/25/jdk/ubuntu/noble/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/25/jdk/ubuntu/noble/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/25/jdk/ubuntu/resolute/Dockerfile b/25/jdk/ubuntu/resolute/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ebf69e2c663ac027fcb3bc2b89fc2daf5d882113 --- /dev/null +++ b/25/jdk/ubuntu/resolute/Dockerfile @@ -0,0 +1,114 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:26.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='e58fcdcd637b25c03ca84cbbcefc70d11efb8f4b4cbd05decc9f661769d77f94'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_x64_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + arm64) \ + ESUM='621f7196f0b682fb557da58bec89bd7dfe5419811fe1c0ba75c9cc8432f084c7'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_aarch64_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='6b49f8289c377d4fb79ef54b612d77f969648f6ff862152f73c0be897e7c1ef8'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_ppc64le_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + s390x) \ + ESUM='24f05bf8b13cbb2fd6bdcc02da837725309d7279b5edebafb6b0994dcda262b3'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_s390x_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + savedAptMark="$(apt-mark showmanual)"; \ + apt-get update; \ + apt-get install -y --no-install-recommends wget gnupg; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark > /dev/null; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/*; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/25/jdk/ubuntu/resolute/entrypoint.sh b/25/jdk/ubuntu/resolute/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/25/jdk/ubuntu/resolute/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/25/jdk/windows/nanoserver-ltsc2022/Dockerfile b/25/jdk/windows/nanoserver-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c3d68dbe74a8c35a055c67378c5e94fbb99445e3 --- /dev/null +++ b/25/jdk/windows/nanoserver-ltsc2022/Dockerfile @@ -0,0 +1,41 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-25.0.4+7 + +ENV JAVA_HOME C:\\openjdk-25 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:25.0.4_7-jdk-windowsservercore-ltsc2022 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo javac --version && javac --version \ + && echo java --version && java --version \ + && echo Complete. + +CMD ["jshell"] diff --git a/25/jdk/windows/nanoserver-ltsc2025/Dockerfile b/25/jdk/windows/nanoserver-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c3c10d1336a1b9516a93f5aa4d5174f37d41ae75 --- /dev/null +++ b/25/jdk/windows/nanoserver-ltsc2025/Dockerfile @@ -0,0 +1,41 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2025 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-25.0.4+7 + +ENV JAVA_HOME C:\\openjdk-25 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:25.0.4_7-jdk-windowsservercore-ltsc2025 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo javac --version && javac --version \ + && echo java --version && java --version \ + && echo Complete. + +CMD ["jshell"] diff --git a/25/jdk/windows/windowsservercore-ltsc2022/Dockerfile b/25/jdk/windows/windowsservercore-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3cc18aa29aa2a55ddf7bc5573a9cb8eb1f3c6ea3 --- /dev/null +++ b/25/jdk/windows/windowsservercore-ltsc2022/Dockerfile @@ -0,0 +1,56 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2022 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_x64_windows_hotspot_25.0.4_7.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_x64_windows_hotspot_25.0.4_7.msi ; \ + Write-Host ('Verifying sha256 (6e9d08f214b0b284c2d8a58a980761d976c6588145af9e3c75b22fc2982b6636) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne '6e9d08f214b0b284c2d8a58a980761d976c6588145af9e3c75b22fc2982b6636') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-25' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'javac --version'; javac --version; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' + +CMD ["jshell"] diff --git a/25/jdk/windows/windowsservercore-ltsc2025/Dockerfile b/25/jdk/windows/windowsservercore-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..41a5de50581efed6d5c8f7ea441c2d6f8e084065 --- /dev/null +++ b/25/jdk/windows/windowsservercore-ltsc2025/Dockerfile @@ -0,0 +1,56 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2025 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_x64_windows_hotspot_25.0.4_7.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jdk_x64_windows_hotspot_25.0.4_7.msi ; \ + Write-Host ('Verifying sha256 (6e9d08f214b0b284c2d8a58a980761d976c6588145af9e3c75b22fc2982b6636) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne '6e9d08f214b0b284c2d8a58a980761d976c6588145af9e3c75b22fc2982b6636') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-25' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'javac --version'; javac --version; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' + +CMD ["jshell"] diff --git a/25/jre/alpine/3.21/Dockerfile b/25/jre/alpine/3.21/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..76ae9a1aa6836f2b7c60ae66b70027ada0ca18a1 --- /dev/null +++ b/25/jre/alpine/3.21/Dockerfile @@ -0,0 +1,90 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.21 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='c9a48a33d65f308c6066bbfdfc0d4b9143793588a0def79df219760b25bb8b84'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_aarch64_alpine-linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='4a641bfa74e961efd9cc6dbfb6eccf0bec13014904433f00eb33df84c393318f'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_x64_alpine-linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + apk add --no-cache --virtual .fetch-deps gnupg; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + apk del --no-network .fetch-deps; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/25/jre/alpine/3.21/entrypoint.sh b/25/jre/alpine/3.21/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/25/jre/alpine/3.21/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/25/jre/alpine/3.22/Dockerfile b/25/jre/alpine/3.22/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..367ea74d71519ddcb6b209b8c18d167dce24bf22 --- /dev/null +++ b/25/jre/alpine/3.22/Dockerfile @@ -0,0 +1,90 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.22 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='c9a48a33d65f308c6066bbfdfc0d4b9143793588a0def79df219760b25bb8b84'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_aarch64_alpine-linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='4a641bfa74e961efd9cc6dbfb6eccf0bec13014904433f00eb33df84c393318f'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_x64_alpine-linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + apk add --no-cache --virtual .fetch-deps gnupg; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + apk del --no-network .fetch-deps; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/25/jre/alpine/3.22/entrypoint.sh b/25/jre/alpine/3.22/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/25/jre/alpine/3.22/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/25/jre/alpine/3.23/Dockerfile b/25/jre/alpine/3.23/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cead25d061c96319e87ef11b8ef6f12aff03d72a --- /dev/null +++ b/25/jre/alpine/3.23/Dockerfile @@ -0,0 +1,90 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.23 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='c9a48a33d65f308c6066bbfdfc0d4b9143793588a0def79df219760b25bb8b84'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_aarch64_alpine-linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='4a641bfa74e961efd9cc6dbfb6eccf0bec13014904433f00eb33df84c393318f'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_x64_alpine-linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + apk add --no-cache --virtual .fetch-deps gnupg; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + apk del --no-network .fetch-deps; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/25/jre/alpine/3.23/entrypoint.sh b/25/jre/alpine/3.23/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/25/jre/alpine/3.23/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/25/jre/alpine/3.24/Dockerfile b/25/jre/alpine/3.24/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a92eb5b33ca8087b0b7254031ecae4b8b7eabdeb --- /dev/null +++ b/25/jre/alpine/3.24/Dockerfile @@ -0,0 +1,90 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.24 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='c9a48a33d65f308c6066bbfdfc0d4b9143793588a0def79df219760b25bb8b84'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_aarch64_alpine-linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='4a641bfa74e961efd9cc6dbfb6eccf0bec13014904433f00eb33df84c393318f'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_x64_alpine-linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + apk add --no-cache --virtual .fetch-deps gnupg; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + apk del --no-network .fetch-deps; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/25/jre/alpine/3.24/entrypoint.sh b/25/jre/alpine/3.24/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/25/jre/alpine/3.24/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/25/jre/ubi/ubi10-minimal/Dockerfile b/25/jre/ubi/ubi10-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e505315058fb0d21eb3b4b2326027f68206dc1df --- /dev/null +++ b/25/jre/ubi/ubi10-minimal/Dockerfile @@ -0,0 +1,99 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi10-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + # Required for gpg in multi-arch-install + gnupg2 \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='1f2644427000316bc431df3389504551ed7464fe8486bf6b4f1130af9ffc8f55'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_aarch64_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='7c4235dc156e85d4e8b7b12075d7d72265fa49b73af2d0453d118a4786176476'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_ppc64le_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + s390x) \ + ESUM='7698a64e995bf41cb2620bea225b6383e66a8b76a0b97ea04db89e300c470ed8'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_s390x_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='aed3915f8facc0c80733ab2448bb0df4b494a36a2c5759e9a6e1eb979720f2b3'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_x64_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/25/jre/ubi/ubi10-minimal/entrypoint.sh b/25/jre/ubi/ubi10-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fb2948890a10dda817bec84a42a47cf5cdaf6ba --- /dev/null +++ b/25/jre/ubi/ubi10-minimal/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/25/jre/ubuntu/jammy/Dockerfile b/25/jre/ubuntu/jammy/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b2511bebbf26134c5a4293a6aad0ec42caaaf414 --- /dev/null +++ b/25/jre/ubuntu/jammy/Dockerfile @@ -0,0 +1,107 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:22.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='aed3915f8facc0c80733ab2448bb0df4b494a36a2c5759e9a6e1eb979720f2b3'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_x64_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + arm64) \ + ESUM='1f2644427000316bc431df3389504551ed7464fe8486bf6b4f1130af9ffc8f55'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_aarch64_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='7c4235dc156e85d4e8b7b12075d7d72265fa49b73af2d0453d118a4786176476'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_ppc64le_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + s390x) \ + ESUM='7698a64e995bf41cb2620bea225b6383e66a8b76a0b97ea04db89e300c470ed8'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_s390x_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + savedAptMark="$(apt-mark showmanual)"; \ + apt-get update; \ + apt-get install -y --no-install-recommends wget gnupg; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark > /dev/null; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/*; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/25/jre/ubuntu/jammy/entrypoint.sh b/25/jre/ubuntu/jammy/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/25/jre/ubuntu/jammy/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/25/jre/ubuntu/noble/Dockerfile b/25/jre/ubuntu/noble/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..781b250377cd2c15ed2b8864020b277250fd35f9 --- /dev/null +++ b/25/jre/ubuntu/noble/Dockerfile @@ -0,0 +1,111 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:24.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='aed3915f8facc0c80733ab2448bb0df4b494a36a2c5759e9a6e1eb979720f2b3'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_x64_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + arm64) \ + ESUM='1f2644427000316bc431df3389504551ed7464fe8486bf6b4f1130af9ffc8f55'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_aarch64_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='7c4235dc156e85d4e8b7b12075d7d72265fa49b73af2d0453d118a4786176476'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_ppc64le_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + riscv64) \ + ESUM='ee3e62f50e2bdd5b65f9f8937b33d862846d0245bc1be0dd8e3a99ea10fce32a'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_riscv64_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + s390x) \ + ESUM='7698a64e995bf41cb2620bea225b6383e66a8b76a0b97ea04db89e300c470ed8'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_s390x_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + savedAptMark="$(apt-mark showmanual)"; \ + apt-get update; \ + apt-get install -y --no-install-recommends wget gnupg; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark > /dev/null; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/*; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/25/jre/ubuntu/noble/entrypoint.sh b/25/jre/ubuntu/noble/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/25/jre/ubuntu/noble/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/25/jre/ubuntu/resolute/Dockerfile b/25/jre/ubuntu/resolute/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..729e5ea49eec9c21a246b8f23ceca547fec1c017 --- /dev/null +++ b/25/jre/ubuntu/resolute/Dockerfile @@ -0,0 +1,107 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:26.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='aed3915f8facc0c80733ab2448bb0df4b494a36a2c5759e9a6e1eb979720f2b3'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_x64_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + arm64) \ + ESUM='1f2644427000316bc431df3389504551ed7464fe8486bf6b4f1130af9ffc8f55'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_aarch64_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='7c4235dc156e85d4e8b7b12075d7d72265fa49b73af2d0453d118a4786176476'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_ppc64le_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + s390x) \ + ESUM='7698a64e995bf41cb2620bea225b6383e66a8b76a0b97ea04db89e300c470ed8'; \ + BINARY_URL='https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_s390x_linux_hotspot_25.0.4_7.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + savedAptMark="$(apt-mark showmanual)"; \ + apt-get update; \ + apt-get install -y --no-install-recommends wget gnupg; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark > /dev/null; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/*; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/25/jre/ubuntu/resolute/entrypoint.sh b/25/jre/ubuntu/resolute/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/25/jre/ubuntu/resolute/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/25/jre/windows/nanoserver-ltsc2022/Dockerfile b/25/jre/windows/nanoserver-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2399fc32910a615fe480962ce1d2776e0a6fa536 --- /dev/null +++ b/25/jre/windows/nanoserver-ltsc2022/Dockerfile @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-25.0.4+7 + +ENV JAVA_HOME C:\\openjdk-25 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:25.0.4_7-jre-windowsservercore-ltsc2022 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo java --version && java --version \ + && echo Complete. diff --git a/25/jre/windows/nanoserver-ltsc2025/Dockerfile b/25/jre/windows/nanoserver-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..63366f93cf3337d5aecee21b245de89fb9651448 --- /dev/null +++ b/25/jre/windows/nanoserver-ltsc2025/Dockerfile @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2025 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-25.0.4+7 + +ENV JAVA_HOME C:\\openjdk-25 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:25.0.4_7-jre-windowsservercore-ltsc2025 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo java --version && java --version \ + && echo Complete. diff --git a/25/jre/windows/windowsservercore-ltsc2022/Dockerfile b/25/jre/windows/windowsservercore-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a0b0f77d8a5202800234bc8f38ca42695fdddff3 --- /dev/null +++ b/25/jre/windows/windowsservercore-ltsc2022/Dockerfile @@ -0,0 +1,53 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2022 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_x64_windows_hotspot_25.0.4_7.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_x64_windows_hotspot_25.0.4_7.msi ; \ + Write-Host ('Verifying sha256 (a0c56fbe62dd18a7da032c1e41fd1da027530ebd472e61b5ae64581ebdcfebc8) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne 'a0c56fbe62dd18a7da032c1e41fd1da027530ebd472e61b5ae64581ebdcfebc8') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-25' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' diff --git a/25/jre/windows/windowsservercore-ltsc2025/Dockerfile b/25/jre/windows/windowsservercore-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..29d5ec35638a98b0636e57a91bdc194518cce62f --- /dev/null +++ b/25/jre/windows/windowsservercore-ltsc2025/Dockerfile @@ -0,0 +1,53 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2025 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-25.0.4+7 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_x64_windows_hotspot_25.0.4_7.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.4%2B7/OpenJDK25U-jre_x64_windows_hotspot_25.0.4_7.msi ; \ + Write-Host ('Verifying sha256 (a0c56fbe62dd18a7da032c1e41fd1da027530ebd472e61b5ae64581ebdcfebc8) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne 'a0c56fbe62dd18a7da032c1e41fd1da027530ebd472e61b5ae64581ebdcfebc8') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-25' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' diff --git a/26/jdk/alpine/3.23/Dockerfile b/26/jdk/alpine/3.23/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f96b5b33838798cd21d143ac0a7f3e15c6029b60 --- /dev/null +++ b/26/jdk/alpine/3.23/Dockerfile @@ -0,0 +1,97 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.23 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-26.0.2+10 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='bee481d4ba078ac1aaa741541bb0b99de876d679ccc80f9685710b72bc7b04f1'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_aarch64_alpine-linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='88caf27ab9f2a15a52a114ea18fa20c518ccc325b5ba4bb5fd6c42c56b581498'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_x64_alpine-linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + apk add --no-cache --virtual .fetch-deps gnupg; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + apk del --no-network .fetch-deps; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/26/jdk/alpine/3.23/entrypoint.sh b/26/jdk/alpine/3.23/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/26/jdk/alpine/3.23/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/26/jdk/alpine/3.24/Dockerfile b/26/jdk/alpine/3.24/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6e07ba14d16e99cae0e4124105e371b1e6d936b2 --- /dev/null +++ b/26/jdk/alpine/3.24/Dockerfile @@ -0,0 +1,97 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.24 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-26.0.2+10 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='bee481d4ba078ac1aaa741541bb0b99de876d679ccc80f9685710b72bc7b04f1'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_aarch64_alpine-linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='88caf27ab9f2a15a52a114ea18fa20c518ccc325b5ba4bb5fd6c42c56b581498'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_x64_alpine-linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + apk add --no-cache --virtual .fetch-deps gnupg; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + apk del --no-network .fetch-deps; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/26/jdk/alpine/3.24/entrypoint.sh b/26/jdk/alpine/3.24/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/26/jdk/alpine/3.24/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/26/jdk/ubi/ubi10-minimal/Dockerfile b/26/jdk/ubi/ubi10-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..23ad4057fcf286283d2ce7027171f63f695526b7 --- /dev/null +++ b/26/jdk/ubi/ubi10-minimal/Dockerfile @@ -0,0 +1,103 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi10-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + # Required for gpg in multi-arch-install + gnupg2 \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk-26.0.2+10 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='f82aeb1d5b0ddb93d3bd81c20948bc560c0758993157202424c17e805e2effbb'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_aarch64_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='54e5f3a1eaa48650f30a8f189843a96654f5e31db4f0a8495c71adc4ca8f896a'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_ppc64le_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + s390x) \ + ESUM='4cac19ce8091df128261c42886a2e0357de7deecfe3f60b39bca16ccb55703e2'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_s390x_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='56f768372f6ca1e2eb4c5f46b78f627949e8dcfe9c9723926cf45a45faf35802'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_x64_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/26/jdk/ubi/ubi10-minimal/entrypoint.sh b/26/jdk/ubi/ubi10-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fb2948890a10dda817bec84a42a47cf5cdaf6ba --- /dev/null +++ b/26/jdk/ubi/ubi10-minimal/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/26/jdk/ubuntu/jammy/Dockerfile b/26/jdk/ubuntu/jammy/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6bff24478276118a05ca6dace4998ed319709f58 --- /dev/null +++ b/26/jdk/ubuntu/jammy/Dockerfile @@ -0,0 +1,114 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:22.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-26.0.2+10 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='56f768372f6ca1e2eb4c5f46b78f627949e8dcfe9c9723926cf45a45faf35802'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_x64_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + arm64) \ + ESUM='f82aeb1d5b0ddb93d3bd81c20948bc560c0758993157202424c17e805e2effbb'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_aarch64_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='54e5f3a1eaa48650f30a8f189843a96654f5e31db4f0a8495c71adc4ca8f896a'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_ppc64le_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + s390x) \ + ESUM='4cac19ce8091df128261c42886a2e0357de7deecfe3f60b39bca16ccb55703e2'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_s390x_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + savedAptMark="$(apt-mark showmanual)"; \ + apt-get update; \ + apt-get install -y --no-install-recommends wget gnupg; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark > /dev/null; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/*; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/26/jdk/ubuntu/jammy/entrypoint.sh b/26/jdk/ubuntu/jammy/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/26/jdk/ubuntu/jammy/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/26/jdk/ubuntu/noble/Dockerfile b/26/jdk/ubuntu/noble/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6e9601b0defbb1c67339c265ec296dc73b22117b --- /dev/null +++ b/26/jdk/ubuntu/noble/Dockerfile @@ -0,0 +1,118 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:24.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-26.0.2+10 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='56f768372f6ca1e2eb4c5f46b78f627949e8dcfe9c9723926cf45a45faf35802'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_x64_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + arm64) \ + ESUM='f82aeb1d5b0ddb93d3bd81c20948bc560c0758993157202424c17e805e2effbb'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_aarch64_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='54e5f3a1eaa48650f30a8f189843a96654f5e31db4f0a8495c71adc4ca8f896a'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_ppc64le_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + riscv64) \ + ESUM='b247d7cb807d6b2be85c7e7bd2ba2c968cf7cbe2533a63689276c03ce51dc8d4'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_riscv64_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + s390x) \ + ESUM='4cac19ce8091df128261c42886a2e0357de7deecfe3f60b39bca16ccb55703e2'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_s390x_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + savedAptMark="$(apt-mark showmanual)"; \ + apt-get update; \ + apt-get install -y --no-install-recommends wget gnupg; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark > /dev/null; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/*; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/26/jdk/ubuntu/noble/entrypoint.sh b/26/jdk/ubuntu/noble/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/26/jdk/ubuntu/noble/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/26/jdk/ubuntu/resolute/Dockerfile b/26/jdk/ubuntu/resolute/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a931fc82f3996401fecfae8ea49383ae69ec1395 --- /dev/null +++ b/26/jdk/ubuntu/resolute/Dockerfile @@ -0,0 +1,114 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:26.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-26.0.2+10 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='56f768372f6ca1e2eb4c5f46b78f627949e8dcfe9c9723926cf45a45faf35802'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_x64_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + arm64) \ + ESUM='f82aeb1d5b0ddb93d3bd81c20948bc560c0758993157202424c17e805e2effbb'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_aarch64_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='54e5f3a1eaa48650f30a8f189843a96654f5e31db4f0a8495c71adc4ca8f896a'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_ppc64le_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + s390x) \ + ESUM='4cac19ce8091df128261c42886a2e0357de7deecfe3f60b39bca16ccb55703e2'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_s390x_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + savedAptMark="$(apt-mark showmanual)"; \ + apt-get update; \ + apt-get install -y --no-install-recommends wget gnupg; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark > /dev/null; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/*; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + echo "javac --version"; javac --version; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] + +CMD ["jshell"] diff --git a/26/jdk/ubuntu/resolute/entrypoint.sh b/26/jdk/ubuntu/resolute/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/26/jdk/ubuntu/resolute/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/26/jdk/windows/nanoserver-ltsc2022/Dockerfile b/26/jdk/windows/nanoserver-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1c1e44dfd1fde1334347ec10b5457fabb7c5e130 --- /dev/null +++ b/26/jdk/windows/nanoserver-ltsc2022/Dockerfile @@ -0,0 +1,41 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-26.0.2+10 + +ENV JAVA_HOME C:\\openjdk-26 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:26.0.2_10-jdk-windowsservercore-ltsc2022 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo javac --version && javac --version \ + && echo java --version && java --version \ + && echo Complete. + +CMD ["jshell"] diff --git a/26/jdk/windows/nanoserver-ltsc2025/Dockerfile b/26/jdk/windows/nanoserver-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1f7f4d3f9aebd65bc9821f69a646aba912a81962 --- /dev/null +++ b/26/jdk/windows/nanoserver-ltsc2025/Dockerfile @@ -0,0 +1,41 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2025 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-26.0.2+10 + +ENV JAVA_HOME C:\\openjdk-26 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:26.0.2_10-jdk-windowsservercore-ltsc2025 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo javac --version && javac --version \ + && echo java --version && java --version \ + && echo Complete. + +CMD ["jshell"] diff --git a/26/jdk/windows/windowsservercore-ltsc2022/Dockerfile b/26/jdk/windows/windowsservercore-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e4f5882333a143078ac4d90efe20049727d10267 --- /dev/null +++ b/26/jdk/windows/windowsservercore-ltsc2022/Dockerfile @@ -0,0 +1,56 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2022 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-26.0.2+10 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_x64_windows_hotspot_26.0.2_10.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_x64_windows_hotspot_26.0.2_10.msi ; \ + Write-Host ('Verifying sha256 (80ca3c0874a4287c007f99ebaa5ea0e9ef73166c9b2a850009aa1e0b62648e57) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne '80ca3c0874a4287c007f99ebaa5ea0e9ef73166c9b2a850009aa1e0b62648e57') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-26' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'javac --version'; javac --version; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' + +CMD ["jshell"] diff --git a/26/jdk/windows/windowsservercore-ltsc2025/Dockerfile b/26/jdk/windows/windowsservercore-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e95ced75ac6b1f8dee9445b3d622993d2dec048d --- /dev/null +++ b/26/jdk/windows/windowsservercore-ltsc2025/Dockerfile @@ -0,0 +1,56 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2025 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-26.0.2+10 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_x64_windows_hotspot_26.0.2_10.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jdk_x64_windows_hotspot_26.0.2_10.msi ; \ + Write-Host ('Verifying sha256 (80ca3c0874a4287c007f99ebaa5ea0e9ef73166c9b2a850009aa1e0b62648e57) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne '80ca3c0874a4287c007f99ebaa5ea0e9ef73166c9b2a850009aa1e0b62648e57') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-26' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'javac --version'; javac --version; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' + +CMD ["jshell"] diff --git a/26/jre/alpine/3.23/Dockerfile b/26/jre/alpine/3.23/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..18ea9aa422ec2b27d9cabddbcd29eb8b980d1cd3 --- /dev/null +++ b/26/jre/alpine/3.23/Dockerfile @@ -0,0 +1,90 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.23 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-26.0.2+10 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='700193f55adf1f5c65aba6276e003edd97f7e1b5c6693718afffe7c82ad004cc'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_aarch64_alpine-linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='fcfa7c2b3502fd8bd256c75320655c50b7114efa0f4931ad3ba8fcbb331fe18c'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_x64_alpine-linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + apk add --no-cache --virtual .fetch-deps gnupg; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + apk del --no-network .fetch-deps; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/26/jre/alpine/3.23/entrypoint.sh b/26/jre/alpine/3.23/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/26/jre/alpine/3.23/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/26/jre/alpine/3.24/Dockerfile b/26/jre/alpine/3.24/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f8f5ea4cf64849a6de033922a75783f4955e08ca --- /dev/null +++ b/26/jre/alpine/3.24/Dockerfile @@ -0,0 +1,90 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.24 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk-26.0.2+10 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='700193f55adf1f5c65aba6276e003edd97f7e1b5c6693718afffe7c82ad004cc'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_aarch64_alpine-linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='fcfa7c2b3502fd8bd256c75320655c50b7114efa0f4931ad3ba8fcbb331fe18c'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_x64_alpine-linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + apk add --no-cache --virtual .fetch-deps gnupg; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + apk del --no-network .fetch-deps; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/26/jre/alpine/3.24/entrypoint.sh b/26/jre/alpine/3.24/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a4fe87a49e8f419524c080ee364491cab8cc3f --- /dev/null +++ b/26/jre/alpine/3.24/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/26/jre/ubi/ubi10-minimal/Dockerfile b/26/jre/ubi/ubi10-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b4e132ec5cb079ea06d65a5f4db7ee9e17c38114 --- /dev/null +++ b/26/jre/ubi/ubi10-minimal/Dockerfile @@ -0,0 +1,99 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi10-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + # Required for gpg in multi-arch-install + gnupg2 \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk-26.0.2+10 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='3c689572d2ea7aa3e19db5e5bc4ee41e90b557593d15eefcec179a9b8abfff0e'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_aarch64_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='8698a0734da25b9edc552eb80e9db8e69583afbcecbfda291c9f23bac4062f17'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_ppc64le_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + s390x) \ + ESUM='5803ccac6551ec18aada9ab58a55d7fa3b82f5e698dfd32f8ed16f5dd4b5255e'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_s390x_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='585c4cce5807ce5677289a123680a8648c84c9afac66727a0e3027298d8e32c7'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_x64_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/26/jre/ubi/ubi10-minimal/entrypoint.sh b/26/jre/ubi/ubi10-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fb2948890a10dda817bec84a42a47cf5cdaf6ba --- /dev/null +++ b/26/jre/ubi/ubi10-minimal/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/26/jre/ubuntu/jammy/Dockerfile b/26/jre/ubuntu/jammy/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6376c7fdd8a7ab9710ba9321cd131368fcf11ffa --- /dev/null +++ b/26/jre/ubuntu/jammy/Dockerfile @@ -0,0 +1,107 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:22.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-26.0.2+10 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='585c4cce5807ce5677289a123680a8648c84c9afac66727a0e3027298d8e32c7'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_x64_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + arm64) \ + ESUM='3c689572d2ea7aa3e19db5e5bc4ee41e90b557593d15eefcec179a9b8abfff0e'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_aarch64_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='8698a0734da25b9edc552eb80e9db8e69583afbcecbfda291c9f23bac4062f17'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_ppc64le_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + s390x) \ + ESUM='5803ccac6551ec18aada9ab58a55d7fa3b82f5e698dfd32f8ed16f5dd4b5255e'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_s390x_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + savedAptMark="$(apt-mark showmanual)"; \ + apt-get update; \ + apt-get install -y --no-install-recommends wget gnupg; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark > /dev/null; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/*; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/26/jre/ubuntu/jammy/entrypoint.sh b/26/jre/ubuntu/jammy/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/26/jre/ubuntu/jammy/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/26/jre/ubuntu/noble/Dockerfile b/26/jre/ubuntu/noble/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..616a7570ad587ba2e467766b42bf77bda2be5de9 --- /dev/null +++ b/26/jre/ubuntu/noble/Dockerfile @@ -0,0 +1,111 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:24.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-26.0.2+10 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='585c4cce5807ce5677289a123680a8648c84c9afac66727a0e3027298d8e32c7'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_x64_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + arm64) \ + ESUM='3c689572d2ea7aa3e19db5e5bc4ee41e90b557593d15eefcec179a9b8abfff0e'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_aarch64_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='8698a0734da25b9edc552eb80e9db8e69583afbcecbfda291c9f23bac4062f17'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_ppc64le_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + riscv64) \ + ESUM='781e70f2ae6c82a99d09cd2beeed55fc9f87f9ec998c12fc1bee7378c01d3fbe'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_riscv64_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + s390x) \ + ESUM='5803ccac6551ec18aada9ab58a55d7fa3b82f5e698dfd32f8ed16f5dd4b5255e'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_s390x_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + savedAptMark="$(apt-mark showmanual)"; \ + apt-get update; \ + apt-get install -y --no-install-recommends wget gnupg; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark > /dev/null; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/*; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/26/jre/ubuntu/noble/entrypoint.sh b/26/jre/ubuntu/noble/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/26/jre/ubuntu/noble/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/26/jre/ubuntu/resolute/Dockerfile b/26/jre/ubuntu/resolute/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..22d6769abc73cdee1a5d4932d039f53d51087fba --- /dev/null +++ b/26/jre/ubuntu/resolute/Dockerfile @@ -0,0 +1,107 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:26.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk-26.0.2+10 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='585c4cce5807ce5677289a123680a8648c84c9afac66727a0e3027298d8e32c7'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_x64_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + arm64) \ + ESUM='3c689572d2ea7aa3e19db5e5bc4ee41e90b557593d15eefcec179a9b8abfff0e'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_aarch64_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='8698a0734da25b9edc552eb80e9db8e69583afbcecbfda291c9f23bac4062f17'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_ppc64le_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + s390x) \ + ESUM='5803ccac6551ec18aada9ab58a55d7fa3b82f5e698dfd32f8ed16f5dd4b5255e'; \ + BINARY_URL='https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_s390x_linux_hotspot_26.0.2_10.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + savedAptMark="$(apt-mark showmanual)"; \ + apt-get update; \ + apt-get install -y --no-install-recommends wget gnupg; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark > /dev/null; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/*; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java --version"; java --version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/26/jre/ubuntu/resolute/entrypoint.sh b/26/jre/ubuntu/resolute/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0446a8f809b413f961c4828e06ce9bbbe6d7241 --- /dev/null +++ b/26/jre/ubuntu/resolute/entrypoint.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -cacerts "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/26/jre/windows/nanoserver-ltsc2022/Dockerfile b/26/jre/windows/nanoserver-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a773a057adefd7a47c74ffd687ebbf733a41709e --- /dev/null +++ b/26/jre/windows/nanoserver-ltsc2022/Dockerfile @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-26.0.2+10 + +ENV JAVA_HOME C:\\openjdk-26 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:26.0.2_10-jre-windowsservercore-ltsc2022 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo java --version && java --version \ + && echo Complete. diff --git a/26/jre/windows/nanoserver-ltsc2025/Dockerfile b/26/jre/windows/nanoserver-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..09807cee4457c3718aaf5ffc0ddc5df4018f1282 --- /dev/null +++ b/26/jre/windows/nanoserver-ltsc2025/Dockerfile @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2025 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk-26.0.2+10 + +ENV JAVA_HOME C:\\openjdk-26 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:26.0.2_10-jre-windowsservercore-ltsc2025 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo java --version && java --version \ + && echo Complete. diff --git a/26/jre/windows/windowsservercore-ltsc2022/Dockerfile b/26/jre/windows/windowsservercore-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..54252ee72d1f57528b48ef1d8c34ce5469471243 --- /dev/null +++ b/26/jre/windows/windowsservercore-ltsc2022/Dockerfile @@ -0,0 +1,53 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2022 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-26.0.2+10 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_x64_windows_hotspot_26.0.2_10.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_x64_windows_hotspot_26.0.2_10.msi ; \ + Write-Host ('Verifying sha256 (b35b3ded4429c10442e7809bf38b0000fc58d944b08e354c872938d638de4ee6) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne 'b35b3ded4429c10442e7809bf38b0000fc58d944b08e354c872938d638de4ee6') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-26' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' diff --git a/26/jre/windows/windowsservercore-ltsc2025/Dockerfile b/26/jre/windows/windowsservercore-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..95a14af0698526ef6d15c29ab8b5947471b5fe88 --- /dev/null +++ b/26/jre/windows/windowsservercore-ltsc2025/Dockerfile @@ -0,0 +1,53 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2025 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk-26.0.2+10 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_x64_windows_hotspot_26.0.2_10.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin26-binaries/releases/download/jdk-26.0.2%2B10/OpenJDK26U-jre_x64_windows_hotspot_26.0.2_10.msi ; \ + Write-Host ('Verifying sha256 (b35b3ded4429c10442e7809bf38b0000fc58d944b08e354c872938d638de4ee6) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne 'b35b3ded4429c10442e7809bf38b0000fc58d944b08e354c872938d638de4ee6') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-26' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'java --version'; java --version; \ + \ + Write-Host 'Complete.' diff --git a/8/jdk/alpine/3.21/Dockerfile b/8/jdk/alpine/3.21/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..07999128bb7dda556bab2c4ca8dedae1e2f28d83 --- /dev/null +++ b/8/jdk/alpine/3.21/Dockerfile @@ -0,0 +1,87 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.21 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='746bc5577ca2067bf2a96a0ae0f6cf50422f9cb7b5aa58a52e9fceabff5d0619'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_x64_alpine-linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "javac -version"; javac -version; \ + echo "java -version"; java -version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/8/jdk/alpine/3.21/entrypoint.sh b/8/jdk/alpine/3.21/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..6c705501ac42d5b7917bd3f2826d891368d4353d --- /dev/null +++ b/8/jdk/alpine/3.21/entrypoint.sh @@ -0,0 +1,152 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +# JDK8 puts its JRE in a subdirectory +JRE_CACERTS_PATH=$JAVA_HOME/jre/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/8/jdk/alpine/3.22/Dockerfile b/8/jdk/alpine/3.22/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b25d74c31bf947b93d07b72563043aa35a0dbbd5 --- /dev/null +++ b/8/jdk/alpine/3.22/Dockerfile @@ -0,0 +1,87 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.22 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='746bc5577ca2067bf2a96a0ae0f6cf50422f9cb7b5aa58a52e9fceabff5d0619'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_x64_alpine-linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "javac -version"; javac -version; \ + echo "java -version"; java -version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/8/jdk/alpine/3.22/entrypoint.sh b/8/jdk/alpine/3.22/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..6c705501ac42d5b7917bd3f2826d891368d4353d --- /dev/null +++ b/8/jdk/alpine/3.22/entrypoint.sh @@ -0,0 +1,152 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +# JDK8 puts its JRE in a subdirectory +JRE_CACERTS_PATH=$JAVA_HOME/jre/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/8/jdk/alpine/3.23/Dockerfile b/8/jdk/alpine/3.23/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e8ec8cc599365744c926f818027bc30d3bccab18 --- /dev/null +++ b/8/jdk/alpine/3.23/Dockerfile @@ -0,0 +1,87 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.23 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='746bc5577ca2067bf2a96a0ae0f6cf50422f9cb7b5aa58a52e9fceabff5d0619'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_x64_alpine-linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "javac -version"; javac -version; \ + echo "java -version"; java -version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/8/jdk/alpine/3.23/entrypoint.sh b/8/jdk/alpine/3.23/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..6c705501ac42d5b7917bd3f2826d891368d4353d --- /dev/null +++ b/8/jdk/alpine/3.23/entrypoint.sh @@ -0,0 +1,152 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +# JDK8 puts its JRE in a subdirectory +JRE_CACERTS_PATH=$JAVA_HOME/jre/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/8/jdk/alpine/3.24/Dockerfile b/8/jdk/alpine/3.24/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3cc0e34483bf1259e068635eb7017e58793d9202 --- /dev/null +++ b/8/jdk/alpine/3.24/Dockerfile @@ -0,0 +1,87 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.24 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='746bc5577ca2067bf2a96a0ae0f6cf50422f9cb7b5aa58a52e9fceabff5d0619'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_x64_alpine-linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "javac -version"; javac -version; \ + echo "java -version"; java -version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/8/jdk/alpine/3.24/entrypoint.sh b/8/jdk/alpine/3.24/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..6c705501ac42d5b7917bd3f2826d891368d4353d --- /dev/null +++ b/8/jdk/alpine/3.24/entrypoint.sh @@ -0,0 +1,152 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +# JDK8 puts its JRE in a subdirectory +JRE_CACERTS_PATH=$JAVA_HOME/jre/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/8/jdk/ubi/ubi10-minimal/Dockerfile b/8/jdk/ubi/ubi10-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1876ed2643dad70736d32bc6a8f267cdc8c7112a --- /dev/null +++ b/8/jdk/ubi/ubi10-minimal/Dockerfile @@ -0,0 +1,96 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi10-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + # Required for gpg in multi-arch-install + gnupg2 \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='34912db17786f7144dab274f040a42028e25da6e7a6a09780d7013339a56bdb2'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_aarch64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='626e870f411d01d6541fafa11e64b8584d8b737195cec5576256e6d3d34a62ba'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_ppc64le_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='b8f5440f64f50193c01f67dacba55c9660caffe13b908baf6bd1955f4dd4c3ea'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_x64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "javac -version"; javac -version; \ + echo "java -version"; java -version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/8/jdk/ubi/ubi10-minimal/entrypoint.sh b/8/jdk/ubi/ubi10-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..905d997c230b463078851b19bfda953a839a3035 --- /dev/null +++ b/8/jdk/ubi/ubi10-minimal/entrypoint.sh @@ -0,0 +1,152 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +# JDK8 puts its JRE in a subdirectory +JRE_CACERTS_PATH=$JAVA_HOME/jre/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/8/jdk/ubi/ubi9-minimal/Dockerfile b/8/jdk/ubi/ubi9-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7a0dff53bb6b5a86b0531b8071e44fdea1351c66 --- /dev/null +++ b/8/jdk/ubi/ubi9-minimal/Dockerfile @@ -0,0 +1,94 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi9-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='34912db17786f7144dab274f040a42028e25da6e7a6a09780d7013339a56bdb2'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_aarch64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='626e870f411d01d6541fafa11e64b8584d8b737195cec5576256e6d3d34a62ba'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_ppc64le_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='b8f5440f64f50193c01f67dacba55c9660caffe13b908baf6bd1955f4dd4c3ea'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_x64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/src.zip; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "javac -version"; javac -version; \ + echo "java -version"; java -version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/8/jdk/ubi/ubi9-minimal/entrypoint.sh b/8/jdk/ubi/ubi9-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..905d997c230b463078851b19bfda953a839a3035 --- /dev/null +++ b/8/jdk/ubi/ubi9-minimal/entrypoint.sh @@ -0,0 +1,152 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +# JDK8 puts its JRE in a subdirectory +JRE_CACERTS_PATH=$JAVA_HOME/jre/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/8/jdk/ubuntu/jammy/Dockerfile b/8/jdk/ubuntu/jammy/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..587992a5d6885a2391c71115dfb4be07532843be --- /dev/null +++ b/8/jdk/ubuntu/jammy/Dockerfile @@ -0,0 +1,99 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:22.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='b8f5440f64f50193c01f67dacba55c9660caffe13b908baf6bd1955f4dd4c3ea'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_x64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + arm64) \ + ESUM='34912db17786f7144dab274f040a42028e25da6e7a6a09780d7013339a56bdb2'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_aarch64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='626e870f411d01d6541fafa11e64b8584d8b737195cec5576256e6d3d34a62ba'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_ppc64le_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/src.zip; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "javac -version"; javac -version; \ + echo "java -version"; java -version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/8/jdk/ubuntu/jammy/entrypoint.sh b/8/jdk/ubuntu/jammy/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..92d736ad1394f57a4e7b4c7bd1c8639ba2a04c78 --- /dev/null +++ b/8/jdk/ubuntu/jammy/entrypoint.sh @@ -0,0 +1,152 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +# JDK8 puts its JRE in a subdirectory +JRE_CACERTS_PATH=$JAVA_HOME/jre/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/8/jdk/ubuntu/noble/Dockerfile b/8/jdk/ubuntu/noble/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..65a8417c5e24efaef255dd82f9e2cdc9602a455d --- /dev/null +++ b/8/jdk/ubuntu/noble/Dockerfile @@ -0,0 +1,99 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:24.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='b8f5440f64f50193c01f67dacba55c9660caffe13b908baf6bd1955f4dd4c3ea'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_x64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + arm64) \ + ESUM='34912db17786f7144dab274f040a42028e25da6e7a6a09780d7013339a56bdb2'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_aarch64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='626e870f411d01d6541fafa11e64b8584d8b737195cec5576256e6d3d34a62ba'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_ppc64le_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/src.zip; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "javac -version"; javac -version; \ + echo "java -version"; java -version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/8/jdk/ubuntu/noble/entrypoint.sh b/8/jdk/ubuntu/noble/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..92d736ad1394f57a4e7b4c7bd1c8639ba2a04c78 --- /dev/null +++ b/8/jdk/ubuntu/noble/entrypoint.sh @@ -0,0 +1,152 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +# JDK8 puts its JRE in a subdirectory +JRE_CACERTS_PATH=$JAVA_HOME/jre/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/8/jdk/ubuntu/resolute/Dockerfile b/8/jdk/ubuntu/resolute/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..38bd36dd6a133aef35df919ae19a98bff4c4f8a2 --- /dev/null +++ b/8/jdk/ubuntu/resolute/Dockerfile @@ -0,0 +1,99 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:26.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='b8f5440f64f50193c01f67dacba55c9660caffe13b908baf6bd1955f4dd4c3ea'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_x64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + arm64) \ + ESUM='34912db17786f7144dab274f040a42028e25da6e7a6a09780d7013339a56bdb2'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_aarch64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='626e870f411d01d6541fafa11e64b8584d8b737195cec5576256e6d3d34a62ba'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_ppc64le_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/src.zip; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "javac -version"; javac -version; \ + echo "java -version"; java -version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/8/jdk/ubuntu/resolute/entrypoint.sh b/8/jdk/ubuntu/resolute/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..92d736ad1394f57a4e7b4c7bd1c8639ba2a04c78 --- /dev/null +++ b/8/jdk/ubuntu/resolute/entrypoint.sh @@ -0,0 +1,152 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +# JDK8 puts its JRE in a subdirectory +JRE_CACERTS_PATH=$JAVA_HOME/jre/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/8/jdk/windows/nanoserver-ltsc2022/Dockerfile b/8/jdk/windows/nanoserver-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..78df59397029b9af5a243cb7013e1d7c8aaa07b5 --- /dev/null +++ b/8/jdk/windows/nanoserver-ltsc2022/Dockerfile @@ -0,0 +1,39 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk8u502-b07 + +ENV JAVA_HOME C:\\openjdk-8 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:8u502-b07-jdk-windowsservercore-ltsc2022 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo javac -version && javac -version \ + && echo java -version && java -version \ + && echo Complete. diff --git a/8/jdk/windows/nanoserver-ltsc2025/Dockerfile b/8/jdk/windows/nanoserver-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..eb94d3d50b2cf34fd5aebdcf0c67c30a592b0e91 --- /dev/null +++ b/8/jdk/windows/nanoserver-ltsc2025/Dockerfile @@ -0,0 +1,39 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2025 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk8u502-b07 + +ENV JAVA_HOME C:\\openjdk-8 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:8u502-b07-jdk-windowsservercore-ltsc2025 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo javac -version && javac -version \ + && echo java -version && java -version \ + && echo Complete. diff --git a/8/jdk/windows/windowsservercore-ltsc2022/Dockerfile b/8/jdk/windows/windowsservercore-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7976ee62c1110d299919b4579e95c2358b2f162f --- /dev/null +++ b/8/jdk/windows/windowsservercore-ltsc2022/Dockerfile @@ -0,0 +1,54 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2022 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_x64_windows_hotspot_8u502b07.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_x64_windows_hotspot_8u502b07.msi ; \ + Write-Host ('Verifying sha256 (3888c5a2c851587c06262fb225f4c8098c6096f30aff1808b171c1c8f184e358) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne '3888c5a2c851587c06262fb225f4c8098c6096f30aff1808b171c1c8f184e358') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-8' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'javac -version'; javac -version; \ + Write-Host 'java -version'; java -version; \ + \ + Write-Host 'Complete.' diff --git a/8/jdk/windows/windowsservercore-ltsc2025/Dockerfile b/8/jdk/windows/windowsservercore-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a61066eb8f0aa72e92ed0528872618129ab28523 --- /dev/null +++ b/8/jdk/windows/windowsservercore-ltsc2025/Dockerfile @@ -0,0 +1,54 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2025 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_x64_windows_hotspot_8u502b07.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jdk_x64_windows_hotspot_8u502b07.msi ; \ + Write-Host ('Verifying sha256 (3888c5a2c851587c06262fb225f4c8098c6096f30aff1808b171c1c8f184e358) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne '3888c5a2c851587c06262fb225f4c8098c6096f30aff1808b171c1c8f184e358') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-8' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'javac -version'; javac -version; \ + Write-Host 'java -version'; java -version; \ + \ + Write-Host 'Complete.' diff --git a/8/jre/alpine/3.21/Dockerfile b/8/jre/alpine/3.21/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a9d7574bbc7f8948b7878321fa99fe55b6260184 --- /dev/null +++ b/8/jre/alpine/3.21/Dockerfile @@ -0,0 +1,86 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.21 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='39d17b519d925e2a979056d800e712b4d5f8b68112413ab1d06f525c1571c164'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_x64_alpine-linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java -version"; java -version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/8/jre/alpine/3.21/entrypoint.sh b/8/jre/alpine/3.21/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..7f4d15fd27a414df99bf5c44c96da77007ffd225 --- /dev/null +++ b/8/jre/alpine/3.21/entrypoint.sh @@ -0,0 +1,151 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/8/jre/alpine/3.22/Dockerfile b/8/jre/alpine/3.22/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9e8f2ea4378a02c5da16efc2650d1453612b8807 --- /dev/null +++ b/8/jre/alpine/3.22/Dockerfile @@ -0,0 +1,86 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.22 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='39d17b519d925e2a979056d800e712b4d5f8b68112413ab1d06f525c1571c164'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_x64_alpine-linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java -version"; java -version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/8/jre/alpine/3.22/entrypoint.sh b/8/jre/alpine/3.22/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..7f4d15fd27a414df99bf5c44c96da77007ffd225 --- /dev/null +++ b/8/jre/alpine/3.22/entrypoint.sh @@ -0,0 +1,151 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/8/jre/alpine/3.23/Dockerfile b/8/jre/alpine/3.23/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c83255a69d67934d626e70ff188a3fe12df5f824 --- /dev/null +++ b/8/jre/alpine/3.23/Dockerfile @@ -0,0 +1,86 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.23 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='39d17b519d925e2a979056d800e712b4d5f8b68112413ab1d06f525c1571c164'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_x64_alpine-linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java -version"; java -version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/8/jre/alpine/3.23/entrypoint.sh b/8/jre/alpine/3.23/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..7f4d15fd27a414df99bf5c44c96da77007ffd225 --- /dev/null +++ b/8/jre/alpine/3.23/entrypoint.sh @@ -0,0 +1,151 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/8/jre/alpine/3.24/Dockerfile b/8/jre/alpine/3.24/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5477368417a55433f34977550e3c244c660dde3d --- /dev/null +++ b/8/jre/alpine/3.24/Dockerfile @@ -0,0 +1,86 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM alpine:3.24 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + # gnupg required to verify the signature + gnupg \ + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ + case "${ARCH}" in \ + x86_64) \ + ESUM='39d17b519d925e2a979056d800e712b4d5f8b68112413ab1d06f525c1571c164'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_x64_alpine-linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java -version"; java -version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/8/jre/alpine/3.24/entrypoint.sh b/8/jre/alpine/3.24/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..7f4d15fd27a414df99bf5c44c96da77007ffd225 --- /dev/null +++ b/8/jre/alpine/3.24/entrypoint.sh @@ -0,0 +1,151 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/8/jre/ubi/ubi10-minimal/Dockerfile b/8/jre/ubi/ubi10-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7536fe66cc962cb69580e14e46990b1492e66083 --- /dev/null +++ b/8/jre/ubi/ubi10-minimal/Dockerfile @@ -0,0 +1,95 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi10-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + # Required for gpg in multi-arch-install + gnupg2 \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='4ffd3abaf65a47610096d9c25ea06f2439428f1c087d3e54eb518553a6115638'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_aarch64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='56fbe946d93afefd39353ff3fe0219e227fd4880267159ab48f95ac8ba25482d'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_ppc64le_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='f1a7bea0804bfa5627dac412fe7a0d751c4228592e356d6a32a30da54a48ed7a'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_x64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java -version"; java -version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/8/jre/ubi/ubi10-minimal/entrypoint.sh b/8/jre/ubi/ubi10-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..fc7aa3a0c18157518fd70cc47a113bd52773cd13 --- /dev/null +++ b/8/jre/ubi/ubi10-minimal/entrypoint.sh @@ -0,0 +1,151 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/8/jre/ubi/ubi9-minimal/Dockerfile b/8/jre/ubi/ubi9-minimal/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e0c73ab9e2a30a9ec6209bb2d74d40befc31d2ec --- /dev/null +++ b/8/jre/ubi/ubi9-minimal/Dockerfile @@ -0,0 +1,93 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM redhat/ubi9-minimal + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ + ; \ + microdnf clean all + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN set -eux; \ + ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)"; \ + case "${ARCH}" in \ + aarch64) \ + ESUM='4ffd3abaf65a47610096d9c25ea06f2439428f1c087d3e54eb518553a6115638'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_aarch64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + ppc64le) \ + ESUM='56fbe946d93afefd39353ff3fe0219e227fd4880267159ab48f95ac8ba25482d'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_ppc64le_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + x86_64) \ + ESUM='f1a7bea0804bfa5627dac412fe7a0d751c4228592e356d6a32a30da54a48ed7a'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_x64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java -version"; java -version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/8/jre/ubi/ubi9-minimal/entrypoint.sh b/8/jre/ubi/ubi9-minimal/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..fc7aa3a0c18157518fd70cc47a113bd52773cd13 --- /dev/null +++ b/8/jre/ubi/ubi9-minimal/entrypoint.sh @@ -0,0 +1,151 @@ +#!/usr/bin/env sh +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + fi + update-ca-trust + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/8/jre/ubuntu/jammy/Dockerfile b/8/jre/ubuntu/jammy/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6a57a3336f0bd888b963b3cffcf4da1242b7b942 --- /dev/null +++ b/8/jre/ubuntu/jammy/Dockerfile @@ -0,0 +1,98 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:22.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='f1a7bea0804bfa5627dac412fe7a0d751c4228592e356d6a32a30da54a48ed7a'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_x64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + arm64) \ + ESUM='4ffd3abaf65a47610096d9c25ea06f2439428f1c087d3e54eb518553a6115638'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_aarch64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='56fbe946d93afefd39353ff3fe0219e227fd4880267159ab48f95ac8ba25482d'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_ppc64le_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java -version"; java -version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/8/jre/ubuntu/jammy/entrypoint.sh b/8/jre/ubuntu/jammy/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..2bc4da293d6eb8dc4f680ad8b4a9163f9d273cfa --- /dev/null +++ b/8/jre/ubuntu/jammy/entrypoint.sh @@ -0,0 +1,151 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/8/jre/ubuntu/noble/Dockerfile b/8/jre/ubuntu/noble/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6904d09f45cbaab4941059f10cfe3562ad3bd192 --- /dev/null +++ b/8/jre/ubuntu/noble/Dockerfile @@ -0,0 +1,98 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:24.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='f1a7bea0804bfa5627dac412fe7a0d751c4228592e356d6a32a30da54a48ed7a'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_x64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + arm64) \ + ESUM='4ffd3abaf65a47610096d9c25ea06f2439428f1c087d3e54eb518553a6115638'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_aarch64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='56fbe946d93afefd39353ff3fe0219e227fd4880267159ab48f95ac8ba25482d'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_ppc64le_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java -version"; java -version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/8/jre/ubuntu/noble/entrypoint.sh b/8/jre/ubuntu/noble/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..2bc4da293d6eb8dc4f680ad8b4a9163f9d273cfa --- /dev/null +++ b/8/jre/ubuntu/noble/entrypoint.sh @@ -0,0 +1,151 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/8/jre/ubuntu/resolute/Dockerfile b/8/jre/ubuntu/resolute/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4268a89bbe2df64e88a2931959148c0e6722f095 --- /dev/null +++ b/8/jre/ubuntu/resolute/Dockerfile @@ -0,0 +1,98 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM ubuntu:26.04 + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + wget \ + # gnupg required to verify the signature + gnupg \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64) \ + ESUM='f1a7bea0804bfa5627dac412fe7a0d751c4228592e356d6a32a30da54a48ed7a'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_x64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + arm64) \ + ESUM='4ffd3abaf65a47610096d9c25ea06f2439428f1c087d3e54eb518553a6115638'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_aarch64_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + ppc64el) \ + ESUM='56fbe946d93afefd39353ff3fe0219e227fd4880267159ab48f95ac8ba25482d'; \ + BINARY_URL='https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_ppc64le_linux_hotspot_8u502b07.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget --progress=dot:giga -O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz; \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; + +RUN set -eux; \ + echo "Verifying install ..."; \ + echo "java -version"; java -version; \ + echo "Complete." +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/8/jre/ubuntu/resolute/entrypoint.sh b/8/jre/ubuntu/resolute/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..2bc4da293d6eb8dc4f680ad8b4a9163f9d273cfa --- /dev/null +++ b/8/jre/ubuntu/resolute/entrypoint.sh @@ -0,0 +1,151 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + cp -La /certificates/* /usr/local/share/ca-certificates/ + fi + update-ca-certificates + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/8/jre/windows/nanoserver-ltsc2022/Dockerfile b/8/jre/windows/nanoserver-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4da8867a2058993fdce89d7e386f0e32b86297db --- /dev/null +++ b/8/jre/windows/nanoserver-ltsc2022/Dockerfile @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk8u502-b07 + +ENV JAVA_HOME C:\\openjdk-8 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:8u502-b07-jre-windowsservercore-ltsc2022 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo java -version && java -version \ + && echo Complete. diff --git a/8/jre/windows/nanoserver-ltsc2025/Dockerfile b/8/jre/windows/nanoserver-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..17b11d30624c51fbc5f6cefdfa4e1da279bfd895 --- /dev/null +++ b/8/jre/windows/nanoserver-ltsc2025/Dockerfile @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2025 + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION=jdk8u502-b07 + +ENV JAVA_HOME C:\\openjdk-8 +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:8u502-b07-jre-windowsservercore-ltsc2025 $JAVA_HOME $JAVA_HOME + +RUN echo Verifying install ... \ + && echo java -version && java -version \ + && echo Complete. diff --git a/8/jre/windows/windowsservercore-ltsc2022/Dockerfile b/8/jre/windows/windowsservercore-ltsc2022/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cfb82bcd3101f9ad9b3a60796583d55d0f06219e --- /dev/null +++ b/8/jre/windows/windowsservercore-ltsc2022/Dockerfile @@ -0,0 +1,53 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2022 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_x64_windows_hotspot_8u502b07.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_x64_windows_hotspot_8u502b07.msi ; \ + Write-Host ('Verifying sha256 (d10ea23f35e10be60775bdff2ea858f4d56fd59e2d7b2c75b61412465fea1fe6) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne 'd10ea23f35e10be60775bdff2ea858f4d56fd59e2d7b2c75b61412465fea1fe6') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-8' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'java -version'; java -version; \ + \ + Write-Host 'Complete.' diff --git a/8/jre/windows/windowsservercore-ltsc2025/Dockerfile b/8/jre/windows/windowsservercore-ltsc2025/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..21a0a3bb8083bb1f6ac12a4323b1bbfe431fda74 --- /dev/null +++ b/8/jre/windows/windowsservercore-ltsc2025/Dockerfile @@ -0,0 +1,53 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2025 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION=jdk8u502-b07 + +RUN Write-Host ('Downloading https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_x64_windows_hotspot_8u502b07.msi ...'); \ + curl.exe -LfsSo openjdk.msi https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u502-b07/OpenJDK8U-jre_x64_windows_hotspot_8u502b07.msi ; \ + Write-Host ('Verifying sha256 (d10ea23f35e10be60775bdff2ea858f4d56fd59e2d7b2c75b61412465fea1fe6) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne 'd10ea23f35e10be60775bdff2ea858f4d56fd59e2d7b2c75b61412465fea1fe6') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-8' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +RUN Write-Host 'Verifying install ...'; \ + Write-Host 'java -version'; java -version; \ + \ + Write-Host 'Complete.' diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000000000000000000000000000000000..dc6932c2d337e0b09cf90fde80c08ac83b92a2a3 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,107 @@ +# Contributing to containers + +Thanks for your interest in this project. +You can contribute to this project in many different ways. **We appreciate all kinds of help, so thank you!** + +## Project description + +containers is a project that contains the Dockerfiles and scripts to produce Temurin container images + +* [https://github.com/adoptium/containers](https://github.com/adoptium/containers) + +## Developer resources + +The project maintains the following source code repositories + +* [https://github.com/adoptium/containers](https://github.com/adoptium/containers) + +## Eclipse Contributor Agreement + +Before your contribution can be accepted by the project team contributors must +electronically sign the Eclipse Contributor Agreement (ECA). + +* [Eclipse CLA](http://www.eclipse.org/legal/ECA.php) + +Commits that are provided by non-committers must have a Signed-off-by field in +the footer indicating that the author is aware of the terms by which the +contribution has been provided to the project. The non-committer must +additionally have an Eclipse Foundation account and must have a signed Eclipse +Contributor Agreement (ECA) on file. + +For more information, please see the [Eclipse Committer Handbook](https://www.eclipse.org/projects/handbook/#resources-commit). + +## Contact + +Contact the Eclipse Foundation Webdev team via webdev@eclipse-foundation.org. + +## Issues and Enhancements + +Please let us know via our [issue tracker](https://github.com/adoptium/temurin-build/issues) if you find a problem, even if you don't have a fix for it. The ideal issue report should be descriptive, and where possible include the steps we can take to reproduce the problem for ourselves. + +If you have a proposed fix for an issue, or an enhancement you would like to make to the code please describe it in an issue, then send us the code as a [GitHub pull request](https://help.github.com/articles/about-pull-requests) as described below. + +## Pull requests + +We use GitHub's pull requests (PRs) as the primary way to accept contributions to the project. That means we assume you have followed the usual procedure and forked the project repository, cloned your fork, created a new branch for your contribution, and pushed one or more commits to your branch. There are many [on-line guides](https://guides.github.com/activities/forking/) that will help you with these steps. + +Consider whether the project documentation or tests also need updating as part of your change, and make that part of the same logical issue and PR. Open your PR against the master branch of the project. + +To keep track of [the pull requests we are managing](https://github.com/adoptium/temurin-build/pulls) we ask that you follow these guidelines for structuring the pull request title and comment. + +### Pull request title + +Use a descriptive title, and if it relates to an issue in our tracker please reference which one. If the PR is not intended to be merged you should prefix the title with "[WIP]" which indicates it is still Work In Progress. For example, you may wish to send the PR in for an early review as you work through it. + +### Pull request comment + +The PR comment should be formed by a one-line subject, followed by one line of white space, and one or more descriptive paragraphs, each separated by one line of white space. All of them should be finished by a dot. + +Where your PR fixes an issue, it should include a reference to the issue's identifier in the first line of the commit comment. The comment should provide enough information for a reviewer to understand the changes and their relation to the rest of the code. + +### Licensing and Developer certificate of origin + +When you submit any copyrighted material to the project via a pull request, issue tracker, or any other means, you agree to license the material under [the project's open source license](https://github.com/adoptium/temurin-build/blob/master/LICENSE), and warrant that you have the legal authority to do so, whether or not you state this explicitly. + +We ask that you include a line similar to the following as part of your pull request comment or individual commit comments: + +```git +DCO 1.1 Signed-off-by: Random J Developer +``` + +“DCO” stands for “Developer Certificate of Origin,” and refers to [the same text used in the Linux Kernel community](https://elinux.org/Developer_Certificate_Of_Origin). Of course, you should replace "Random J Developer" by your own real name. + +By adding this simple comment, you are telling the community that you wrote the code you are contributing, or you have the right to pass on the code that you are contributing. + +> Tip: You can use `git commit -s ...` or configure a git `commit.template` to include the sign-off statement in your commit messages automatically. + +### Source file headers + +All the project's source files must start with a comment, as near to the top of the file as practical, that includes a reference to [the project license](https://github.com/adoptium/temurin-build/blob/master/LICENSE). Take a look at some existing files to see how we do that, and if there are any questions just ask. In some cases, such as small, trivial files, or source files generated by tooling we don't reference the license again, but it still applies wherever the file contains copyrightable material. + +We don't place explicit copyright statements in the project source files. The project comprises many distinct pieces of code, spread across numerous source files, and authored by a variety of individuals. Managing copyright statements is unproductive and [can lead to confusion and contention around the edge cases](https://opensource.com/law/14/n2/copyright-statements-source-files). Rather we utilize [the NOTICE file](https://github.com/adoptium/temurin-build/blob/master/NOTICE) mechanism as a way to acknowledge copyright broadly where there is a valid reason to do so. + +Finally, for similar reasons to avoiding individual copyright statements, we don't maintain `@author` tags in source files. There are good arguments to suggest that [author tags discourage open contribution](https://producingoss.com/en/managing-volunteers.html#territoriality), and we depend upon Git to maintain that information for the project. + +### Ensuring high quality + +If you're changing a shellscript, please make sure you run [shellcheck](https://github.com/koalaman/shellcheck) before submitting your PR. This will also run in a GitHub check titled `Linter` to ensure you comply to our coding style guidelines (alongside a lot of other linters for different formats). + +After we receive your pull request our [GitHub Checks](https://github.com/adoptium/temurin-build/tree/master/.github/workflows) will test your changes. +If you're making any changes to our groovy files, you'll be more interested in our [pr-tester](https://ci.adoptopenjdk.net/view/build-tester/job/build-scripts-pr-tester/job/openjdk-build-pr-tester/) jenkins job which executes a set of test pipelines in a semi-live environment. Watch for the results posted as a comment to the PR, investigate and fix any failures. +Please see the [Testing.md](Testing.md) for more information on any of this. + +Fixes can simply be pushed to the same branch from which you opened your pull request. GitHub will automatically re-test when new commits are pushed and update the results. + +### Reviews and merge conflicts + +After your PR has passed the automated testing it will be reviewed by other developers. Comments on the changes and suggested modifications are encouraged from anybody, especially committers. Please keep all comments focused, polite, and technical. + +You may consider seeking explicit feedback from a contributor who has already worked on the code being changed. + +> Tip: Use git's blame function to see who changed the code last, then ask them to be a reviewer. + +Any reviewer can indicate that a change looks suitable for merging with a comment such as: “I think this patch looks good” or "this fixes the issue for me"; and we use the [LGTM](https://en.wiktionary.org/wiki/LGTM) convention for indicating the strongest level of technical sign-off on a PR. When a committer comments with "LGTM" they specifically mean “I’ve looked at this patch thoroughly and take as much responsibility as if I wrote it myself”. + +Sometimes, other changes will be merged ahead of yours which cause a conflict with your pull request’s changes. The PR cannot be merged until the conflict is resolved. As a PR author it is your responsibility to resolve the conflicts and keep the PR up to date. To facilitate this, try to be responsive to the review discussion rather than let days pass between replies. + +Again, **thank you** for contributing to the project! diff --git a/DISTRO_MAINTENANCE.md b/DISTRO_MAINTENANCE.md new file mode 100644 index 0000000000000000000000000000000000000000..69afb2cac95376bd06b41953297c696ad05d2332 --- /dev/null +++ b/DISTRO_MAINTENANCE.md @@ -0,0 +1,334 @@ +# Distribution Maintenance for Eclipse Temurin Container Images + +## 1. Introduction + +This document describes the policy, criteria, and practical steps for adding, maintaining, deprecating, and removing operating system distributions in the Eclipse Temurin container images. It is intended for maintainers of the [containers](https://github.com/adoptium/containers) repository. + +## 2. Currently Supported Distributions + +The current list of supported distributions can be seen at [Supported Platforms](https://adoptium.net/supported-platforms/). The Docker icon indicates which distributions are supported as part of the official image manifest. + +All supported distros and their configuration are defined in [`config/temurin.yml`](config/temurin.yml). At the time of writing, we support: + +| OS Family | Distributions | +|-----------|--------------| +| Ubuntu | Resolute (26.04), Noble (24.04), Jammy (22.04) | +| UBI (Red Hat) | UBI 10 Minimal, UBI 9 Minimal | +| Alpine Linux | 3.23, 3.22, 3.21 | +| Windows | Server Core LTSC 2022/2025, Nano Server LTSC 2022/2025 | + +### Support Commitments + +We pledge to support the following: + +- **Ubuntu**: All actively supported LTS versions. Ubuntu LTS releases receive five years of standard support from Canonical, and we aim to carry every version that is still within that window. +- **Alpine Linux**: All actively supported versions. Alpine has a roughly two-year support cycle per release; we track every version that is still receiving security updates. +- **Red Hat UBI**: All actively supported UBI Minimal versions that are still receiving security updates from Red Hat. +- **Windows**: All actively supported Windows Server LTSC releases, in both Server Core and Nano Server variants. + +We **may remove a distribution mid-Java-LTS-release** if it reaches End-of-Life upstream and no longer receives security updates. Continuing to ship images on an unsupported base OS is a security risk we are not willing to carry. + +We **may deprecate older distributions for future Java versions** rather than removing them outright. For example, older Alpine versions may be marked `deprecated` so that they stop receiving Dockerfiles for the next Java release (e.g. JDK 27) while still being maintained for earlier Java LTS versions. This is controlled via the `deprecated` field in `temurin.yml` (see [Section 6](#6-deprecating-a-distribution)). + +## 3. Criteria for Adding New Distributions + +All proposals for new distributions must be reviewed and approved by the Project Management Committee (PMC). The PMC evaluates each proposal based on the following criteria. + +### 3.1 Long-Term Support (LTS) Requirement + +Only distributions with a commitment to long-term support are considered to ensure stability and ongoing support. + +### 3.2 Community Demand + +The distribution must demonstrate significant demand from the Adoptium community or enterprise users. Strong consideration will be given to proposals received from [Adoptium Working Group Members](https://adoptium.net/members/). + +### 3.3 Technical Feasibility + +The distribution should be capable of supporting the Eclipse Temurin versions without requiring excessive adaptations. + +### 3.4 Compatibility Testing + +The Adoptium project must have access to sufficient testing resources matching the proposed distribution. New distributions must pass a predefined set of compatibility tests to confirm that existing functionalities are not adversely affected. + +### 3.5 Official Base Images + +Because Eclipse Temurin images are published as [official images](https://docs.docker.com/trusted-content/official-images/) in collaboration with Docker, there are restrictions as to which base images can be supported. + +### 3.6 Encouraging Flexible Deployment via Docker + +While we strive to support a range of widely-used distributions, our main goal is not to support every possible distribution. Instead, we encourage users to leverage Docker's `COPY` command to deploy Java and other dependencies on top of any base image they prefer: + +```dockerfile +FROM your-choice-of-base-image + +COPY --from=eclipse-temurin:21-jdk /opt/java/openjdk /opt/java/openjdk + +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH="${JAVA_HOME}/bin:${PATH}" +``` + +## 4. How Distribution Configuration Works + +### 4.1 Configuration File + +All distributions are defined in [`config/temurin.yml`](config/temurin.yml). The file is organised by OS family (`linux`, `alpine-linux`, `windows`) with a list of configurations under each. Example entry: + +```yaml +configurations: + linux: + - directory: ubuntu/noble + image: ubuntu:24.04 + architectures: [aarch64, arm, ppc64le, riscv64, s390x, x64] + os: ubuntu +``` + +Each configuration entry has the following fields: + +| Field | Required | Description | +|-------|----------|-------------| +| `directory` | Yes | Path under the version directory (e.g. `ubuntu/noble`). This becomes part of the Dockerfile output path: `///Dockerfile`. | +| `image` | Yes | The Docker base image to use (e.g. `ubuntu:24.04`, `alpine:3.23`). | +| `architectures` | Yes | List of CPU architectures to build for. Valid values: `aarch64`, `arm`, `ppc64le`, `riscv64`, `s390x`, `x64`. | +| `os` | Yes | The Dockerfile template to use. Must match one of the Jinja2 templates in `docker_templates/`: `ubuntu`, `alpine-linux`, `ubi-minimal`, `servercore`, or `nanoserver`. | +| `deprecated` | No | Java major version number at which to stop generating Dockerfiles for this distro. For example, `deprecated: 25` means the distro will not receive Dockerfiles for Java 25 or later. | +| `versions` | No | Override the list of Java versions to generate for this distro. Defaults to all supported versions from the Adoptium API. | + +### 4.2 Dockerfile Generation + +[`generate_dockerfiles.py`](generate_dockerfiles.py) reads `config/temurin.yml`, queries the [Adoptium API](https://api.adoptium.net) for the latest release information, and renders Dockerfiles using the Jinja2 templates in [`docker_templates/`](docker_templates/). + +The generated Dockerfiles are written to: + +``` +///Dockerfile +``` + +For example: `21/jdk/ubuntu/noble/Dockerfile`. + +### 4.3 Dockerfile Templates + +Each OS family has a corresponding Jinja2 template: + +| Template | Used for | +|----------|----------| +| `ubuntu.Dockerfile.j2` | Ubuntu-based images | +| `alpine-linux.Dockerfile.j2` | Alpine Linux images | +| `ubi-minimal.Dockerfile.j2` | Red Hat UBI Minimal images | +| `servercore.Dockerfile.j2` | Windows Server Core images | +| `nanoserver.Dockerfile.j2` | Windows Nano Server images | + +Shared logic (architecture selection, version checks, entrypoints, etc.) lives in `docker_templates/partials/`. + +### 4.4 Docker Hub Manifest + +[`dockerhub_doc_config_update.py`](dockerhub_doc_config_update.py) reads the same `config/temurin.yml` and the generated Dockerfiles to produce the official Docker Hub manifest file (`eclipse-temurin`). This manifest is submitted as a PR to the [docker-library/official-images](https://github.com/docker-library/official-images) repository. + +### 4.5 Ordering Matters + +The **first entry** in each OS family list in `temurin.yml` is treated as the default image for that family. This affects tag generation — the default linux image gets `SharedTags` (tags without a distro suffix, e.g. `21-jdk`) in the Docker Hub manifest. When adding a new distro, add it at the correct position: the newest/preferred distro should be first. + +### 4.6 Automation + +A [GitHub Action](.github/workflows/updater.yml) runs every 30 minutes. It executes `generate_dockerfiles.py --force`, and if any Dockerfiles change, it opens a PR automatically. This means that once a distro is added to `temurin.yml`, Dockerfiles will be generated on the next automated run. + +## 5. Adding a New Distribution + +### Decision Flowchart + +Use this flowchart to evaluate whether and how to add a new distribution: + +```mermaid +flowchart TD + A[New distro request] --> B{Does this distro\nhave an LTS policy?} + B -- No --> C[Reject — we only\nsupport LTS distros] + B -- Yes --> D{What C library\ndoes it use?} + + D -- glibc --> E{Is there an existing\nDockerfile template\nthat works?\ne.g. ubuntu.Dockerfile.j2} + D -- musl --> F{Is there an existing\nmusl template\nthat works?\ne.g. alpine-linux.Dockerfile.j2} + D -- Other/Unknown --> G[Evaluate feasibility\nwith PMC — may need\nnew Temurin builds] + + E -- Yes --> H[Add entry to temurin.yml\nusing existing template] + E -- No --> I{Can the user use\nCOPY --from to get\nTemurin onto their\npreferred base image?} + + F -- Yes --> J[Add entry to temurin.yml\nusing existing template] + F -- No --> I + + I -- Yes --> K[Document COPY --from\napproach — no new\nofficial image needed] + I -- No --> L[Create a new\nDockerfile template\nin docker_templates/] + + L --> M{Does Docker accept\nthis base image as an\nofficial image source?} + M -- Yes --> N[Proceed with PMC\napproval and implement] + M -- No --> K + + H --> O[Generate Dockerfiles,\nrun tests, submit PR] + J --> O + N --> O +``` + +### 5.1 Get PMC Approval + +Submit a proposal (see [Section 3](#3-criteria-for-adding-new-distributions)) and obtain PMC approval before making any code changes. Add the `PMC-agenda` label to the issue or PR to ensure it gets visibility at the next PMC meeting. + +### 5.2 Add the Configuration Entry + +Edit [`config/temurin.yml`](config/temurin.yml) and add a new entry under the appropriate OS family. Include: + +- The `directory` name (typically `/` e.g. `ubuntu/noble`) +- The base `image` (e.g. `ubuntu:24.04`) +- The supported `architectures` — check which architectures Temurin builds for on the target OS via the [Adoptium API](https://api.adoptium.net/v3/info/available_releases) +- The `os` template name + +Place the entry at the correct position. Entries are ordered with the newest/preferred distro first (this determines which distro gets the default shared tags). + +**Example — adding Ubuntu 28.04 (Xenial Xerus):** + +```yaml + linux: + # EOL April 2033 + - directory: ubuntu/xenial-xerus + image: ubuntu:28.04 + architectures: [aarch64, arm, ppc64le, riscv64, s390x, x64] + os: ubuntu +``` + +### 5.3 Add a Dockerfile Template (if needed) + +If the new distro uses an existing OS family (e.g. a new Ubuntu version), no template changes are needed — it will use the existing `ubuntu.Dockerfile.j2`. + +If adding a completely new OS type, create a new `.Dockerfile.j2` template in `docker_templates/` and update `generate_dockerfiles.py` if the OS family name needs any special handling (e.g. architecture mappings in `archHelper()`). + +### 5.4 Generate and Verify Dockerfiles + +Run the generator locally to verify: + +```bash +pip3 install -r requirements.txt +python3 generate_dockerfiles.py --force +``` + +Check that Dockerfiles are generated in the expected directories and look correct. + +### 5.5 Run Sanity Checks + +```bash +./sanity.sh +``` + +This verifies there are no empty checksums or download URLs in the generated Dockerfiles. + +### 5.6 Run Tests + +```bash +python3 -m pytest test_generate_dockerfiles.py test_dockerhub_doc_config_update.py +``` + +### 5.7 Submit a PR + +Submit a PR with: +1. The `temurin.yml` change +2. The generated Dockerfiles (from running `generate_dockerfiles.py --force`) + +The CI pipeline will build and test all generated Docker images. + +### 5.8 Update the Docker Hub Manifest + +After the PR is merged: + +```bash +git fetch --all && git checkout main && git pull +python3 dockerhub_doc_config_update.py +``` + +Submit the generated `eclipse-temurin` manifest file as a PR to [docker-library/official-images](https://github.com/docker-library/official-images/blob/master/library/eclipse-temurin). + +## 6. Deprecating a Distribution + +When a distribution is approaching End-of-Life (upstream EOL), we deprecate it so that newer Java versions are no longer built for it, while older Java versions continue to be available. + +### 6.1 When to Deprecate + +- When the upstream distribution announces an EOL date +- When the PMC determines a distribution should be phased out +- When we want to stop generating images for a distro on future Java versions while continuing to support it for existing ones (e.g. dropping Alpine 3.21 for JDK 27 onwards) +- Aim to announce deprecation through official channels at least six months before full removal + +### 6.2 How to Deprecate + +Add a `deprecated` field to the distribution's entry in `temurin.yml`. The value is the Java major version at which to stop generating Dockerfiles. + +**Example — deprecating UBI 9 Minimal starting from Java 25:** + +```yaml + - directory: ubi/ubi9-minimal + architectures: [aarch64, ppc64le, s390x, x64] + image: redhat/ubi9-minimal + deprecated: 25 + os: ubi-minimal +``` + +This means: +- Java 8, 11, 17, 21, and any version < 25 will continue to receive Dockerfile updates for UBI 9 Minimal +- Java 25 and later will **not** generate Dockerfiles for UBI 9 Minimal + +After adding the `deprecated` field, re-run `generate_dockerfiles.py --force` to remove any Dockerfiles that should no longer exist, and update the Docker Hub manifest. + +## 7. Removing a Distribution + +A distribution may be fully removed in two scenarios: + +1. **Scheduled removal**: The distro was previously deprecated and all associated Java versions have moved past the deprecation threshold. +2. **Immediate removal**: The distro has reached EOL upstream and no longer receives security updates. In this case we may remove it mid-Java-LTS-release to avoid shipping images on an insecure base. The PMC will approve this action. + +To remove a distribution: + +1. Remove the entry from `temurin.yml` +2. Run `python3 generate_dockerfiles.py --force` to clean up generated Dockerfiles +3. Update the Docker Hub manifest +4. Submit PRs for both this repository and the docker-library/official-images repository + +Previous tagged versions remain available on Docker Hub for historical access and audit purposes but are not recommended for production use. + +## 8. Updating an Existing Distribution Version + +When a distribution releases a new minor/patch version (e.g. Alpine 3.22 → 3.23): + +1. Add the new version as a new entry in `temurin.yml` (placed first in the list if it should become the new default) +2. Optionally add a `deprecated` field to the older version to phase it out for newer Java releases +3. Follow the standard generation and PR workflow from [Section 5.4](#54-generate-and-verify-dockerfiles) onwards + +## 9. Architecture Support + +Not all architectures are available for all distributions. When adding a new distro, verify: + +1. The base image supports the target architectures +2. Temurin binaries exist for those architectures on the target OS (check the [Adoptium API](https://api.adoptium.net)) +3. The architecture name maps correctly — see `archHelper()` in `generate_dockerfiles.py` and `DOCKERFILE_ARCH_MAP` in `dockerhub_doc_config_update.py` + +Current architecture identifiers used in `temurin.yml`: + +| Config value | Ubuntu/Debian | Alpine | Docker Hub | +|-------------|---------------|--------|------------| +| `x64` | `amd64` | `x86_64` | `amd64` | +| `aarch64` | `arm64` | `aarch64` | `arm64v8` | +| `arm` | `armhf` | — | `arm32v7` | +| `ppc64le` | `ppc64el` | — | `ppc64le` | +| `s390x` | `s390x` | — | `s390x` | +| `riscv64` | `riscv64` | — | `riscv64` | + +## 10. Quick Reference + +| Task | What to change | +|------|---------------| +| Add a new distro | Add entry to `temurin.yml`, generate Dockerfiles, update manifest | +| Deprecate a distro for new Java versions | Add `deprecated: ` to entry in `temurin.yml` | +| Fully remove a distro | Remove entry from `temurin.yml`, run generator with `--force` | +| Change default distro for an OS family | Move the preferred entry to the first position in the list | +| Add architecture support | Add arch to the `architectures` list in the distro's entry | + +## 11. Amendment Procedure + +The process for updating this document includes community consultation and must be approved by a majority of the Project Management Committee (PMC). + +## Feedback and Improvements + +Feedback on this document is welcome and can be submitted via [GitHub issues](https://github.com/adoptium/containers/issues/new/choose). diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..034280c74f6dcc5a32f110537975fb7af58a1fb0 --- /dev/null +++ b/README.md @@ -0,0 +1,107 @@ +# Containers +[![DockerPulls](https://img.shields.io/docker/pulls/_/eclipse-temurin?label=Docker%20Pulls)](https://hub.docker.com/_/eclipse-temurin) +[![Docker Stars](https://img.shields.io/docker/stars/_/eclipse-temurin?label=Docker%20Stars)](https://hub.docker.com/r/_/eclipse-temurin) +[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/adoptium/containers/badge)](https://api.securityscorecards.dev/projects/github.com/adoptium/containers) + +This repository contains the Dockerfiles for the official [Adoptium](https://adoptium.net) images of the Eclipse Temurin distribution (OpenJDK). These images are made available in Docker Hub. + +If you are looking for the usage README then please head to the [Official Docker Hub Documentation](https://hub.docker.com/_/eclipse-temurin). + +## Supported Images + +In general, we support Alpine, UBI, Ubuntu and Windows containers. + +[List of Supported Images By Tag](https://github.com/docker-library/docs/tree/master/eclipse-temurin#simple-tags) + +## Update Policy + +As these are official Docker Hub images, Docker Inc maintains the base image +and so any critical CVEs in the base O/S layer gets updated by them in short +order. + +Note that the eclipse-temurin images include `openssl` as a prerequisite of +the `wget` and `ca-certificates` packages but they are NOT included in the +Ubuntu base image so updates to openssl will not necessarily trigger an +rebuild to pick up fixes. In general, low severity vulnerabilities can wait +until the next rebuild. See +[this comment](https://github.com/docker-library/official-images/issues/16225#issuecomment-1942193224) +for some details and also the +[docker-library FAQ](https://github.com/docker-library/faq/tree/master?tab=readme-ov-file#image-building). + +The Debian and Ubuntu images are generally also built periodically (about +once a month) and may also be triggered by dockerhub if another high +security vulnerability is detected, such as in openssl. Adoptium has no +mechanism - other than putting an update to the Dockerfiles - to explicitly +trigger a rebuild at dockerhub. + +For JDK version updates, we update the dockerfiles and release on a +quarterly cadence Temurin releases a Patch Set Update (PSU). + +## Maintenance of Dockerfiles + +This section is for maintainers of the containers repository. + +### Hourly automated Job + +A [Updater GitHub Action](.github/workflows/updater.yml) runs every 30 mins which triggers the +[`./generate_dockerfiles.py`](./generate_dockerfiles.py) script to update the Dockerfiles by creating a Pull Request containing any changes. It uses the jinja templates defined in [docker_templates](./docker_templates/) to generate the docker updates. It uses the Adoptium API to fetch the latest artefacts for each release. + +#### Manual Release + +Generally this is not necessary but during a release you can also trigger the above process by running [`./generate_dockerfiles.py`](./generate_dockerfiles.py) manually by heading to The [GitHub Action definition](https://github.com/adoptium/containers/actions/workflows/updater.yml) and clicking the **Run Workflow** button and making sure the `main` (default) branch is selected, then click the next **Run Workflow** button. + +### Review and Merge PR + +Once the PR from the hourly automated job is created you should review it (which itself tests all of the Docker Images that we have generate configuration for). + +## Update Official Docker Hub Manifest + +Once you've merged the PR, you can update the official Docker Hub manifest. This is done by running the following command in the containers repo on your local machine: + +```bash +# Get the latest changes +git fetch --all +# Checkout the main branch +git checkout main +python3 dockerhub_doc_config_update.py +``` + +This script will create a file called _eclipse-temurin_ by default. + +Create a new PR to replace the [Manifest on Docker Hub](https://github.com/docker-library/official-images/blob/master/library/eclipse-temurin) with the new contents of _eclipse-temurin_ - this can be done using a fork of the code or do it via the github UI as follows: + +- Go to https://github.com/docker-library/official-images/blob/master/library/eclipse-temurin web UI +- Click **edit(pencil button)** +- Remove its content +- Copy-paste _eclipse-temurin_'s content +- At the bottom of that edit screen' Propose changes section + - add **title** e.g [eclipse-temurin: XXXXX] + - add **description** for the commit + - click **Propose Change** button. + +In the next screen click on the **Create Pull Request** button. + +Once that PR has been created it will be automatically tested and reviewed by Docker Hub staff and eventually released. + +### Diff Output at Docker Hub + +It can be useful to look at the "Diff for XXX:" output created by one of the Docker Hub GitHub Actions on the Pull Request. This output +should not be read as a traditional PR (since Docker Hub bots do move things around, so you may see what looks like odd deletions) +but as a sanity check to make sure you see the platforms/architectures that you expect. + +## Release time process + +During a release, when linux and windows binaries are published to github, there is an ["hourly" automated containers CI](#hourly-automated-job) PR labeled "Update Dockerfiles", that will +generate any updates required to the Dockerfiles for these new linux and windows binaries. The containers Dockerfiles are located within this +repository under the folders \/\/\/\/Dockerfile. + +It should be understood that no actual "pushing" of any information to dockerhub is done, the way it works is once all the necessary Dockerfiles have been updated for the new +releases, the remote dockerhub Manifest is updated with the information. Then dockerhub "pulls" the new container Dockerfiles and builds the new images for the updated Manifest, once +completed those new images are then available in dockerhub. + +The "Release" process for updating dockerhub cannot start until all linux and windows binaries for all versions have been published, due to the Manifest setup. + +### Release process: +1. Have all linux and windows binaries been published for all versions? +1. Verify that all the \/\/\/\/Dockerfile's have been updated by the auto-generated "Update Dockerfiles" PRs. Check there are not any left requiring "approval" to merge? +1. Create and publish the dockerhub Manifest update PR following the instructions: [Update Official Docker Hub Manifest](#update-official-docker-hub-nanifest) diff --git a/adoptium_api.py b/adoptium_api.py new file mode 100644 index 0000000000000000000000000000000000000000..728e1813f80c653cc0092399d1251c54a7c56af7 --- /dev/null +++ b/adoptium_api.py @@ -0,0 +1,57 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import json +import urllib.request + +ADOPTIUM_API_URL = "https://api.adoptium.net/v3/info/available_releases" + + +def _fetch_release_data(): + """Fetch release info from the Adoptium API.""" + req = urllib.request.Request( + ADOPTIUM_API_URL, + headers={"User-Agent": "Adoptium Dockerfile Updater"}, + ) + with urllib.request.urlopen(req) as response: + return json.loads(response.read().decode("utf-8")) + + +def get_supported_versions(): + """Fetch supported versions from the Adoptium API. + + Returns all LTS versions plus any non-LTS versions between the most + recent LTS and the most recent feature release (inclusive). + + For example, if LTS versions are [8, 11, 17, 21, 25] and the most + recent feature release is 26, this returns [8, 11, 17, 21, 25, 26]. + """ + data = _fetch_release_data() + + lts_versions = set(data["available_lts_releases"]) + most_recent_lts = data["most_recent_lts"] + most_recent_feature = data["most_recent_feature_release"] + + # All LTS versions + anything between latest LTS and most recent feature release + versions = set(lts_versions) + for v in range(most_recent_lts + 1, most_recent_feature + 1): + if v in data["available_releases"]: + versions.add(v) + + return sorted(versions) + + +def get_latest_lts(): + """Return the most recent LTS version number.""" + data = _fetch_release_data() + return data["most_recent_lts"] diff --git a/config/temurin.yml b/config/temurin.yml new file mode 100644 index 0000000000000000000000000000000000000000..8c7741654f476e2ff9af5ffc1c7bc883191416fb --- /dev/null +++ b/config/temurin.yml @@ -0,0 +1,100 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +architecture_overrides: + # We don't ship s390x for JDK8 as it has no JIT + - versions: "==8" + exclude: [s390x] + # We only ship riscv64 for JDK17 and above + - versions: "<17" + exclude: [riscv64] + # We don't ship arm32 for JDK21 and above + - versions: ">=21" + exclude: [arm] + +configurations: + linux: + - directory: ubuntu/resolute + image: ubuntu:26.04 + # TODO add riscv64 back once upstream docker can build it + architectures: [aarch64, arm, ppc64le, s390x, x64] + os: ubuntu + + - directory: ubuntu/noble + image: ubuntu:24.04 + architectures: [aarch64, arm, ppc64le, riscv64, s390x, x64] + deprecated: 27 + os: ubuntu + + - directory: ubuntu/jammy + image: ubuntu:22.04 + architectures: [aarch64, arm, ppc64le, s390x, x64] + deprecated: 27 + os: ubuntu + + - directory: ubi/ubi10-minimal + architectures: [aarch64, ppc64le, s390x, x64] + image: redhat/ubi10-minimal + os: ubi-minimal + + - directory: ubi/ubi9-minimal + architectures: [aarch64, ppc64le, s390x, x64] + image: redhat/ubi9-minimal + deprecated: 25 + os: ubi-minimal + + alpine-linux: + - directory: alpine/3.24 + architectures: [aarch64, x64] + image: alpine:3.24 + os: alpine-linux + + - directory: alpine/3.23 + architectures: [aarch64, x64] + image: alpine:3.23 + deprecated: 27 + os: alpine-linux + + - directory: alpine/3.22 + architectures: [aarch64, x64] + image: alpine:3.22 + deprecated: 26 + os: alpine-linux + + - directory: alpine/3.21 + architectures: [aarch64, x64] + image: alpine:3.21 + deprecated: 26 + os: alpine-linux + + windows: + - directory: windows/windowsservercore-ltsc2022 + architectures: [x64] + image: mcr.microsoft.com/windows/servercore:ltsc2022 + os: servercore + + - directory: windows/nanoserver-ltsc2022 + architectures: [x64] + image: mcr.microsoft.com/windows/nanoserver:ltsc2022 + os: nanoserver + + - directory: windows/windowsservercore-ltsc2025 + architectures: [x64] + image: mcr.microsoft.com/windows/servercore:ltsc2025 + os: servercore + + - directory: windows/nanoserver-ltsc2025 + architectures: [x64] + image: mcr.microsoft.com/windows/nanoserver:ltsc2025 + os: nanoserver diff --git a/docker_templates/alpine-linux.Dockerfile.j2 b/docker_templates/alpine-linux.Dockerfile.j2 new file mode 100644 index 0000000000000000000000000000000000000000..260d1ffb79a9d327f62006129773d7f8fcdf9783 --- /dev/null +++ b/docker_templates/alpine-linux.Dockerfile.j2 @@ -0,0 +1,39 @@ +{% include 'partials/license.j2' %} + +FROM {{ base_image }} + +{% include 'partials/nix-env.j2' %} + +RUN set -eux; \ + apk add --no-cache \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig ttf-dejavu \ + {% if version|int < 25 -%} + # gnupg required to verify the signature + gnupg \ + {% endif -%} + # utilities for keeping Alpine and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit-trust \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + musl-locales musl-locales-lang \ + {%- include 'partials/binutils.j2' %} + tzdata \ + # Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can + # only import one at a time. + coreutils \ + # Needed to extract CN and generate aliases for certificates + openssl \ + ; \ + rm -rf /var/cache/apk/* + +{% include 'partials/java-version.j2' %} + +{% set arch_cmd = "apk --print-arch" -%} +{% include 'partials/multi-arch-install.j2' %} + +{% include 'partials/version-check.j2' %} +{% include 'partials/entrypoint.j2' %} +{% include 'partials/jshell.j2' %} diff --git a/docker_templates/entrypoint.sh.j2 b/docker_templates/entrypoint.sh.j2 new file mode 100755 index 0000000000000000000000000000000000000000..e1396c438f5728115f612084be9a7ad85007e3b3 --- /dev/null +++ b/docker_templates/entrypoint.sh.j2 @@ -0,0 +1,162 @@ +{%- if os == "ubuntu" -%} +#!/usr/bin/env bash +{%- else -%} +#!/usr/bin/env sh +{%- endif %} +{% include 'partials/license.j2' %} +# This script defines `sh` as the interpreter, which is available in all POSIX environments. However, it might get +# started with `bash` as the shell to support dotted.environment.variable.names which are not supported by POSIX, but +# are supported by `sh` in some Linux flavours. + +set -e + +TMPDIR=${TMPDIR:-/tmp} + +# JDK truststore location +{%- if version|int == 8 and image_type == "jdk" %} +# JDK8 puts its JRE in a subdirectory +JRE_CACERTS_PATH=$JAVA_HOME/jre/lib/security/cacerts +{%- else %} +JRE_CACERTS_PATH=$JAVA_HOME/lib/security/cacerts +{%- endif %} + +# Opt-in is only activated if the environment variable is set +if [ -n "$USE_SYSTEM_CA_CERTS" ]; then + + if [ ! -w "$TMPDIR" ]; then + echo "Using additional CA certificates requires write permissions to $TMPDIR. Cannot create truststore." + exit 1 + fi + + # Wrap keytool truststore access. JDK 9+ uses -cacerts (added in JDK 9) + # to avoid the "Warning: use -cacerts option to access cacerts keystore" + # that keytool emits when -keystore points at the default cacerts file. + # JDK 8 has no -cacerts and uses -keystore. The temporary-truststore + # branch below rebinds the JDK 9+ wrapper to -keystore as well, since + # -cacerts would still resolve to the read-only default. -importkeystore + # is not routed through this wrapper: its -destkeystore/-srckeystore do + # not trigger the warning and have no -cacerts form. + keytool_truststore() { +{%- if version|int >= 9 %} + keytool -cacerts "$@" +{%- else %} + keytool -keystore "$JRE_CACERTS_PATH" "$@" +{%- endif %} + } + + # Figure out whether we can write to the JVM truststore. If we can, we'll add the certificates there. If not, + # we'll use a temporary truststore. + if [ ! -w "$JRE_CACERTS_PATH" ]; then + # We cannot write to the JVM truststore, so we create a temporary one + JRE_CACERTS_PATH_NEW=$(mktemp) + echo "Using a temporary truststore at $JRE_CACERTS_PATH_NEW" + cp "$JRE_CACERTS_PATH" "$JRE_CACERTS_PATH_NEW" + JRE_CACERTS_PATH=$JRE_CACERTS_PATH_NEW + # If we use a custom truststore, we need to make sure that the JVM uses it + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Djavax.net.ssl.trustStore=${JRE_CACERTS_PATH} -Djavax.net.ssl.trustStorePassword=changeit" +{%- if version|int >= 9 %} + # Rebind: -cacerts would still resolve to the read-only default. + keytool_truststore() { + keytool -keystore "$JRE_CACERTS_PATH" "$@" + } +{%- endif %} + fi + + tmp_store=$(mktemp) + + # Copy full system CA store to a temporary location + trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$tmp_store" > /dev/null + + # Add the system CA certificates to the JVM truststore. + keytool -importkeystore -destkeystore "$JRE_CACERTS_PATH" -srckeystore "$tmp_store" -srcstorepass changeit -deststorepass changeit -noprompt > /dev/null + + # Clean up the temporary truststore + rm -f "$tmp_store" + + # Import the additional certificate into JVM truststore + for i in /certificates/*crt; do + if [ ! -f "$i" ]; then + continue + fi + tmp_dir=$(mktemp -d) + BASENAME=$(basename "$i" .crt) + + # We might have multiple certificates in the file. Split this file into single files. The reason is that + # `keytool` does not accept multi-certificate files + csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}' + + for crt in "$tmp_dir/$BASENAME"-*; do + # Extract the Common Name (CN) from the certificate + CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p') + + # Compute the certificate SHA-256 fingerprint. It is used both to skip certificates that are + # already present and to build a collision-free alias below. A certificate that openssl cannot + # parse yields an empty fingerprint; skip it rather than risk a non-unique alias. + FINGERPRINT=$(openssl x509 -in "$crt" -noout -fingerprint -sha256 2>/dev/null | cut -d'=' -f2) + if [ -z "$FINGERPRINT" ]; then + echo "Could not read the fingerprint of a certificate in $i, skipping" + continue + fi + + # Check if the certificate is already in the JVM truststore by fingerprint. This prevents + # failures on container restart when the certificate was added to the system CA store in a + # previous run and is now being re-imported via keytool -importkeystore. + if keytool_truststore -list -storepass changeit -v 2>/dev/null | grep -qiF "$FINGERPRINT"; then + echo "Certificate with CN=$CN is already in the JVM truststore, skipping" + continue + fi + + # Normalized, globally-unique fingerprint suffix used to disambiguate aliases. The serial + # number is not reliable for this: CA roots can share a non-unique serial (e.g. 00) and may + # have no CN at all, which previously collapsed every such cert to the same alias. + FP=$(printf '%s' "$FINGERPRINT" | tr -d ':' | tr 'A-Z' 'a-z') + + if [ -n "$CN" ]; then + # Use the CN as the alias, falling back to the fingerprint on collision + ALIAS=$CN + if keytool_truststore -list -storepass changeit -alias "$ALIAS" >/dev/null 2>&1; then + ALIAS="${CN}_${FP}" + fi + else + # No CN available: derive a unique, deterministic alias from the fingerprint + ALIAS="adoptium_${FP}" + fi + + echo "Adding certificate with alias $ALIAS to the JVM truststore" + + # Add the certificate to the JVM truststore + keytool_truststore -import -noprompt -alias "$ALIAS" -file "$crt" -storepass changeit >/dev/null + done + done + + # Add additional certificates to the system CA store. This requires write permissions to several system + # locations, which is not possible in a container with read-only filesystem and/or non-root container. + if [ "$(id -u)" -eq 0 ]; then + + # Copy certificates from /certificates to the system truststore, but only if the directory exists and is not empty. + # The reason why this is not part of the opt-in is because it leaves open the option to mount certificates at the + # system location, for whatever reason. + if [ -d /certificates ] && [ "$(ls -A /certificates 2>/dev/null)" ]; then + {%- if os == "ubuntu" or os == "alpine-linux" %} + cp -La /certificates/* /usr/local/share/ca-certificates/ + {%- elif os == "ubi-minimal" %} + cp -La /certificates/* /usr/share/pki/ca-trust-source/anchors/ + {%- endif %} + fi + + {%- if os == "ubuntu" or os == "alpine-linux" %} + update-ca-certificates + {%- elif os == "ubi-minimal" %} + update-ca-trust + {%- endif %} + else + # If we are not root, we cannot update the system truststore. That's bad news for tools like `curl` and `wget`, + # but since the JVM is the primary focus here, we can live with that. + true + fi +fi + +# Let's provide a variable with the correct path for tools that want or need to use it +export JRE_CACERTS_PATH + +exec "$@" diff --git a/docker_templates/nanoserver.Dockerfile.j2 b/docker_templates/nanoserver.Dockerfile.j2 new file mode 100644 index 0000000000000000000000000000000000000000..60722dab751df0ede206bddda56ebfe0e29968b8 --- /dev/null +++ b/docker_templates/nanoserver.Dockerfile.j2 @@ -0,0 +1,26 @@ +{% include 'partials/license.j2' %} + +FROM {{ base_image }} + +SHELL ["cmd", "/s", "/c"] + +{% include 'partials/java-version.j2' %} + +ENV JAVA_HOME C:\\openjdk-{{ version }} +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:{{ arch_data.copy_from }} $JAVA_HOME $JAVA_HOME + +{% set vflag = "--version" if version|int >= 11 else "-version" -%} +RUN echo Verifying install ... \ + {% if image_type == "jdk" -%} + && echo javac {{ vflag }} && javac {{ vflag }} \ + {% endif -%} + && echo java {{ vflag }} && java {{ vflag }} \ + && echo Complete. +{% include 'partials/jshell.j2' %} diff --git a/docker_templates/partials/binutils.j2 b/docker_templates/partials/binutils.j2 new file mode 100644 index 0000000000000000000000000000000000000000..b4b7872d05b14f8ecedb638d0080af6abf725524 --- /dev/null +++ b/docker_templates/partials/binutils.j2 @@ -0,0 +1,5 @@ +{% if image_type == "jdk" and version|int >= 13 %} + # jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351 + # Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory + binutils \ +{%- endif -%} diff --git a/docker_templates/partials/entrypoint.j2 b/docker_templates/partials/entrypoint.j2 new file mode 100644 index 0000000000000000000000000000000000000000..ff1f83e9b2ab124a612c2ee0dfaea37a51a6e943 --- /dev/null +++ b/docker_templates/partials/entrypoint.j2 @@ -0,0 +1,2 @@ +COPY --chmod=755 entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] diff --git a/docker_templates/partials/java-version.j2 b/docker_templates/partials/java-version.j2 new file mode 100644 index 0000000000000000000000000000000000000000..8f66e6acd68c934b8421bf0b103f00e53b13847a --- /dev/null +++ b/docker_templates/partials/java-version.j2 @@ -0,0 +1 @@ +ENV JAVA_VERSION={{ java_version }} \ No newline at end of file diff --git a/docker_templates/partials/jshell.j2 b/docker_templates/partials/jshell.j2 new file mode 100644 index 0000000000000000000000000000000000000000..9a2e187e8e6d1c27df7f84e004da5e429eebb023 --- /dev/null +++ b/docker_templates/partials/jshell.j2 @@ -0,0 +1,3 @@ +{% if image_type == "jdk" and version|int >= 11 %} +CMD ["jshell"] +{% endif -%} diff --git a/docker_templates/partials/license.j2 b/docker_templates/partials/license.j2 new file mode 100644 index 0000000000000000000000000000000000000000..80dc5feefaa062606680bcd45b431b0545c43d7e --- /dev/null +++ b/docker_templates/partials/license.j2 @@ -0,0 +1,18 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS FILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/docker_templates/partials/multi-arch-install.j2 b/docker_templates/partials/multi-arch-install.j2 new file mode 100644 index 0000000000000000000000000000000000000000..e440a6a591ea47ac3207cc314df5b1f4c38d88cc --- /dev/null +++ b/docker_templates/partials/multi-arch-install.j2 @@ -0,0 +1,62 @@ +RUN set -eux; \ + ARCH="$({{ arch_cmd }})"; \ +{%- set ver = version|int %} + case "${ARCH}" in \ + {% for arch, details in arch_data.items() -%} + {{ arch }}) \ + ESUM='{{ details.checksum }}'; \ + BINARY_URL='{{ details.download_url }}'; \ + {% if arch == "armhf" and os == "ubuntu" and ver == 8 -%} + # Fixes libatomic.so.1: cannot open shared object file + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libatomic1; \ + rm -rf /var/lib/apt/lists/*; \ + {% endif -%} + ;; \ + {% endfor -%} + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + {%- if ver > 24 %} + {%- if os == "alpine-linux" %} + apk add --no-cache --virtual .fetch-deps gnupg; \ + {%- elif os == "ubuntu" %} + savedAptMark="$(apt-mark showmanual)"; \ + apt-get update; \ + apt-get install -y --no-install-recommends wget gnupg; \ + {%- endif %} + {%- endif %} + wget {% if os != "alpine-linux" %}--progress=dot:giga {% endif %}-O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + wget {% if os != "alpine-linux" %}--progress=dot:giga {% endif %}-O /tmp/openjdk.tar.gz.sig ${BINARY_URL}.sig; \ + export GNUPGHOME="$(mktemp -d)"; \ + # gpg: key 843C48A565F8F04B: "Adoptium GPG Key (DEB/RPM Signing Key) " imported + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B; \ + gpg --batch --verify /tmp/openjdk.tar.gz.sig /tmp/openjdk.tar.gz; \ + rm -rf "${GNUPGHOME}" /tmp/openjdk.tar.gz.sig; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + {%- if ver == 8 %} + rm -f /tmp/openjdk.tar.gz{% if image_type == "jdk" %} ${JAVA_HOME}/src.zip{% endif %}; + {%- else %} + rm -f /tmp/openjdk.tar.gz{% if image_type == "jdk" %} ${JAVA_HOME}/lib/src.zip{% endif %}; + {%- if ver > 24 -%} + {%- if os == "alpine-linux" -%} + {{ " " }}\ + apk del --no-network .fetch-deps; + {%- elif os == "ubuntu" -%} + {{ " " }}\ + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark > /dev/null; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/*; + {%- endif %} + {%- endif %} + {%- endif %} diff --git a/docker_templates/partials/nix-env.j2 b/docker_templates/partials/nix-env.j2 new file mode 100644 index 0000000000000000000000000000000000000000..0d19c984107d105a93e9960911032b7d26529caa --- /dev/null +++ b/docker_templates/partials/nix-env.j2 @@ -0,0 +1,5 @@ +ENV JAVA_HOME=/opt/java/openjdk +ENV PATH=$JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' diff --git a/docker_templates/partials/version-check.j2 b/docker_templates/partials/version-check.j2 new file mode 100644 index 0000000000000000000000000000000000000000..6e4358e589fb0e3b626697192313627e3913cf95 --- /dev/null +++ b/docker_templates/partials/version-check.j2 @@ -0,0 +1,11 @@ +{%- set vflag = "--version" if version|int >= 11 else "-version" -%} +RUN set -eux; \ + echo "Verifying install ..."; \ + {% if image_type == "jdk" and version|int >= 11 -%} + fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \ + {% endif -%} + {% if image_type == "jdk" -%} + echo "javac {{ vflag }}"; javac {{ vflag }}; \ + {% endif -%} + echo "java {{ vflag }}"; java {{ vflag }}; \ + echo "Complete." diff --git a/docker_templates/servercore.Dockerfile.j2 b/docker_templates/servercore.Dockerfile.j2 new file mode 100644 index 0000000000000000000000000000000000000000..87a4338872dc9ed55ef5fa537422202d98a717a6 --- /dev/null +++ b/docker_templates/servercore.Dockerfile.j2 @@ -0,0 +1,41 @@ +{% include 'partials/license.j2' %} + +FROM {{ base_image }} + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +{% include 'partials/java-version.j2' %} + +RUN Write-Host ('Downloading {{ arch_data.download_url }} ...'); \ + curl.exe -LfsSo openjdk.msi {{ arch_data.download_url }} ; \ + Write-Host ('Verifying sha256 ({{ arch_data.checksum }}) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne '{{ arch_data.checksum }}') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-{{ version }}' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +{% set vflag = "--version" if version|int >= 11 else "-version" -%} +RUN Write-Host 'Verifying install ...'; \ + {% if image_type == "jdk" -%} + Write-Host 'javac {{ vflag }}'; javac {{ vflag }}; \ + {% endif -%} + Write-Host 'java {{ vflag }}'; java {{ vflag }}; \ + \ + Write-Host 'Complete.' +{% include 'partials/jshell.j2' %} diff --git a/docker_templates/ubi-minimal.Dockerfile.j2 b/docker_templates/ubi-minimal.Dockerfile.j2 new file mode 100644 index 0000000000000000000000000000000000000000..726859072971f7e96626d9bb30b61be4532a0b0d --- /dev/null +++ b/docker_templates/ubi-minimal.Dockerfile.j2 @@ -0,0 +1,39 @@ +{% include 'partials/license.j2' %} + +FROM {{ base_image }} + +{% include 'partials/nix-env.j2' %} + +RUN set -eux; \ + microdnf install -y \ + gzip \ + tar \ + # Required for jlink + binutils \ + tzdata \ + wget \ + # utilities for keeping UBI and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates \ + # Needed to extract CN and generate aliases for certificates + openssl \ + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + glibc-langpack-en \ +{%- if "ubi10" in base_image %} + # Required for gpg in multi-arch-install + gnupg2 \ +{%- endif %} + ; \ + microdnf clean all + +{% include 'partials/java-version.j2' %} + +{% set arch_cmd = "rpm --query --queryformat='%{ARCH}' rpm" -%} +{% include 'partials/multi-arch-install.j2' %} + +{% include 'partials/version-check.j2' %} +{% include 'partials/entrypoint.j2' %} +{% include 'partials/jshell.j2' %} diff --git a/docker_templates/ubuntu.Dockerfile.j2 b/docker_templates/ubuntu.Dockerfile.j2 new file mode 100644 index 0000000000000000000000000000000000000000..bbfccaf5d2c303a5082da63d20c9e575a4ab62ff --- /dev/null +++ b/docker_templates/ubuntu.Dockerfile.j2 @@ -0,0 +1,51 @@ +{% include 'partials/license.j2' %} + +FROM {{ base_image }} + +{% include 'partials/nix-env.j2' %} + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + {% if version|int < 22 -%} + # curl required for historical reasons, see https://github.com/adoptium/containers/issues/255 + curl \ + {% endif -%} + {% if version|int < 25 -%} + wget \ + # gnupg required to verify the signature + gnupg \ + {% endif -%} + # java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory + # java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager + # https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 + fontconfig \ + # utilities for keeping Ubuntu and OpenJDK CA certificates in sync + # https://github.com/adoptium/containers/issues/293 + ca-certificates p11-kit \ + {%- include 'partials/binutils.j2' %} + tzdata \ + # locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 + locales \ + ; \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ + locale-gen en_US.UTF-8; \ + rm -rf /var/lib/apt/lists/* + +{% include 'partials/java-version.j2' %} + +{% set arch_cmd = "dpkg --print-architecture" -%} +{% include 'partials/multi-arch-install.j2' %} \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + {% if version|int >= 11 -%} + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; +{% else -%} + ldconfig; +{% endif %} +{% include 'partials/version-check.j2' %} +{% include 'partials/entrypoint.j2' %} +{% include 'partials/jshell.j2' %} diff --git a/dockerhub_doc_config_update.py b/dockerhub_doc_config_update.py new file mode 100755 index 0000000000000000000000000000000000000000..317d65c1af605effdcce409e6b0fd24741820496 --- /dev/null +++ b/dockerhub_doc_config_update.py @@ -0,0 +1,319 @@ +#!/usr/bin/env python3 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Script that generates the `eclipse-temurin` config file for the official docker +# image github repo and the doc updates for the unofficial docker image repo. +# Process to update the official docker image repo +# 1. Run generate_dockerfiles.py to update all the dockerfiles in the current repo. +# 2. Submit PR to push the newly generated dockerfiles to the current repo. +# 3. After above PR is merged, git pull the latest changes. +# 4. Run this command + +import os +import re +import subprocess +import sys +import urllib.request + +import yaml + +from adoptium_api import get_latest_lts, get_supported_versions +from eol_checker import print_eol_warnings + +OFFICIAL_MANIFEST_URL = ( + "https://raw.githubusercontent.com/docker-library/official-images/" + "master/library/eclipse-temurin" +) + + +def load_config(): + with open("config/temurin.yml", "r") as f: + return yaml.safe_load(f) + + +def get_git_commit(): + result = subprocess.run( + ["git", "rev-parse", "HEAD"], capture_output=True, text=True, check=True + ) + return result.stdout.strip() + + +def fetch_official_manifest(): + """Fetch the current official manifest for diff comparison.""" + try: + req = urllib.request.Request(OFFICIAL_MANIFEST_URL) + with urllib.request.urlopen(req) as response: + return response.read().decode("utf-8") + except Exception: + return "" + + +def get_java_version(dockerfile_path): + """Extract JAVA_VERSION from a Dockerfile.""" + with open(dockerfile_path, "r") as f: + for line in f: + if "JAVA_VERSION=" in line: + return line.split("=")[1].strip() + return None + + +def format_ojdk_version(full_version): + """Convert JAVA_VERSION to Docker tag-compatible version string. + + Examples: + jdk8u482-b08 -> 8u482-b08 + jdk-25.0.1+9 -> 25.0.1_9 + """ + version = re.sub(r"^jdk-?", "", full_version) + version = version.replace("+", "_") + return version + + +def get_distro_name(os_family, directory): + """Derive the distro tag name from the config directory.""" + name = directory.split("/")[-1] + if os_family == "alpine-linux": + return f"alpine-{name}" + return name + + +# Map Dockerfile arch names to Docker Hub official image architecture names +DOCKERFILE_ARCH_MAP = { + "amd64": "amd64", + "x86_64": "amd64", + "arm64": "arm64v8", + "aarch64": "arm64v8", + "armhf": "arm32v7", + "ppc64el": "ppc64le", + "ppc64le": "ppc64le", + "s390x": "s390x", + "riscv64": "riscv64", +} + + +def get_dockerfile_arches(dockerfile_path): + """Parse architectures from the case statement in a Dockerfile.""" + arches = [] + with open(dockerfile_path, "r") as f: + for line in f: + match = re.match(r'\s+(\w+)\)\s*\\?\s*$', line) + if match: + arch = match.group(1) + if arch in DOCKERFILE_ARCH_MAP: + arches.append(DOCKERFILE_ARCH_MAP[arch]) + return sorted(set(arches)) + + +def find_manifest_block(official_manifest, tags_str): + """Find the manifest block matching the given tags in the official manifest.""" + if not official_manifest: + return None + for block in official_manifest.split("\n\n"): + if tags_str in block: + return block + return None + + +def get_block_gitcommit(block): + """Extract GitCommit from a manifest block.""" + if not block: + return None + for line in block.split("\n"): + if line.startswith("GitCommit:"): + return line.split(":")[1].strip() + return None + + +def has_changed(gitcommit, official_gitcommit, dfdir): + """Check if Dockerfile or entrypoint.sh changed between two git commits.""" + if not official_gitcommit: + return True + try: + result = subprocess.run( + [ + "git", "diff", + f"{gitcommit}:{dfdir}/Dockerfile", + f"{official_gitcommit}:{dfdir}/Dockerfile", + ], + capture_output=True, text=True, + ) + if result.returncode != 0: + return True + diff_lines = len(result.stdout.splitlines()) + + entrypoint = os.path.join(dfdir, "entrypoint.sh") + if os.path.exists(entrypoint): + result = subprocess.run( + [ + "git", "diff", + f"{gitcommit}:{dfdir}/entrypoint.sh", + f"{official_gitcommit}:{dfdir}/entrypoint.sh", + ], + capture_output=True, text=True, + ) + if result.returncode != 0: + return True + diff_lines += len(result.stdout.splitlines()) + + return diff_lines > 0 + except Exception: + return True + + +def generate_manifest(config, output_file): + gitcommit = get_git_commit() + official_manifest = fetch_official_manifest() + + versions = get_supported_versions() + latest_version = get_latest_lts() + # Default images are the first entry in each OS family + default_linux_image = get_distro_name("linux", config["configurations"]["linux"][0]["directory"]) + default_alpine_image = get_distro_name("alpine-linux", config["configurations"]["alpine-linux"][0]["directory"]) + + lines = [] + + # Header + lines.append("# Eclipse Temurin OpenJDK images provided by the Eclipse Foundation.") + lines.append("") + lines.append("Maintainers: George Adams (@gdams),") + lines.append(" Stewart Addison (@sxa)") + lines.append("GitRepo: https://github.com/adoptium/containers.git") + lines.append("GitFetch: refs/heads/main") + lines.append("Builder: buildkit") + + # OS family iteration order matches the original script + os_family_order = ["alpine-linux", "linux", "windows"] + + for ver in versions: + lines.append("") + lines.append( + f"#------------------------------v{ver} images---------------------------------" + ) + + for pkg in ["jdk", "jre"]: + for os_family in os_family_order: + if os_family not in config["configurations"]: + continue + + for cfg in config["configurations"][os_family]: + directory = cfg["directory"] + architectures = cfg["architectures"] + deprecated = cfg.get("deprecated", None) + cfg_versions = cfg.get("versions", versions) + + if ver not in cfg_versions: + continue + if deprecated and ver >= deprecated: + continue + + dfdir = os.path.join(str(ver), pkg, directory) + dockerfile = os.path.join(dfdir, "Dockerfile") + + if not os.path.exists(dockerfile): + continue + + full_version = get_java_version(dockerfile) + if not full_version: + continue + + ojdk_version = format_ojdk_version(full_version) + distro = get_distro_name(os_family, directory) + is_windows = os_family == "windows" + + # Build tags + full_ver_tag = f"{ojdk_version}-{pkg}-{distro}" + ver_tag = f"{ver}-{pkg}-{distro}" + all_tags = f"{full_ver_tag}, {ver_tag}" + + extra_shared_tags = "" + if pkg == "jdk": + jdk_tag = f"{ver}-{distro}" + all_tags = f"{all_tags}, {jdk_tag}" + if ver == latest_version and os_family != "alpine-linux": + extra_shared_tags = ", latest" + + # Shared tags = tags without distro suffix + shared_tags = all_tags.replace(f"-{distro}", "") + + if is_windows: + parts = distro.split("-", 1) + windows_version = parts[0] + windows_version_number = parts[1] if len(parts) > 1 else "" + windows_shared_tags = all_tags.replace(distro, windows_version) + + if distro.startswith("nanoserver"): + constraints = ( + f"{distro}, windowsservercore-{windows_version_number}" + ) + all_shared_tags = windows_shared_tags + else: + constraints = distro + all_shared_tags = ( + f"{windows_shared_tags}, " + f"{shared_tags}{extra_shared_tags}" + ) + else: + all_shared_tags = f"{shared_tags}{extra_shared_tags}" + + # Compare with official manifest (before appending alpine aliases) + manifest_block = find_manifest_block(official_manifest, all_tags) + official_gitcommit = get_block_gitcommit(manifest_block) + + if official_gitcommit and not has_changed( + gitcommit, official_gitcommit, dfdir + ): + commit = official_gitcommit + else: + commit = gitcommit + + # Append alpine alias tags for the default alpine image + if distro == default_alpine_image: + alpine_aliases = ( + all_shared_tags.replace(", ", "-alpine, ") + "-alpine" + ) + all_tags = f"{all_tags}, {alpine_aliases}" + + # Write entry + lines.append(f"Tags: {all_tags}") + if is_windows or distro == default_linux_image: + lines.append(f"SharedTags: {all_shared_tags}") + if is_windows: + lines.append("Architectures: windows-amd64") + else: + arches = ", ".join(get_dockerfile_arches(dockerfile)) + lines.append(f"Architectures: {arches}") + lines.append(f"GitCommit: {commit}") + lines.append(f"Directory: {dfdir}") + if is_windows: + lines.append("Builder: classic") + lines.append(f"Constraints: {constraints}") + lines.append("") + + with open(output_file, "w") as f: + # Remove trailing empty lines before writing + while lines and lines[-1] == "": + lines.pop() + f.write("\n".join(lines)) + f.write("\n") + + +def main(): + output_file = sys.argv[1] if len(sys.argv) > 1 else "eclipse-temurin" + config = load_config() + print_eol_warnings(config) + generate_manifest(config, output_file) + + +if __name__ == "__main__": + main() diff --git a/eol_checker.py b/eol_checker.py new file mode 100644 index 0000000000000000000000000000000000000000..e500fd57953a0f31f9ca5b08693e5a9ec57b4048 --- /dev/null +++ b/eol_checker.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python3 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Fetch EOL dates from endoflife.date API for base images.""" + +import re +import sys +import urllib.request +import json +from datetime import date, datetime + +ENDOFLIFE_API = "https://endoflife.date/api" + +# Map os config values to endoflife.date product names +OS_TO_PRODUCT = { + "ubuntu": "ubuntu", + "alpine-linux": "alpine", + "ubi-minimal": "rhel", +} + +# Regex to extract version from image string (e.g. "ubuntu:26.04" -> "26.04", +# "redhat/ubi9-minimal" -> "9", "alpine:3.24" -> "3.24") +IMAGE_VERSION_PATTERNS = [ + # standard image:tag format + re.compile(r":(\d[\d.]*)$"), + # UBI images like redhat/ubi9-minimal -> extract major version + re.compile(r"/ubi(\d+)"), +] + + +def _extract_cycle(image): + """Extract the version/cycle string from a Docker image reference.""" + for pattern in IMAGE_VERSION_PATTERNS: + m = pattern.search(image) + if m: + return m.group(1) + return None + + +def fetch_eol_date(product, cycle): + """Fetch the EOL date for a product cycle from endoflife.date. + + Returns a date object or None if the lookup fails. + """ + url = f"{ENDOFLIFE_API}/{product}/{cycle}.json" + try: + req = urllib.request.Request(url, headers={"User-Agent": "Adoptium EOL Checker"}) + with urllib.request.urlopen(req, timeout=10) as resp: + data = json.loads(resp.read().decode("utf-8")) + eol = data.get("eol") + if isinstance(eol, bool): + # Some products return eol: false (meaning not yet EOL) + return None + if eol: + return datetime.strptime(eol, "%Y-%m-%d").date() + except Exception: + pass + return None + + +def get_eol_date(configuration): + """Get the EOL date for a configuration entry. + + Priority: + 1. Hardcoded 'eol' field in the config (as fallback/override) + 2. Lookup from endoflife.date API based on os + image + """ + # Check for hardcoded override first + eol_str = configuration.get("eol") + if eol_str: + if isinstance(eol_str, date): + return eol_str + return datetime.strptime(str(eol_str), "%Y-%m-%d").date() + + os_name = configuration.get("os", "") + image = configuration.get("image", "") + + product = OS_TO_PRODUCT.get(os_name) + if not product: + return None + + cycle = _extract_cycle(image) + if not cycle: + return None + + return fetch_eol_date(product, cycle) + + +def check_eol_configs(config): + """Check all configurations for EOL status. + + Returns a list of (configuration, eol_date) tuples for entries past EOL. + """ + today = date.today() + expired = [] + + for os_family, configurations in config.get("configurations", {}).items(): + for cfg in configurations: + eol_date = get_eol_date(cfg) + if eol_date and eol_date <= today: + expired.append((cfg, eol_date)) + + return expired + + +def print_eol_warnings(config, file=sys.stderr): + """Print warnings for any expired distros. Returns the list of expired entries.""" + expired = check_eol_configs(config) + if expired: + print(f"\n⚠ {len(expired)} distro(s) past EOL:", file=file) + for cfg, eol_date in expired: + image = cfg.get("image", cfg.get("directory", "unknown")) + directory = cfg.get("directory", "") + print(f" - {image} ({directory}) expired {eol_date}", file=file) + return expired + + +if __name__ == "__main__": + import yaml + + with open("config/temurin.yml") as f: + config = yaml.safe_load(f) + + print("Distro EOL dates:") + for os_family, configurations in config.get("configurations", {}).items(): + for cfg in configurations: + image = cfg.get("image", cfg.get("directory", "unknown")) + eol = get_eol_date(cfg) + eol_str = str(eol) if eol else "unknown" + print(f" {image}: {eol_str}") + + print() + expired = print_eol_warnings(config, file=sys.stdout) + if not expired: + print("All distros are within their EOL dates.") + sys.exit(1 if expired else 0) diff --git a/generate_dockerfiles.py b/generate_dockerfiles.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b7ae14f77a6abe3d022224da6199398d2a0258 --- /dev/null +++ b/generate_dockerfiles.py @@ -0,0 +1,263 @@ +#!/usr/bin/env python3 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import argparse +import operator +import os +import re +import shutil +import sys + +import requests +import requests_cache +import yaml +from jinja2 import Environment, FileSystemLoader + +from adoptium_api import get_supported_versions +from eol_checker import print_eol_warnings + +requests_cache.install_cache("adoptium_cache", expire_after=3600) + + +VERSION_OPERATORS = { + "==": operator.eq, + "!=": operator.ne, + ">=": operator.ge, + "<=": operator.le, + ">": operator.gt, + "<": operator.lt, +} + +VERSION_CONDITION_RE = re.compile(r"^(==|!=|>=|<=|>|<)(\d+)$") + + +def resolve_architectures(default_architectures, overrides, version): + """Resolve effective architectures for a given version by applying overrides. + + All matching overrides are applied in order. Each override has a 'versions' + string (e.g. '==8', '<=11', '>17') and either: + - 'exclude': list of architectures to remove + - 'include': list of architectures to add + - 'architectures': full replacement list (overrides default entirely) + """ + if not overrides: + return default_architectures + + result = list(default_architectures) + for override in overrides: + condition = override["versions"].strip() + match = VERSION_CONDITION_RE.match(condition) + if not match: + raise ValueError(f"Invalid version condition: '{condition}'") + op_str, target = match.groups() + if VERSION_OPERATORS[op_str](version, int(target)): + if "architectures" in override: + result = list(override["architectures"]) + if "exclude" in override: + result = [a for a in result if a not in override["exclude"]] + if "include" in override: + result = result + [a for a in override["include"] if a not in result] + + return result + + +def archHelper(arch, os_name): + if arch == "aarch64" and os_name == "ubuntu": + return "arm64" + elif arch == "ppc64le" and os_name == "ubuntu": + return "ppc64el" + elif arch == "arm": + return "armhf" + elif arch == "x64": + if os_name == "ubuntu": + return "amd64" + else: + return "x86_64" + else: + return arch + + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + description="Generate Dockerfiles for Eclipse Temurin images" + ) + + # Setup the Jinja2 environment + env = Environment( + loader=FileSystemLoader("docker_templates"), trim_blocks=False, lstrip_blocks=False + ) + + headers = { + "User-Agent": "Adoptium Dockerfile Updater", + } + + # Flag for force removing old Dockerfiles + parser.add_argument("--force", action="store_true", help="Force remove old Dockerfiles") + + args = parser.parse_args() + + # Remove old Dockerfiles if --force is set + if args.force: + # Remove all top level dirs that are numbers + for dir in os.listdir(): + if dir.isdigit(): + print(f"Removing {dir}") + shutil.rmtree(dir) + + + # Load the YAML configuration + with open("config/temurin.yml", "r") as file: + config = yaml.safe_load(file) + + # Global architecture overrides apply to all configurations + global_architecture_overrides = config.get("architecture_overrides", []) + + # Fetch supported versions from the Adoptium API + supported_versions = get_supported_versions() + + # Iterate through OS families and then configurations + # Check for expired distros + print_eol_warnings(config) + + for os_family, configurations in config["configurations"].items(): + for configuration in configurations: + directory = configuration["directory"] + default_architectures = configuration["architectures"] + local_overrides = configuration.get("architecture_overrides", []) + architecture_overrides = global_architecture_overrides + local_overrides + os_name = configuration["os"] + base_image = configuration["image"] + deprecated = configuration.get("deprecated", None) + versions = configuration.get("versions", supported_versions) + + # Define the path for the template based on OS + template_name = f"{os_name}.Dockerfile.j2" + template = env.get_template(template_name) + + # Create output directories if they don't exist + for version in versions: + # if deprecated is set and version is greater than or equal to deprecated, skip + if deprecated and version >= deprecated: + continue + + architectures = resolve_architectures(default_architectures, architecture_overrides, version) + print("Generating Dockerfiles for", base_image, "-", version) + for image_type in ["jdk", "jre"]: + output_directory = os.path.join(str(version), image_type, directory) + os.makedirs(output_directory, exist_ok=True) + + # Fetch latest release for version from Adoptium API + url = f"https://api.adoptium.net/v3/assets/feature_releases/{version}/ga?page=0&image_type={image_type}&os={os_family}&page_size=1&vendor=eclipse" + response = requests.get(url, headers=headers) + + # Handle 404 errors gracefully - skip this version if not available + if response.status_code == 404: + print(f"Version {version} not available for {image_type} on {os_family}, skipping...") + continue + + response.raise_for_status() + data = response.json() + + release = response.json()[0] + + # Extract the version number from the release name + openjdk_version = release["release_name"] + + # If version doesn't equal 8, get the more accurate version number + if version != 8: + openjdk_version = ( + "jdk-" + release["version_data"]["openjdk_version"] + ) + # if openjdk_version contains -LTS remove it + if "-LTS" in openjdk_version: + openjdk_version = openjdk_version.replace("-LTS", "") + + # Generate the data for each architecture + arch_data = {} + + for binary in release["binaries"]: + if ( + binary["architecture"] in architectures + and binary["os"] == os_family + ): + if os_family == "windows": + # Windows only has x64 binaries + copy_from = openjdk_version.replace( + "jdk", "" + ) # jdk8u292-b10 -> 8u292-b10 + if version != 8: + copy_from = copy_from.replace("-", "").replace( + "+", "_" + ) # 11.0.11+9 -> 11.0.11_9 + copy_from = f"{copy_from}-{image_type}-windowsservercore-{base_image.split(':')[1]}" + arch_data = { + "download_url": binary["installer"]["link"], + "checksum": binary["installer"]["checksum"], + "copy_from": copy_from, + } + else: + arch_data[archHelper(binary["architecture"], os_name)] = { + "download_url": binary["package"]["link"], + "checksum": binary["package"]["checksum"], + } + + else: + continue + + # If arch_data is empty, skip updating the dockerfile + if arch_data.__len__() == 0: + continue + + # Sort arch_data by key + arch_data = dict(sorted(arch_data.items())) + + # Generate Dockerfile for each architecture + rendered_dockerfile = template.render( + base_image=base_image, + image_type=image_type, + java_version=openjdk_version, + version=version, + arch_data=arch_data, + os_family=os_family, + os=os_name, + ) + + print("Writing Dockerfile to", output_directory) + # Save the rendered Dockerfile + with open( + os.path.join(output_directory, "Dockerfile"), "w" + ) as out_file: + out_file.write(rendered_dockerfile) + + if os_family != "windows": + # Entrypoint is currently only needed for CA certificate handling, which is not (yet) + # available on Windows + + # Generate entrypoint.sh + template_entrypoint_file = "entrypoint.sh.j2" + template_entrypoint = env.get_template(template_entrypoint_file) + + entrypoint = template_entrypoint.render( + image_type=image_type, + os=os_name, + version=version, + ) + + with open( + os.path.join(output_directory, "entrypoint.sh"), "w" + ) as out_file: + out_file.write(entrypoint) + + print("Dockerfiles generated successfully!") diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..5a7adceda33e67e96b5b74756b616bc3a39b7830 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +Jinja2==3.1.6 +PyYAML==6.0.1 +Requests==2.33.0 +requests-cache==1.2.0 diff --git a/sanity.sh b/sanity.sh new file mode 100755 index 0000000000000000000000000000000000000000..48062817e473270517e7c2d913e210c14c0a707f --- /dev/null +++ b/sanity.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +set -o pipefail + +# Check for empty Shasum +if [[ $(grep -R ESUM=\'\' . | wc -l | awk '{print $1}') != 0 ]]; then + echo "detected empty ESUM" + exit 1 +fi + +# Check for empty Binary URL +if [[ $(grep -R BINARY_URL=\'\' . | wc -l | awk '{print $1}') != 0 ]]; then + echo "detected empty Binary URL" + exit 1 +fi + +# Check for empty Shasum Windows +if [[ $(grep -R "Hash -ne '\'" . | wc -l | awk '{print $1}') != 0 ]]; then + echo "detected empty Hash" + exit 1 +fi + +# Check for empty Binary URL Windows +if [[ $(grep -R 'Downloading \.\.\.' . | wc -l | awk '{print $1}') != 0 ]]; then + echo "detected empty Binary URL" + exit 1 +fi \ No newline at end of file diff --git a/test_dockerhub_doc_config_update.py b/test_dockerhub_doc_config_update.py new file mode 100644 index 0000000000000000000000000000000000000000..99df86846c94884c9cc9a99bdd691d1f16f7a535 --- /dev/null +++ b/test_dockerhub_doc_config_update.py @@ -0,0 +1,384 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import json +import os +import tempfile +import textwrap +import unittest +from unittest.mock import patch + +from adoptium_api import get_latest_lts, get_supported_versions +from dockerhub_doc_config_update import ( + find_manifest_block, + format_ojdk_version, + get_block_gitcommit, + get_distro_name, + get_dockerfile_arches, + get_java_version, + generate_manifest, +) + + +MOCK_API_RESPONSE = { + "available_lts_releases": [8, 11, 17, 21, 25], + "available_releases": [8, 11, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26], + "most_recent_feature_release": 26, + "most_recent_feature_version": 27, + "most_recent_lts": 25, + "tip_version": 27, +} + + +def mock_urlopen(req): + """Mock urllib.request.urlopen to return fake API data.""" + class MockResponse: + def read(self): + return json.dumps(MOCK_API_RESPONSE).encode("utf-8") + def __enter__(self): + return self + def __exit__(self, *args): + pass + return MockResponse() + + +class TestAdoptiumAPI(unittest.TestCase): + + @patch("adoptium_api.urllib.request.urlopen", side_effect=mock_urlopen) + def test_get_supported_versions(self, _mock): + versions = get_supported_versions() + self.assertEqual(versions, [8, 11, 17, 21, 25, 26]) + + @patch("adoptium_api.urllib.request.urlopen", side_effect=mock_urlopen) + def test_get_supported_versions_lts_only(self, _mock): + """When most_recent_feature_release equals most_recent_lts, only LTS versions are returned.""" + with patch.dict(MOCK_API_RESPONSE, {"most_recent_feature_release": 25}): + versions = get_supported_versions() + self.assertEqual(versions, [8, 11, 17, 21, 25]) + + @patch("adoptium_api.urllib.request.urlopen", side_effect=mock_urlopen) + def test_get_supported_versions_multiple_non_lts(self, _mock): + """When there are multiple non-LTS releases between the latest LTS and the most recent feature release.""" + with patch.dict(MOCK_API_RESPONSE, {"most_recent_feature_release": 28, "available_releases": [8, 11, 17, 21, 25, 26, 27, 28]}): + versions = get_supported_versions() + self.assertEqual(versions, [8, 11, 17, 21, 25, 26, 27, 28]) + + @patch("adoptium_api.urllib.request.urlopen", side_effect=mock_urlopen) + def test_get_latest_lts(self, _mock): + self.assertEqual(get_latest_lts(), 25) + + +class TestFormatOjdkVersion(unittest.TestCase): + + def test_jdk8_version(self): + self.assertEqual(format_ojdk_version("jdk8u482-b08"), "8u482-b08") + + def test_jdk11_version(self): + self.assertEqual(format_ojdk_version("jdk-11.0.30+7"), "11.0.30_7") + + def test_jdk25_version(self): + self.assertEqual(format_ojdk_version("jdk-25.0.2+10"), "25.0.2_10") + + def test_jdk26_ea_version(self): + self.assertEqual(format_ojdk_version("jdk-26+35"), "26_35") + + +class TestGetDistroName(unittest.TestCase): + + def test_ubuntu(self): + self.assertEqual(get_distro_name("linux", "ubuntu/noble"), "noble") + + def test_alpine(self): + self.assertEqual(get_distro_name("alpine-linux", "alpine/3.23"), "alpine-3.23") + + def test_ubi(self): + self.assertEqual(get_distro_name("linux", "ubi/ubi10-minimal"), "ubi10-minimal") + + def test_windows(self): + self.assertEqual( + get_distro_name("windows", "windows/windowsservercore-ltsc2022"), + "windowsservercore-ltsc2022", + ) + + +class TestGetJavaVersion(unittest.TestCase): + + def test_extracts_version(self): + with tempfile.NamedTemporaryFile(mode="w", suffix=".Dockerfile", delete=False) as f: + f.write("FROM ubuntu:24.04\n") + f.write("ENV JAVA_VERSION=jdk-25.0.2+10\n") + f.write("RUN echo hello\n") + f.flush() + self.assertEqual(get_java_version(f.name), "jdk-25.0.2+10") + os.unlink(f.name) + + def test_returns_none_when_missing(self): + with tempfile.NamedTemporaryFile(mode="w", suffix=".Dockerfile", delete=False) as f: + f.write("FROM ubuntu:24.04\n") + f.write("RUN echo hello\n") + f.flush() + self.assertIsNone(get_java_version(f.name)) + os.unlink(f.name) + + +class TestGetDockerfileArches(unittest.TestCase): + + def test_parses_ubuntu_arches(self): + dockerfile = textwrap.dedent("""\ + FROM ubuntu:24.04 + RUN set -eux; \\ + ARCH="$(dpkg --print-architecture)"; \\ + case "${ARCH}" in \\ + amd64) \\ + ESUM='abc123'; \\ + ;; \\ + arm64) \\ + ESUM='def456'; \\ + ;; \\ + ppc64el) \\ + ESUM='ghi789'; \\ + ;; \\ + s390x) \\ + ESUM='jkl012'; \\ + ;; \\ + *) \\ + echo "Unsupported arch: ${ARCH}"; \\ + exit 1; \\ + ;; \\ + esac; + """) + with tempfile.NamedTemporaryFile(mode="w", suffix=".Dockerfile", delete=False) as f: + f.write(dockerfile) + f.flush() + arches = get_dockerfile_arches(f.name) + self.assertEqual(arches, ["amd64", "arm64v8", "ppc64le", "s390x"]) + os.unlink(f.name) + + def test_parses_alpine_arches(self): + dockerfile = textwrap.dedent("""\ + FROM alpine:3.23 + RUN set -eux; \\ + ARCH="$(apk --print-arch)"; \\ + case "${ARCH}" in \\ + x86_64) \\ + ESUM='abc123'; \\ + ;; \\ + aarch64) \\ + ESUM='def456'; \\ + ;; \\ + *) \\ + echo "Unsupported arch: ${ARCH}"; \\ + exit 1; \\ + ;; \\ + esac; + """) + with tempfile.NamedTemporaryFile(mode="w", suffix=".Dockerfile", delete=False) as f: + f.write(dockerfile) + f.flush() + arches = get_dockerfile_arches(f.name) + self.assertEqual(arches, ["amd64", "arm64v8"]) + os.unlink(f.name) + + def test_parses_armhf(self): + dockerfile = textwrap.dedent("""\ + FROM ubuntu:22.04 + RUN set -eux; \\ + case "${ARCH}" in \\ + amd64) \\ + ;; \\ + armhf) \\ + ;; \\ + *) \\ + ;; \\ + esac; + """) + with tempfile.NamedTemporaryFile(mode="w", suffix=".Dockerfile", delete=False) as f: + f.write(dockerfile) + f.flush() + arches = get_dockerfile_arches(f.name) + self.assertEqual(arches, ["amd64", "arm32v7"]) + os.unlink(f.name) + + def test_staggered_release_fewer_arches(self): + """A Dockerfile with only amd64 and arm64 (e.g. early access release).""" + dockerfile = textwrap.dedent("""\ + FROM ubuntu:24.04 + RUN set -eux; \\ + case "${ARCH}" in \\ + amd64) \\ + ;; \\ + arm64) \\ + ;; \\ + *) \\ + ;; \\ + esac; + """) + with tempfile.NamedTemporaryFile(mode="w", suffix=".Dockerfile", delete=False) as f: + f.write(dockerfile) + f.flush() + arches = get_dockerfile_arches(f.name) + self.assertEqual(arches, ["amd64", "arm64v8"]) + os.unlink(f.name) + + +class TestFindManifestBlock(unittest.TestCase): + + SAMPLE_MANIFEST = ( + "Tags: 25.0.2_10-jdk-noble, 25-jdk-noble\n" + "Architectures: amd64, arm64v8\n" + "GitCommit: abc123\n" + "Directory: 25/jdk/ubuntu/noble\n" + "\n" + "Tags: 26_35-jdk-noble, 26-jdk-noble\n" + "Architectures: amd64\n" + "GitCommit: def456\n" + "Directory: 26/jdk/ubuntu/noble" + ) + + def test_finds_matching_block(self): + block = find_manifest_block(self.SAMPLE_MANIFEST, "25.0.2_10-jdk-noble, 25-jdk-noble") + self.assertIn("GitCommit: abc123", block) + + def test_returns_none_for_no_match(self): + block = find_manifest_block(self.SAMPLE_MANIFEST, "99-jdk-noble") + self.assertIsNone(block) + + def test_returns_none_for_empty_manifest(self): + self.assertIsNone(find_manifest_block("", "25-jdk-noble")) + self.assertIsNone(find_manifest_block(None, "25-jdk-noble")) + + +class TestGetBlockGitcommit(unittest.TestCase): + + def test_extracts_commit(self): + block = "Tags: 25-jdk-noble\nGitCommit: abc123def\nDirectory: 25/jdk" + self.assertEqual(get_block_gitcommit(block), "abc123def") + + def test_returns_none_for_no_commit(self): + block = "Tags: 25-jdk-noble\nDirectory: 25/jdk" + self.assertIsNone(get_block_gitcommit(block)) + + def test_returns_none_for_none(self): + self.assertIsNone(get_block_gitcommit(None)) + + +class TestGenerateManifest(unittest.TestCase): + """Integration test using a minimal config and temp Dockerfiles.""" + + def setUp(self): + self.tmpdir = tempfile.mkdtemp() + # Create a minimal Dockerfile + jdk_dir = os.path.join(self.tmpdir, "25", "jdk", "ubuntu", "noble") + os.makedirs(jdk_dir) + with open(os.path.join(jdk_dir, "Dockerfile"), "w") as f: + f.write(textwrap.dedent("""\ + FROM ubuntu:24.04 + ENV JAVA_VERSION=jdk-25.0.2+10 + RUN set -eux; \\ + ARCH="$(dpkg --print-architecture)"; \\ + case "${ARCH}" in \\ + amd64) \\ + ESUM='abc'; \\ + ;; \\ + arm64) \\ + ESUM='def'; \\ + ;; \\ + *) \\ + echo "Unsupported"; \\ + exit 1; \\ + ;; \\ + esac; + """)) + + self.config = { + "configurations": { + "linux": [{ + "directory": "ubuntu/noble", + "image": "ubuntu:24.04", + "architectures": ["aarch64", "x64"], + "os": "ubuntu", + }], + "alpine-linux": [{ + "directory": "alpine/3.23", + "image": "alpine:3.23", + "architectures": ["aarch64", "x64"], + "os": "alpine-linux", + }], + }, + } + self.output_file = os.path.join(self.tmpdir, "eclipse-temurin") + self.orig_dir = os.getcwd() + os.chdir(self.tmpdir) + + def tearDown(self): + os.chdir(self.orig_dir) + import shutil + shutil.rmtree(self.tmpdir) + + @patch("dockerhub_doc_config_update.get_supported_versions", return_value=[25]) + @patch("dockerhub_doc_config_update.get_latest_lts", return_value=25) + @patch("dockerhub_doc_config_update.get_git_commit", return_value="abc123") + @patch("dockerhub_doc_config_update.fetch_official_manifest", return_value="") + def test_generates_valid_manifest(self, _fetch, _git, _lts, _versions): + generate_manifest(self.config, self.output_file) + + with open(self.output_file) as f: + content = f.read() + + # Check header + self.assertIn("# Eclipse Temurin OpenJDK images provided by the Eclipse Foundation.", content) + self.assertIn("GitRepo: https://github.com/adoptium/containers.git", content) + self.assertIn("Builder: buildkit", content) + + # Check tags for v25 JDK noble + self.assertIn("Tags: 25.0.2_10-jdk-noble, 25-jdk-noble, 25-noble", content) + self.assertIn("SharedTags: 25.0.2_10-jdk, 25-jdk, 25, latest", content) + + # Architectures come from the Dockerfile, not config + self.assertIn("Architectures: amd64, arm64v8", content) + + # GitCommit + self.assertIn("GitCommit: abc123", content) + self.assertIn("Directory: 25/jdk/ubuntu/noble", content) + + @patch("dockerhub_doc_config_update.get_supported_versions", return_value=[25]) + @patch("dockerhub_doc_config_update.get_latest_lts", return_value=25) + @patch("dockerhub_doc_config_update.get_git_commit", return_value="abc123") + @patch("dockerhub_doc_config_update.fetch_official_manifest", return_value="") + def test_no_trailing_blank_lines(self, _fetch, _git, _lts, _versions): + generate_manifest(self.config, self.output_file) + + with open(self.output_file) as f: + content = f.read() + + # File should end with exactly one newline + self.assertTrue(content.endswith("\n")) + self.assertFalse(content.endswith("\n\n")) + + @patch("dockerhub_doc_config_update.get_supported_versions", return_value=[25]) + @patch("dockerhub_doc_config_update.get_latest_lts", return_value=25) + @patch("dockerhub_doc_config_update.get_git_commit", return_value="abc123") + @patch("dockerhub_doc_config_update.fetch_official_manifest", return_value="") + def test_skips_missing_dockerfiles(self, _fetch, _git, _lts, _versions): + """Entries for os families with no Dockerfiles on disk should be skipped.""" + generate_manifest(self.config, self.output_file) + + with open(self.output_file) as f: + content = f.read() + + # alpine-linux config exists but no Dockerfile was created for it + self.assertNotIn("alpine-3.23", content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test_eol_checker.py b/test_eol_checker.py new file mode 100644 index 0000000000000000000000000000000000000000..d0e337af4877d70e4897a5db3c0ecb791038c777 --- /dev/null +++ b/test_eol_checker.py @@ -0,0 +1,188 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import json +import unittest +from datetime import date +from unittest.mock import patch, MagicMock + +from eol_checker import ( + OS_TO_PRODUCT, + _extract_cycle, + check_eol_configs, + fetch_eol_date, + get_eol_date, +) + + +def _mock_urlopen(response_data): + """Create a mock for urllib.request.urlopen that returns JSON data.""" + mock_resp = MagicMock() + mock_resp.read.return_value = json.dumps(response_data).encode("utf-8") + mock_resp.__enter__ = lambda s: s + mock_resp.__exit__ = MagicMock(return_value=False) + return mock_resp + + +class TestExtractCycle(unittest.TestCase): + + def test_ubuntu_image(self): + self.assertEqual(_extract_cycle("ubuntu:26.04"), "26.04") + + def test_alpine_image(self): + self.assertEqual(_extract_cycle("alpine:3.21"), "3.21") + + def test_ubi_image(self): + self.assertEqual(_extract_cycle("redhat/ubi9-minimal"), "9") + + def test_ubi10_image(self): + self.assertEqual(_extract_cycle("redhat/ubi10-minimal"), "10") + + def test_no_version(self): + self.assertIsNone(_extract_cycle("scratch")) + + def test_windows_image(self): + # Windows images use non-numeric tags like ltsc2022 + self.assertIsNone(_extract_cycle("mcr.microsoft.com/windows/servercore:ltsc2022")) + + +class TestFetchEolDate(unittest.TestCase): + + @patch("eol_checker.urllib.request.urlopen") + def test_returns_date(self, mock_urlopen_fn): + mock_urlopen_fn.return_value = _mock_urlopen({"eol": "2027-11-01"}) + result = fetch_eol_date("alpine", "3.23") + self.assertEqual(result, date(2027, 11, 1)) + + @patch("eol_checker.urllib.request.urlopen") + def test_returns_none_for_bool_eol(self, mock_urlopen_fn): + mock_urlopen_fn.return_value = _mock_urlopen({"eol": False}) + result = fetch_eol_date("alpine", "99.99") + self.assertIsNone(result) + + @patch("eol_checker.urllib.request.urlopen") + def test_returns_none_on_network_error(self, mock_urlopen_fn): + mock_urlopen_fn.side_effect = Exception("network error") + result = fetch_eol_date("alpine", "3.21") + self.assertIsNone(result) + + +class TestGetEolDate(unittest.TestCase): + + @patch("eol_checker.fetch_eol_date", return_value=date(2027, 11, 1)) + def test_fetches_from_api(self, mock_fetch): + cfg = {"os": "alpine-linux", "image": "alpine:3.23"} + result = get_eol_date(cfg) + self.assertEqual(result, date(2027, 11, 1)) + mock_fetch.assert_called_once_with("alpine", "3.23") + + @patch("eol_checker.fetch_eol_date", return_value=date(2029, 4, 30)) + def test_ubuntu(self, mock_fetch): + cfg = {"os": "ubuntu", "image": "ubuntu:24.04"} + result = get_eol_date(cfg) + self.assertEqual(result, date(2029, 4, 30)) + mock_fetch.assert_called_once_with("ubuntu", "24.04") + + @patch("eol_checker.fetch_eol_date", return_value=date(2032, 5, 31)) + def test_ubi(self, mock_fetch): + cfg = {"os": "ubi-minimal", "image": "redhat/ubi9-minimal"} + result = get_eol_date(cfg) + self.assertEqual(result, date(2032, 5, 31)) + mock_fetch.assert_called_once_with("rhel", "9") + + def test_hardcoded_eol_takes_priority(self): + cfg = {"os": "ubuntu", "image": "ubuntu:24.04", "eol": "2030-01-01"} + result = get_eol_date(cfg) + self.assertEqual(result, date(2030, 1, 1)) + + def test_hardcoded_eol_as_date_object(self): + cfg = {"os": "ubuntu", "image": "ubuntu:24.04", "eol": date(2030, 1, 1)} + result = get_eol_date(cfg) + self.assertEqual(result, date(2030, 1, 1)) + + def test_unknown_os_returns_none(self): + cfg = {"os": "servercore", "image": "mcr.microsoft.com/windows/servercore:ltsc2022"} + result = get_eol_date(cfg) + self.assertIsNone(result) + + +class TestCheckEolConfigs(unittest.TestCase): + + @patch("eol_checker.get_eol_date") + def test_finds_expired(self, mock_get_eol): + mock_get_eol.side_effect = [date(2020, 1, 1), date(2099, 1, 1)] + config = { + "configurations": { + "linux": [ + {"os": "ubuntu", "image": "ubuntu:20.04", "directory": "ubuntu/focal"}, + {"os": "ubuntu", "image": "ubuntu:24.04", "directory": "ubuntu/noble"}, + ], + } + } + expired = check_eol_configs(config) + self.assertEqual(len(expired), 1) + self.assertEqual(expired[0][0]["directory"], "ubuntu/focal") + self.assertEqual(expired[0][1], date(2020, 1, 1)) + + @patch("eol_checker.get_eol_date", return_value=None) + def test_skips_when_no_eol(self, mock_get_eol): + config = { + "configurations": { + "windows": [ + {"os": "servercore", "image": "mcr.microsoft.com/windows/servercore:ltsc2022"}, + ], + } + } + expired = check_eol_configs(config) + self.assertEqual(len(expired), 0) + + +class TestEolFetchableForAllConfigs(unittest.TestCase): + """Verify that every non-Windows config in temurin.yml can fetch an EOL date from the API.""" + + @classmethod + def setUpClass(cls): + import yaml + with open("config/temurin.yml") as f: + cls.config = yaml.safe_load(f) + + def test_all_linux_and_alpine_configs_fetch_eol_from_api(self): + """Each non-Windows config should resolve a product/cycle and get a valid date from endoflife.date.""" + missing = [] + for os_family, configurations in self.config["configurations"].items(): + if os_family == "windows": + continue + for cfg in configurations: + os_name = cfg["os"] + image = cfg["image"] + product = OS_TO_PRODUCT.get(os_name) + cycle = _extract_cycle(image) + + with self.subTest(image=image): + self.assertIsNotNone(product, f"No endoflife.date product mapping for os={os_name}") + self.assertIsNotNone(cycle, f"Could not extract version cycle from {image}") + + eol = fetch_eol_date(product, cycle) + if eol is None: + missing.append(f"{image} ({cfg.get('directory', '')})") + else: + self.assertIsInstance(eol, date, f"EOL for {image} is not a date: {eol}") + + self.assertEqual( + missing, [], + f"Could not fetch EOL date from endoflife.date API for: {', '.join(missing)}" + ) + + +if __name__ == "__main__": + unittest.main() diff --git a/test_generate_dockerfiles.py b/test_generate_dockerfiles.py new file mode 100644 index 0000000000000000000000000000000000000000..6bf6720d305023cbd5175737834e2e6639246ad8 --- /dev/null +++ b/test_generate_dockerfiles.py @@ -0,0 +1,279 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import unittest +from unittest.mock import Mock, mock_open, patch + +from jinja2 import Environment, FileSystemLoader + +from generate_dockerfiles import resolve_architectures + + +class TestJinjaRendering(unittest.TestCase): + def setUp(self): + # Setup the Jinja2 environment + self.env = Environment(loader=FileSystemLoader("docker_templates")) + + def test_armhf_ubuntu8_rendering(self): + template_name = "ubuntu.Dockerfile.j2" + template = self.env.get_template(template_name) + + arch_data = {} + + arch_data["armhf"] = { + "download_url": "http://fake-url.com", + "checksum": "fake-checksum", + } + + # The context/variables to render the template + context = { + "architecture": "armhf", + "os": "ubuntu", + "version": "8", + "arch_data": arch_data, + } + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + expected_string = "# Fixes libatomic.so.1: cannot open shared object file" + self.assertIn(expected_string, rendered_template) + + def test_version_checker(self): + template_name = "partials/version-check.j2" + template = self.env.get_template(template_name) + + with self.subTest(): + # The context/variables to render the template + context = {"version": "11", "image_type": "jdk"} + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + self.assertIn("javac --version", rendered_template) + self.assertIn("java --version", rendered_template) + + with self.subTest(): + # The context/variables to render the template + context = {"version": "8", "image_type": "jdk"} + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + self.assertIn("javac -version", rendered_template) + self.assertIn("java -version", rendered_template) + + with self.subTest(): + # The context/variables to render the template + context = {"version": "11", "image_type": "jre"} + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + self.assertNotIn("javac --version", rendered_template) + self.assertIn("java --version", rendered_template) + + with self.subTest(): + # The context/variables to render the template + context = {"version": "8", "image_type": "jre"} + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + self.assertNotIn("javac -version", rendered_template) + self.assertIn("java -version", rendered_template) + + def test_jdk11plus_jshell_cmd(self): + template_name = "partials/jshell.j2" + template = self.env.get_template(template_name) + + with self.subTest(): + # The context/variables to render the template + context = {"version": "11", "image_type": "jdk"} + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + expected_string = 'CMD ["jshell"]' + self.assertIn(expected_string, rendered_template) + + with self.subTest(): + # The context/variables to render the template + context = {"version": "17", "image_type": "jre"} + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + expected_string = 'CMD ["jshell"]' + self.assertNotIn(expected_string, rendered_template) + + with self.subTest(): + # The context/variables to render the template + context = {"version": "8", "image_type": "jdk"} + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + expected_string = 'CMD ["jshell"]' + self.assertNotIn(expected_string, rendered_template) + + def test_binutils_inclusion(self): + template_name = "ubuntu.Dockerfile.j2" + template = self.env.get_template(template_name) + + # Binutils should be included for jdk images with version >= 13 + with self.subTest("jdk 13+ should include binutils"): + context = { + "version": 13, + "image_type": "jdk", + "os": "ubuntu", + "arch_data": {}, + } + rendered_template = template.render(**context) + self.assertIn("binutils", rendered_template) + + # Binutils should not be included for jre images regardless of version + with self.subTest("jre 13+ should not include binutils"): + context = { + "version": 13, + "image_type": "jre", + "os": "ubuntu", + "arch_data": {}, + } + rendered_template = template.render(**context) + self.assertNotIn("binutils", rendered_template) + + # Binutils should not be included for jdk images with version < 13 + with self.subTest("jdk < 13 should not include binutils"): + context = { + "version": 12, + "image_type": "jdk", + "os": "ubuntu", + "arch_data": {}, + } + rendered_template = template.render(**context) + self.assertNotIn("binutils", rendered_template) + + def test_arch_data_population(self): + template_name = "ubuntu.Dockerfile.j2" + template = self.env.get_template(template_name) + + # Simulate API response + arch_data = { + "amd64": { + "download_url": "http://fake-url.com", + "checksum": "fake-checksum", + } + } + + context = { + "version": 11, + "image_type": "jdk", + "os": "ubuntu", + "arch_data": arch_data, + } + rendered_template = template.render(**context) + + self.assertIn("http://fake-url.com", rendered_template) + self.assertIn("fake-checksum", rendered_template) + + def test_entrypoint_rendering(self): + template_name = "entrypoint.sh.j2" + template = self.env.get_template(template_name) + + context = { + "image_type": "jdk", + "os": "ubuntu", + "version": 11, + } + rendered_template = template.render(**context) + + # Ensure that the entrypoint script contains expected commands + self.assertIn("update-ca-certificates", rendered_template) + self.assertIn("/certificates/*crt", rendered_template) + self.assertNotIn("/certificates/*.crt", rendered_template) + self.assertIn("cp -La /certificates/* /usr/local/share/ca-certificates/", rendered_template) + self.assertIn("exec \"$@\"", rendered_template) + + +class TestResolveArchitectures(unittest.TestCase): + def setUp(self): + self.default_archs = ["aarch64", "arm", "ppc64le", "s390x", "x64"] + + def test_no_overrides_returns_default(self): + result = resolve_architectures(self.default_archs, None, 17) + self.assertEqual(result, self.default_archs) + + def test_empty_overrides_returns_default(self): + result = resolve_architectures(self.default_archs, [], 17) + self.assertEqual(result, self.default_archs) + + def test_exact_match_full_replacement(self): + overrides = [{"versions": "==8", "architectures": ["aarch64", "x64"]}] + self.assertEqual(resolve_architectures(self.default_archs, overrides, 8), ["aarch64", "x64"]) + self.assertEqual(resolve_architectures(self.default_archs, overrides, 11), self.default_archs) + + def test_exclude(self): + overrides = [{"versions": ">=21", "exclude": ["arm"]}] + self.assertEqual(resolve_architectures(self.default_archs, overrides, 21), ["aarch64", "ppc64le", "s390x", "x64"]) + self.assertEqual(resolve_architectures(self.default_archs, overrides, 17), self.default_archs) + + def test_include(self): + overrides = [{"versions": ">=17", "include": ["riscv64"]}] + self.assertEqual(resolve_architectures(self.default_archs, overrides, 17), ["aarch64", "arm", "ppc64le", "s390x", "x64", "riscv64"]) + self.assertEqual(resolve_architectures(self.default_archs, overrides, 11), self.default_archs) + + def test_include_no_duplicates(self): + overrides = [{"versions": ">=17", "include": ["x64", "riscv64"]}] + result = resolve_architectures(self.default_archs, overrides, 17) + self.assertEqual(result.count("x64"), 1) + self.assertIn("riscv64", result) + + def test_multiple_matching_overrides_applied(self): + overrides = [ + {"versions": ">=21", "exclude": ["arm"]}, + {"versions": "<17", "exclude": ["riscv64"]}, + ] + # version 8 matches only second rule + self.assertEqual(resolve_architectures(self.default_archs, overrides, 8), ["aarch64", "arm", "ppc64le", "s390x", "x64"]) + # version 17 matches neither + self.assertEqual(resolve_architectures(self.default_archs, overrides, 17), self.default_archs) + # version 21 matches only first rule + self.assertEqual(resolve_architectures(self.default_archs, overrides, 21), ["aarch64", "ppc64le", "s390x", "x64"]) + + def test_all_matching_overrides_accumulate(self): + overrides = [ + {"versions": "==8", "exclude": ["s390x"]}, + {"versions": "<17", "exclude": ["riscv64"]}, + ] + # version 8 matches both rules + result = resolve_architectures(["aarch64", "arm", "ppc64le", "riscv64", "s390x", "x64"], overrides, 8) + self.assertNotIn("s390x", result) + self.assertNotIn("riscv64", result) + self.assertEqual(result, ["aarch64", "arm", "ppc64le", "x64"]) + + def test_not_equal(self): + overrides = [{"versions": "!=8", "exclude": ["arm"]}] + self.assertEqual(resolve_architectures(self.default_archs, overrides, 11), ["aarch64", "ppc64le", "s390x", "x64"]) + self.assertEqual(resolve_architectures(self.default_archs, overrides, 8), self.default_archs) + + def test_less_than(self): + overrides = [{"versions": "<11", "exclude": ["s390x"]}] + self.assertEqual(resolve_architectures(self.default_archs, overrides, 8), ["aarch64", "arm", "ppc64le", "x64"]) + self.assertEqual(resolve_architectures(self.default_archs, overrides, 11), self.default_archs) + + def test_greater_than(self): + overrides = [{"versions": ">17", "exclude": ["arm"]}] + self.assertEqual(resolve_architectures(self.default_archs, overrides, 21), ["aarch64", "ppc64le", "s390x", "x64"]) + self.assertEqual(resolve_architectures(self.default_archs, overrides, 17), self.default_archs) + + def test_invalid_condition_raises(self): + overrides = [{"versions": "~8", "exclude": ["x64"]}] + with self.assertRaises(ValueError): + resolve_architectures(self.default_archs, overrides, 8) + + +if __name__ == "__main__": + unittest.main()