Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions config/presubmits.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import json
import os
import subprocess
from typing import List, Tuple
import sys
import textwrap
Expand Down Expand Up @@ -298,6 +299,14 @@ def verify_flyway_index():
return not success


def verify_release_scripts():
"""Runs unit tests for release preparation shell scripts."""
result = subprocess.run(
['bash', 'release/prepare_release_tree_test.sh'], check=False
)
return result.returncode != 0


def get_files():
for root, dirnames, filenames in os.walk("."):
for filename in filenames:
Expand All @@ -320,6 +329,7 @@ def get_files():
# index is up-to-date. It's quicker to do it here than in the unit tests:
# when we put it here it fails fast before all of the tests are run.
failed |= verify_flyway_index()
failed |= verify_release_scripts()

if failed:
sys.exit(1)
10 changes: 9 additions & 1 deletion core/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
FROM eclipse-temurin:25
FROM launcher.gcr.io/google/ubuntu2404
ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
ca-certificates \
openjdk-25-jre-headless \
&& rm -rf /var/lib/apt/lists/*

ADD build/libs/nomulus.jar /nomulus.jar
# Disable C2 Base64 SIMD intrinsics as defense-in-depth for CVE-2026-114938
# (JDK-8393212).
Expand Down
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ ext {
'org.eclipse.angus:jakarta.mail:[2.0.3,)',
'org.eclipse.jetty.ee10:jetty-ee10-servlet:[12.0.0,)',
'org.eclipse.jetty.ee10:jetty-ee10-webapp:[12.0.0,)',
'org.eclipse.jetty:jetty-home:[12.0.0,)',
'org.eclipse.jetty:jetty-server:[12.0.0,)',
'org.flywaydb:flyway-core:[11.0.0,)',
'org.flywaydb:flyway-database-postgresql:[11.0.0,)',
Expand Down
50 changes: 34 additions & 16 deletions jetty/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
FROM jetty:12-jdk25
ADD --chown=jetty:jetty build/jetty-base /jetty-base
ADD --chown=jetty:jetty start.sh /
ADD --chown=jetty:jetty logging.properties /
FROM launcher.gcr.io/google/ubuntu2404
ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
ca-certificates \
openjdk-25-jre-headless \
&& rm -rf /var/lib/apt/lists/*

USER root
# Jetty Home is staged into build/jetty-home by the :jetty:unpackJettyHome
# Gradle task, at the org.eclipse.jetty:jetty-home version locked in
# jetty/gradle.lockfile.
ENV JETTY_HOME=/usr/local/jetty \
JETTY_BASE=/jetty-base \
TMPDIR=/tmp/jetty \
PATH=/usr/local/jetty/bin:${PATH}

# wget is not installed by default in :12-jdk25
RUN apt-get update && \
apt-get install -y wget && \
rm -rf /var/lib/apt/lists/*
# Install the Cloud Profiler Java agent (version-locked to
# cloud-profiler-java-agent_20241028_RC00.tar.gz) under a dedicated non-root
# jetty:jetty user.
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends wget; \
rm -rf /var/lib/apt/lists/*; \
groupadd -r jetty; \
useradd -r -g jetty -d "${JETTY_BASE}" jetty; \
mkdir -p "${JETTY_HOME}" "${JETTY_BASE}" "${TMPDIR}" /opt/cprof; \
wget -q -O- \
https://storage.googleapis.com/cloud-profiler/java/cloud-profiler-java-agent_20241028_RC00.tar.gz \
| tar xzv -C /opt/cprof; \
chown -R jetty:jetty "${JETTY_HOME}" "${JETTY_BASE}" "${TMPDIR}" /opt/cprof

# Create a directory, download and extract the Cloud Profiler agent, version locked to "cloud-profiler-java-agent_20241028_RC00.tar.gz".
RUN mkdir -p /opt/cprof && \
wget -q -O- https://storage.googleapis.com/cloud-profiler/java/cloud-profiler-java-agent_20241028_RC00.tar.gz\
| tar xzv -C /opt/cprof && \
chown -R jetty:jetty /opt/cprof
WORKDIR /jetty-base
ADD --chown=jetty:jetty build/jetty-home /usr/local/jetty
ADD --chown=jetty:jetty build/jetty-base /jetty-base
ADD --chown=jetty:jetty start.sh /
ADD --chown=jetty:jetty logging.properties /

USER jetty

EXPOSE 8080
# jetty:12-jdk25 has bash. We can afford the extra 200M in image size over
# the -alpine flavor.
ENTRYPOINT ["/bin/bash", "/start.sh"]
40 changes: 31 additions & 9 deletions jetty/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,34 @@ tasks.withType(tasks.shadowJar.class).configureEach {
dependsOn(tasks.named('copyJettyBase'))
}

configurations {
// The Jetty distribution installed as JETTY_HOME in the nomulus image.
jettyHome {
transitive = false
}
}

dependencies {
implementation project(':core')
jettyHome "${rootProject.dependencyMap['org.eclipse.jetty:jetty-home']}@tar.gz"
}

// Unpacks the Jetty distribution into build/jetty-home, dropping the top-level
// jetty-home-<version>/ directory. Sync removes files left over from a
// previously staged Jetty version, and adding owner-write (0200) ensures
// read-only tar entries stay overwritable on incremental reruns and Jetty
// upgrades without clean while preserving execute bits.
tasks.register('unpackJettyHome', Sync) {
from({ tarTree(configurations.jettyHome.singleFile) }) {
eachFile { fcd ->
fcd.relativePath = new RelativePath(
!fcd.directory, fcd.relativePath.segments.drop(1))
int mode = fcd.permissions.toUnixNumeric()
fcd.permissions { unix(mode | 0200) }
}
includeEmptyDirs = false
}
into layout.buildDirectory.dir('jetty-home')
}

tasks.register('copyConsole', Copy) {
Expand All @@ -56,6 +82,7 @@ tasks.register('copyConsole', Copy) {
tasks.register('stage') {
dependsOn(tasks.named('war'))
dependsOn(tasks.named('copyConsole'))
dependsOn(tasks.named('unpackJettyHome'))
}

tasks.register('buildNomulusImage', Exec) {
Expand All @@ -75,15 +102,10 @@ tasks.register('pushNomulusImage', Exec) {
}

tasks.register('run', JavaExec) {
// We do the check when the task actually runs, not when we define it.
// This way if one doesn't set the value, one can still run other tasks.
doFirst {
def jetty_home = System.getenv('JETTY_HOME')
if (jetty_home == null) {
throw new GradleException('JETTY_HOME is not set.')
}
}
def jetty_home = System.getenv('JETTY_HOME')
// Use the Jetty distribution staged by unpackJettyHome unless JETTY_HOME
// is set.
def jetty_home = System.getenv('JETTY_HOME') ?:
layout.buildDirectory.dir('jetty-home').get().asFile.absolutePath
def environment = rootProject.environment
jvmArgs "--sun-misc-unsafe-memory-access=allow", "--enable-native-access=ALL-UNNAMED"
workingDir(layout.buildDirectory.dir('jetty-base'))
Expand Down
1 change: 1 addition & 0 deletions jetty/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ org.codehaus.woodstox:stax2-api:4.2.2=deploy_jar,runtimeClasspath,testRuntimeCla
org.conscrypt:conscrypt-openjdk-uber:2.8.0=deploy_jar,runtimeClasspath,testRuntimeClasspath
org.eclipse.angus:angus-activation:2.1.0-M1=deploy_jar,runtimeClasspath,testRuntimeClasspath
org.eclipse.angus:jakarta.mail:2.1.0-M1=deploy_jar,runtimeClasspath,testRuntimeClasspath
org.eclipse.jetty:jetty-home:12.1.15=jettyHome
org.flywaydb:flyway-core:13.13.0=deploy_jar,runtimeClasspath,testRuntimeClasspath
org.flywaydb:flyway-database-cockroachdb:13.13.0=deploy_jar,runtimeClasspath,testRuntimeClasspath
org.flywaydb:flyway-database-postgresql:13.13.0=deploy_jar,runtimeClasspath,testRuntimeClasspath
Expand Down
10 changes: 9 additions & 1 deletion proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
FROM eclipse-temurin:25
FROM launcher.gcr.io/google/ubuntu2404
ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
ca-certificates \
openjdk-25-jre-headless \
&& rm -rf /var/lib/apt/lists/*

ADD build/libs/proxy_server.jar .
# Disable C2 Base64 SIMD intrinsics as defense-in-depth for CVE-2026-114938
# (JDK-8393212).
Expand Down
8 changes: 3 additions & 5 deletions release/cloudbuild-nomulus-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,18 @@ steps:
bash ./release/prepare_release_tree.sh clone-internal \
"${_INTERNAL_REPO_URL}" "${TAG_NAME}"
bash ./release/prepare_release_tree.sh merge-internal
# Pin the Dockerfiles by digest to this release's copies of the base images, as
# Pin the Dockerfiles by digest to this release's copy of the base image, as
# cloudbuild-release.yaml does.
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: /bin/bash
args:
- -c
- |
set -e
jetty_digest=$(gcloud container images list-tags "gcr.io/${PROJECT_ID}/jetty" \
--format='get(digest)' --filter="tags = ${TAG_NAME}")
temurin_digest=$(gcloud container images list-tags "gcr.io/${PROJECT_ID}/temurin" \
ubuntu_digest=$(gcloud container images list-tags "gcr.io/${PROJECT_ID}/ubuntu2404" \
--format='get(digest)' --filter="tags = ${TAG_NAME}")
bash ./release/prepare_release_tree.sh pin-base-images "${PROJECT_ID}" \
--temurin="@$temurin_digest" --jetty="@$jetty_digest" proxy jetty
--ubuntu="@$ubuntu_digest" proxy jetty
# Download saved Gradle distribution from GCS and install it.
- name: 'gcr.io/${PROJECT_ID}/builder:${TAG_NAME}'
entrypoint: ./release/install_gradle.sh
Expand Down
4 changes: 2 additions & 2 deletions release/cloudbuild-proxy-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ steps:
- -c
- |
set -e
temurin_digest=$(gcloud container images list-tags "gcr.io/${PROJECT_ID}/temurin" \
ubuntu_digest=$(gcloud container images list-tags "gcr.io/${PROJECT_ID}/ubuntu2404" \
--format='get(digest)' --filter="tags = ${TAG_NAME}")
bash ./release/prepare_release_tree.sh pin-base-images "${PROJECT_ID}" \
--temurin="@$temurin_digest" proxy
--ubuntu="@$ubuntu_digest" proxy
# Download saved Gradle distribution from GCS and install it.
- name: 'gcr.io/${PROJECT_ID}/builder:${TAG_NAME}'
entrypoint: ./release/install_gradle.sh
Expand Down
24 changes: 8 additions & 16 deletions release/cloudbuild-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,11 @@ steps:
docker tag "gcr.io/${PROJECT_ID}/builder:${TAG_NAME}" "gcr.io/${PROJECT_ID}/builder:latest"
docker push "gcr.io/${PROJECT_ID}/builder:${TAG_NAME}"
docker push "gcr.io/${PROJECT_ID}/builder:latest"
docker pull jetty:12-jdk25
docker tag jetty:12-jdk25 "gcr.io/${PROJECT_ID}/jetty:${TAG_NAME}"
docker tag jetty:12-jdk25 "gcr.io/${PROJECT_ID}/jetty:latest"
docker push "gcr.io/${PROJECT_ID}/jetty:${TAG_NAME}"
docker push "gcr.io/${PROJECT_ID}/jetty:latest"
docker pull eclipse-temurin:25
docker tag eclipse-temurin:25 "gcr.io/${PROJECT_ID}/temurin:${TAG_NAME}"
docker tag eclipse-temurin:25 "gcr.io/${PROJECT_ID}/temurin:latest"
docker push "gcr.io/${PROJECT_ID}/temurin:${TAG_NAME}"
docker push "gcr.io/${PROJECT_ID}/temurin:latest"
docker pull launcher.gcr.io/google/ubuntu2404
docker tag launcher.gcr.io/google/ubuntu2404 "gcr.io/${PROJECT_ID}/ubuntu2404:${TAG_NAME}"
docker tag launcher.gcr.io/google/ubuntu2404 "gcr.io/${PROJECT_ID}/ubuntu2404:latest"
docker push "gcr.io/${PROJECT_ID}/ubuntu2404:${TAG_NAME}"
docker push "gcr.io/${PROJECT_ID}/ubuntu2404:latest"
dir: 'release/builder/'
# Do text replacement in the merged repo, hardcoding image digests.
- name: 'gcr.io/cloud-builders/gcloud'
Expand All @@ -98,13 +93,10 @@ steps:
set -e
builder_digest=$(gcloud container images list-tags "gcr.io/${PROJECT_ID}/builder" \
--format='get(digest)' --filter="tags = ${TAG_NAME}")
jetty_digest=$(gcloud container images list-tags "gcr.io/${PROJECT_ID}/jetty" \
ubuntu_digest=$(gcloud container images list-tags "gcr.io/${PROJECT_ID}/ubuntu2404" \
--format='get(digest)' --filter="tags = ${TAG_NAME}")
temurin_digest=$(gcloud container images list-tags "gcr.io/${PROJECT_ID}/temurin" \
--format='get(digest)' --filter="tags = ${TAG_NAME}")
sed -i s%eclipse-temurin:25%gcr.io/${PROJECT_ID}/temurin@$temurin_digest%g proxy/Dockerfile
sed -i s%eclipse-temurin:25%gcr.io/${PROJECT_ID}/temurin@$temurin_digest%g core/Dockerfile
sed -i s%jetty:12-jdk25%gcr.io/${PROJECT_ID}/jetty@$jetty_digest%g jetty/Dockerfile
bash ./release/prepare_release_tree.sh pin-base-images "${PROJECT_ID}" \
--ubuntu="@$ubuntu_digest" core proxy jetty
sed -i s/builder:latest/builder@$builder_digest/g release/cloudbuild-proxy.yaml
sed -i s/builder:latest/builder@$builder_digest/g release/cloudbuild-nomulus.yaml
sed -i s/builder:latest/builder@$builder_digest/g release/cloudbuild-deploy-gke.yaml
Expand Down
29 changes: 15 additions & 14 deletions release/prepare_release_tree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,27 @@
# Clones the internal repository at <tag> into nomulus-internal/.
# prepare_release_tree.sh merge-internal
# Copies nomulus-internal/ over the tree, then deletes it and .git/.
# prepare_release_tree.sh pin-base-images <project_id> [--temurin=@<digest>]
# [--jetty=@<digest>] <component>...
# prepare_release_tree.sh pin-base-images <project_id> --ubuntu=@<digest>
# <component>...
# Pins <component>/Dockerfile (core, jetty or proxy) to the release's copy
# of its base image: gcr.io/<project_id>/temurin@<digest> for core and
# proxy, gcr.io/<project_id>/jetty@<digest> for jetty. A <digest> is
# of its base image: gcr.io/<project_id>/ubuntu2404@<digest>. A <digest> is
# sha256: and 64 lowercase hex digits. Checks every component before it
# edits any Dockerfile, and logs each pin.
# prepare_release_tree.sh set-proxy-project <project_id>
# Sets the project in the proxy's Kubernetes manifests.

set -e

# The base images that the Dockerfiles name. Keep them in sync with the
# The base image that the Dockerfiles name. Keep it in sync with the
# Dockerfiles.
readonly TEMURIN_BASE_IMAGE='eclipse-temurin:25'
readonly JETTY_BASE_IMAGE='jetty:12-jdk25'
readonly UBUNTU_BASE_IMAGE='launcher.gcr.io/google/ubuntu2404'

usage() {
cat >&2 <<EOF
Usage:
$0 clone-internal <repo_url> <tag>
$0 merge-internal
$0 pin-base-images <project_id> [--temurin=@<digest>] [--jetty=@<digest>] <component>...
$0 pin-base-images <project_id> --ubuntu=@<digest> <component>...
$0 set-proxy-project <project_id>
EOF
exit 1
Expand Down Expand Up @@ -78,13 +76,12 @@ merge_internal() {

pin_base_images() {
(( $# >= 2 )) || usage
local project_id="$1" temurin_ref='' jetty_ref='' arg
local project_id="$1" ubuntu_ref='' arg
local -a components=()
shift
for arg in "$@"; do
case "${arg}" in
--temurin=*) temurin_ref="${arg#--temurin=}" ;;
--jetty=*) jetty_ref="${arg#--jetty=}" ;;
--ubuntu=*) ubuntu_ref="${arg#--ubuntu=}" ;;
-*) usage ;;
*) components+=("${arg}") ;;
esac
Expand All @@ -95,13 +92,17 @@ pin_base_images() {
local -a dockerfiles=() base_images=() pinned_images=()
for component in "${components[@]}"; do
case "${component}" in
core|proxy) base_image="${TEMURIN_BASE_IMAGE}"; copy=temurin; ref="${temurin_ref}" ;;
jetty) base_image="${JETTY_BASE_IMAGE}"; copy=jetty; ref="${jetty_ref}" ;;
core|jetty|proxy)
base_image="${UBUNTU_BASE_IMAGE}"
copy=ubuntu2404
ref="${ubuntu_ref}"
;;
*) echo "Unknown component: ${component}" >&2; exit 1 ;;
esac
# A lookup that finds no image with the release's tag leaves just the @.
if [[ ! "${ref}" =~ ^@sha256:[0-9a-f]{64}$ ]]; then
echo "${component} needs --${copy}=@sha256:<64 hex digits>, not '${ref}'." >&2
echo "${component} needs --ubuntu=@sha256:<64 hex digits>," \
"not '${ref}'." >&2
exit 1
fi
# Fail rather than leave the Dockerfile on the public base image.
Expand Down
Loading
Loading