From c067a4c915bf8a61c3179edcdf0225062c499375 Mon Sep 17 00:00:00 2001 From: zhihang Date: Thu, 4 Sep 2025 03:41:45 +0000 Subject: [PATCH] upgrade netty to 4.2.5 Signed-off-by: zhihang --- Others/netty/4.2.5/24.03-lts-sp2/Dockerfile | 28 +++++++++ .../netty/4.2.5/24.03-lts-sp2/NettyDemo.java | 60 +++++++++++++++++++ .../4.2.5/24.03-lts-sp2/pom.xml.template | 40 +++++++++++++ Others/netty/README.md | 2 +- Others/netty/doc/image-info.yml | 2 +- Others/netty/meta.yml | 2 + 6 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 Others/netty/4.2.5/24.03-lts-sp2/Dockerfile create mode 100644 Others/netty/4.2.5/24.03-lts-sp2/NettyDemo.java create mode 100644 Others/netty/4.2.5/24.03-lts-sp2/pom.xml.template diff --git a/Others/netty/4.2.5/24.03-lts-sp2/Dockerfile b/Others/netty/4.2.5/24.03-lts-sp2/Dockerfile new file mode 100644 index 00000000..f6702c52 --- /dev/null +++ b/Others/netty/4.2.5/24.03-lts-sp2/Dockerfile @@ -0,0 +1,28 @@ +ARG BASE=openeuler/openeuler:24.03-lts-sp2 + +FROM ${BASE} +ARG VERSION=4.2.5 + +RUN dnf update -y \ + && dnf install -y wget java-17-openjdk java-17-openjdk-devel gettext \ + && dnf clean all \ + && rm -rf /var/cache/dnf/* + +ARG MAVEN_VERSION=3.9.11 +RUN wget https://dlcdn.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz \ + && mkdir -p /usr/local/maven \ + && tar -zxvf apache-maven-3.9.11-bin.tar.gz -C /usr/local/maven --strip-components=1 + +ENV PATH=/usr/local/maven/bin:$PATH + +WORKDIR /opt/netty + +COPY NettyDemo.java src/main/java/demo/NettyDemo.java +COPY pom.xml.template pom.xml.template + +ENV NETTY_VERSION=${VERSION}.Final + +RUN envsubst < pom.xml.template > pom.xml \ + && mvn clean package -Dfile.encoding=UTF-8 + +CMD ["java", "-cp", "target/netty-demo-1.0-SNAPSHOT.jar", "demo.NettyDemo"] \ No newline at end of file diff --git a/Others/netty/4.2.5/24.03-lts-sp2/NettyDemo.java b/Others/netty/4.2.5/24.03-lts-sp2/NettyDemo.java new file mode 100644 index 00000000..dc138733 --- /dev/null +++ b/Others/netty/4.2.5/24.03-lts-sp2/NettyDemo.java @@ -0,0 +1,60 @@ +package demo; + +import io.netty.bootstrap.ServerBootstrap; +import io.netty.channel.*; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.SocketChannel; +import io.netty.channel.socket.nio.NioServerSocketChannel; + +public class NettyDemo { + private final int port; + + public NettyDemo(int port) { + this.port = port; + } + + public void start() throws InterruptedException { + EventLoopGroup bossGroup = new NioEventLoopGroup(1); + EventLoopGroup workerGroup = new NioEventLoopGroup(); + try { + ServerBootstrap b = new ServerBootstrap(); + b.group(bossGroup, workerGroup) + .channel(NioServerSocketChannel.class) + .childHandler(new ChannelInitializer() { + @Override + public void initChannel(SocketChannel ch) { + ch.pipeline().addLast(new NettyHandler()); + } + }); + + ChannelFuture f = b.bind(port).sync(); + System.out.println("Echo server started on port " + port); + f.channel().closeFuture().sync(); + } finally { + bossGroup.shutdownGracefully(); + workerGroup.shutdownGracefully(); + } + } + + public static void main(String[] args) throws InterruptedException { + new NettyDemo(8080).start(); + } +} + +class NettyHandler extends ChannelInboundHandlerAdapter { + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) { + ctx.write(msg); + } + + @Override + public void channelReadComplete(ChannelHandlerContext ctx) { + ctx.flush(); + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { + cause.printStackTrace(); + ctx.close(); + } +} \ No newline at end of file diff --git a/Others/netty/4.2.5/24.03-lts-sp2/pom.xml.template b/Others/netty/4.2.5/24.03-lts-sp2/pom.xml.template new file mode 100644 index 00000000..8d92328b --- /dev/null +++ b/Others/netty/4.2.5/24.03-lts-sp2/pom.xml.template @@ -0,0 +1,40 @@ + + 4.0.0 + + org.example + netty-demo + 1.0-SNAPSHOT + + + UTF-8 + 17 + 17 + + + + + io.netty + netty-all + ${NETTY_VERSION} + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + shade + + + + + + + \ No newline at end of file diff --git a/Others/netty/README.md b/Others/netty/README.md index 001431e5..b7460927 100644 --- a/Others/netty/README.md +++ b/Others/netty/README.md @@ -20,7 +20,7 @@ The tag of each `netty` docker image is consist of the version of `netty` and th |--------------------------------------------------------------------------------------------------------------------------------|----------------------------------------|---------------| | [4.2.1-oe2403sp1](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/netty/4.2.1/24.03-lts-sp1/Dockerfile) | Netty 4.2.1 on openEuler 24.03-LTS-SP1 | amd64, arm64 | | [4.2.4-oe2403sp2](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/netty/4.2.4/24.03-lts-sp2/Dockerfile) | Netty 4.2.4 on openEuler 24.03-LTS-SP2 | amd64, arm64 | - +| [4.2.5-oe2403sp2](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/netty/4.2.5/24.03-lts-sp2/Dockerfile) | Netty 4.2.5 on openEuler 24.03-LTS-SP2 | amd64, arm64 |5 # Usage In this usage, users can select the corresponding `{Tag}` based on their requirements. diff --git a/Others/netty/doc/image-info.yml b/Others/netty/doc/image-info.yml index ea05344a..63d79cd0 100644 --- a/Others/netty/doc/image-info.yml +++ b/Others/netty/doc/image-info.yml @@ -13,7 +13,7 @@ tags: | |--------------------------------------------------------------------------------------------------------------------------------|----------------------------------------|---------------| | [4.2.1-oe2403sp1](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/netty/4.2.1/24.03-lts-sp1/Dockerfile) | Netty 4.2.1 on openEuler 24.03-LTS-SP1 | amd64, arm64 | | [4.2.4-oe2403sp2](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/netty/4.2.4/24.03-lts-sp2/Dockerfile) | Netty 4.2.4 on openEuler 24.03-LTS-SP2 | amd64, arm64 | - + | [4.2.5-oe2403sp2](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/netty/4.2.5/24.03-lts-sp2/Dockerfile) | Netty 4.2.5 on openEuler 24.03-LTS-SP2 | amd64, arm64 | download: | 拉取镜像到本地 ``` diff --git a/Others/netty/meta.yml b/Others/netty/meta.yml index 154fdf63..256328e7 100644 --- a/Others/netty/meta.yml +++ b/Others/netty/meta.yml @@ -2,3 +2,5 @@ path: 4.2.1/24.03-lts-sp1/Dockerfile 4.2.4-oe2403sp2: path: 4.2.4/24.03-lts-sp2/Dockerfile +4.2.5-oe2403sp2: + path: 4.2.5/24.03-lts-sp2/Dockerfile \ No newline at end of file -- Gitee