From 2a029ef63ee93b6850960543cc9a0836624c5879 Mon Sep 17 00:00:00 2001 From: GuangJie1 Date: Tue, 9 Sep 2025 15:58:14 +0800 Subject: [PATCH] update jetty --- Others/jetty/12.1.1/24.03-lts-sp2/Dockerfile | 42 ++++++ .../12.1.1/24.03-lts-sp2/docker-entrypoint.sh | 127 ++++++++++++++++++ .../24.03-lts-sp2/generate-jetty-start.sh | 22 +++ Others/jetty/README.md | 28 ++-- Others/jetty/doc/image-info.yml | 23 ++-- Others/jetty/meta.yml | 4 +- 6 files changed, 225 insertions(+), 21 deletions(-) create mode 100644 Others/jetty/12.1.1/24.03-lts-sp2/Dockerfile create mode 100644 Others/jetty/12.1.1/24.03-lts-sp2/docker-entrypoint.sh create mode 100644 Others/jetty/12.1.1/24.03-lts-sp2/generate-jetty-start.sh diff --git a/Others/jetty/12.1.1/24.03-lts-sp2/Dockerfile b/Others/jetty/12.1.1/24.03-lts-sp2/Dockerfile new file mode 100644 index 00000000..06a616c6 --- /dev/null +++ b/Others/jetty/12.1.1/24.03-lts-sp2/Dockerfile @@ -0,0 +1,42 @@ +ARG BASE=openeuler/openeuler:24.03-lts-sp2 +FROM ${BASE} +ARG VERSION=12.1.1 + +RUN dnf update -y \ + && dnf install -y wget git java-17-openjdk shadow-utils \ + && dnf clean all \ + && rm -rf /var/cache/dnf/* + +ENV JETTY_HOME /usr/local/jetty +ENV JETTY_BASE /var/lib/jetty +ENV TMPDIR /tmp/jetty +ENV PATH ${JETTY_HOME}/bin:$PATH + +RUN mkdir -p "$JETTY_HOME" $TMPDIR; \ + cd $JETTY_HOME ; \ + curl -SL https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/$VERSION/jetty-home-$VERSION.tar.gz -o jetty.tar.gz ; \ + tar -xvf jetty.tar.gz --strip-components=1 ; \ + sed -i '/jetty-logging/d' etc/jetty.conf ; \ + mkdir -p "$JETTY_BASE" ; \ + cd $JETTY_BASE ; \ + java -jar "$JETTY_HOME/start.jar" --create-startd --add-to-start="server,http,ext,resources,deployment-scanner,ee8-deploy,ee8-webapp" ; \ + groupadd -r jetty && useradd -r -g jetty jetty ; \ + chown -R jetty:jetty "$JETTY_HOME" "$JETTY_BASE" "$TMPDIR" ; \ + usermod -d $JETTY_BASE jetty ; \ + rm -rf /tmp/hsperfdata_root ; \ + rm -fr $JETTY_HOME/jetty.tar.gz* ; \ + java -jar "$JETTY_HOME/start.jar" --list-config + + +WORKDIR $JETTY_BASE + +COPY docker-entrypoint.sh generate-jetty-start.sh / + +RUN chmod +x /docker-entrypoint.sh /generate-jetty-start.sh + +USER jetty + +EXPOSE 8080 + +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["java","-jar","/usr/local/jetty/start.jar"] diff --git a/Others/jetty/12.1.1/24.03-lts-sp2/docker-entrypoint.sh b/Others/jetty/12.1.1/24.03-lts-sp2/docker-entrypoint.sh new file mode 100644 index 00000000..c468c3ef --- /dev/null +++ b/Others/jetty/12.1.1/24.03-lts-sp2/docker-entrypoint.sh @@ -0,0 +1,127 @@ +#!/bin/sh +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Eclipse Public License - v 2.0 + +set -e + +if [ "$1" = jetty.sh ]; then + if ! command -v bash >/dev/null 2>&1 ; then + cat >&2 <<- 'EOWARN' + ******************************************************************** + ERROR: bash not found. Use of jetty.sh requires bash. + ******************************************************************** + EOWARN + exit 1 + fi + cat >&2 <<- 'EOWARN' + ******************************************************************** + WARNING: Use of jetty.sh from this image is deprecated and may + be removed at some point in the future. + + See the documentation for guidance on extending this image: + https://github.com/docker-library/docs/tree/master/jetty + ******************************************************************** + EOWARN +fi + +if ! command -v -- "$1" >/dev/null 2>&1 ; then + set -- java -jar "$JETTY_HOME/start.jar" "$@" +fi + +: ${TMPDIR:=/tmp/jetty} +[ -d "$TMPDIR" ] || mkdir -p $TMPDIR 2>/dev/null + +: ${JETTY_START:=$JETTY_BASE/jetty.start} + +case "$JAVA_OPTIONS" in + *-Djava.io.tmpdir=*) ;; + *) JAVA_OPTIONS="-Djava.io.tmpdir=$TMPDIR $JAVA_OPTIONS" ;; +esac + +if expr "$*" : 'java .*/start\.jar.*$' >/dev/null ; then + # this is a command to run jetty + + # check if it is a terminating command + for A in "$@" ; do + case $A in + --add-module* |\ + --add-to-start* |\ + --create-files |\ + --create-start-ini |\ + --create-startd |\ + --download |\ + --dry-run |\ + --exec-print |\ + --help |\ + --info |\ + --list-all-modules |\ + --list-classpath |\ + --list-config |\ + --list-modules* |\ + --show-module* |\ + --stop |\ + --update-ini |\ + --version |\ + --write-module-graph* |\ + -v )\ + # It is a terminating command, so exec directly + JAVA="$1" + shift + # The $START_OPTIONS is the JVM options for the JVM which will do the --dry-run. + # The $JAVA_OPTIONS contains the JVM options used in the output of the --dry-run command. + eval "exec $JAVA $START_OPTIONS \"\$@\" $JAVA_OPTIONS $JETTY_PROPERTIES" + esac + done + + if [ $(whoami) != "jetty" ]; then + cat >&2 <<- EOWARN + ******************************************************************** + WARNING: User is $(whoami) + The user should be (re)set to 'jetty' in the Dockerfile + ******************************************************************** + EOWARN + fi + + if [ -f $JETTY_START ] ; then + + # Search for the Jetty Version comment in the jetty.start file. + JETTY_START_VERSION="$( + grep -m1 '^# JETTY_VERSION:' "$JETTY_START" 2>/dev/null \ + | sed 's/^# JETTY_VERSION: //' + )" + + # If the jetty.start file was generated with a different Jetty version we need to regenerate jetty.start. + if [ "$JETTY_START_VERSION" != "$JETTY_VERSION" ]; then + echo "$(date +'%Y-%m-%d %H:%M:%S'):INFO: Jetty version mismatch ($JETTY_START_VERSION -> $JETTY_VERSION), regenerating jetty.start" >&2 + /generate-jetty-start.sh "$@" + + # If the start.d directory has been modified we need to regenerate jetty.start. + elif [ $JETTY_BASE/start.d -nt $JETTY_START ] ; then + cat >&2 <<- EOWARN + ******************************************************************** + WARNING: The $JETTY_BASE/start.d directory has been modified since + the $JETTY_START files was generated. + To avoid regeneration delays at start, either delete + the $JETTY_START file or re-run /generate-jetty-start.sh + from a Dockerfile. + ******************************************************************** + EOWARN + /generate-jetty-start.sh "$@" + fi + echo $(date +'%Y-%m-%d %H:%M:%S.000'):INFO:docker-entrypoint:jetty start from $JETTY_START + else + /generate-jetty-start.sh "$@" + fi + + ## The generate-jetty-start script always starts the jetty.start file with exec, so this command will exec Jetty. + ## We need to do this because the file may have quoted arguments which cannot be read into a variable. + . $JETTY_START +fi + +if [ "${1##*/}" = java -a -n "$JAVA_OPTIONS" ] ; then + JAVA="$1" + shift + set -- "$JAVA" $JAVA_OPTIONS "$@" +fi + +exec "$@" \ No newline at end of file diff --git a/Others/jetty/12.1.1/24.03-lts-sp2/generate-jetty-start.sh b/Others/jetty/12.1.1/24.03-lts-sp2/generate-jetty-start.sh new file mode 100644 index 00000000..8ab07736 --- /dev/null +++ b/Others/jetty/12.1.1/24.03-lts-sp2/generate-jetty-start.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Eclipse Public License - v 2.0 + +if [ -z "$JETTY_START" ] ; then + JETTY_START=$JETTY_BASE/jetty.start +fi +rm -f $JETTY_START + +DRY_RUN=$(/docker-entrypoint.sh "$@" --dry-run | tee /dev/stderr) +DRY_RUN=$(echo "$DRY_RUN" \ + | egrep '[^ ]*java .*org\.eclipse\.jetty\.xml\.XmlConfiguration ' \ + | sed -e 's/ -Djava.io.tmpdir=[^ ]*//g' -e 's/\\$//') +echo "# JETTY_VERSION: $JETTY_VERSION" > "$JETTY_START" +echo "exec $DRY_RUN" >> "$JETTY_START" + +# If jetty.start doesn't have content then the dry-run failed. +if ! [ -s $JETTY_START ]; then + echo "jetty dry run failed:" + echo "$DRY_RUN" | awk '/\\$/ { printf "%s", substr($0, 1, length($0)-1); next } 1' + exit 1 +fi \ No newline at end of file diff --git a/Others/jetty/README.md b/Others/jetty/README.md index b4919f5e..54ee9036 100644 --- a/Others/jetty/README.md +++ b/Others/jetty/README.md @@ -18,22 +18,30 @@ The tag of each `jetty` docker image is consist of the version of `jetty` and th | Tag | Currently | Architectures | |------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------|---------------| -| [12.0.21-oe2403sp1](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/jetty/12.0.21/24.03-lts-sp1/Dockerfile) | Jetty 12.0.21 on openEuler 24.03-LTS-SP1 | amd64, arm64 | +| [12.1.1-oe2403sp2](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/jetty/12.1.1/24.03-lts-sp2/Dockerfile) | Jetty 12.1.1 on openEuler 24.03-LTS-SP2 | amd64, arm64 | | [12.1.0-oe2403sp2](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/jetty/12.1.0/24.03-lts-sp2/Dockerfile) | Jetty 12.1.0 on openEuler 24.03-LTS-SP2 | amd64, arm64 | +| [12.0.21-oe2403sp1](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/jetty/12.0.21/24.03-lts-sp1/Dockerfile) | Jetty 12.0.21 on openEuler 24.03-LTS-SP1 | amd64, arm64 | # Usage In this usage, users can select the corresponding `{Tag}` based on their requirements. -- Add jetty dependency +- Pull the `openeuler/jetty` image from docker + + ```bash + docker pull openeuler/jetty:{Tag} + ``` + +- Start a jetty instance + + ```bash + docker run -d --name my-jetty -p 8080:8080 openeuler/jetty:{Tag} + ``` + After the instance `my-jetty` is started, access the jetty service through `http://host-ip:8080`. + +- Deployment - Maven: Add the following dependency to your `pom.xml`. - ``` - - org.eclipse.jetty - jetty-server - ${jetty.version} - - ``` + - Webapps can be deployed under /var/lib/jetty/webapps in the usual ways (WAR file, exploded WAR directory, or context XML file). + - There is a collection of [examples](https://github.com/jetty/jetty-examples) of how to use various features present in the Eclipse Jetty server and Eclipse Jetty client. # Question and answering If you have any questions or want to use some special features, please submit an issue or a pull request on [openeuler-docker-images](https://gitee.com/openeuler/openeuler-docker-images). \ No newline at end of file diff --git a/Others/jetty/doc/image-info.yml b/Others/jetty/doc/image-info.yml index 21e8636a..ee9e2462 100644 --- a/Others/jetty/doc/image-info.yml +++ b/Others/jetty/doc/image-info.yml @@ -9,10 +9,11 @@ environment: | tags: | jetty镜像的Tag由其版本信息和基础镜像版本信息组成,详细内容如下 - | Tag | Currently | Architectures | + | Tag | Currently | Architectures | |------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------|---------------| - | [12.0.21-oe2403sp1](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/jetty/12.0.21/24.03-lts-sp1/Dockerfile) | Jetty 12.0.21 on openEuler 24.03-LTS-SP1 | amd64, arm64 | + | [12.1.1-oe2403sp2](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/jetty/12.1.1/24.03-lts-sp2/Dockerfile) | Jetty 12.1.1 on openEuler 24.03-LTS-SP2 | amd64, arm64 | | [12.1.0-oe2403sp2](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/jetty/12.1.0/24.03-lts-sp2/Dockerfile) | Jetty 12.1.0 on openEuler 24.03-LTS-SP2 | amd64, arm64 | + | [12.0.21-oe2403sp1](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/jetty/12.0.21/24.03-lts-sp1/Dockerfile) | Jetty 12.0.21 on openEuler 24.03-LTS-SP1 | amd64, arm64 | download: | 拉取镜像到本地 @@ -21,16 +22,18 @@ download: | ``` usage: | - - 添加maven依赖 - Maven: 在`pom.xml`文件中引入Jetty依赖 - ``` - - org.eclipse.jetty - jetty-server - ${jetty.version} - + - 启动一个 Jetty 实例 + + ```bash + docker run -d --name my-jetty -p 8080:8080 openeuler/jetty:{Tag} ``` + 当实例 `my-jetty` 启动后,可以通过 `http://host-ip:8080` 访问 Jetty 服务。 + + - 部署 + + - 可以像常规方式一样,将 Web 应用部署到 /var/lib/jetty/webapps 下(支持 WAR 包、解压后的 WAR 目录或上下文 XML 文件。 + - 这里有一个 [示例集合]((https://github.com/jetty/jetty-examples)),展示了如何使用 Eclipse Jetty 服务器和 Eclipse Jetty 客户端中提供的各种功能。 license: Apache-2.0 license similar_packages: diff --git a/Others/jetty/meta.yml b/Others/jetty/meta.yml index b487978f..2a50b9ac 100644 --- a/Others/jetty/meta.yml +++ b/Others/jetty/meta.yml @@ -1,4 +1,6 @@ 12.0.21-oe2403sp1: path: 12.0.21/24.03-lts-sp1/Dockerfile 12.1.0-oe2403sp2: - path: 12.1.0/24.03-lts-sp2/Dockerfile \ No newline at end of file + path: 12.1.0/24.03-lts-sp2/Dockerfile +12.1.1-oe2403sp2: + path: 12.1.1/24.03-lts-sp2/Dockerfile \ No newline at end of file -- Gitee