diff --git a/Others/netty/4.2.8/24.03-lts-sp2/Dockerfile b/Others/netty/4.2.8/24.03-lts-sp2/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ae473e214d604a1db47633bf9d0e80728d98e367 --- /dev/null +++ b/Others/netty/4.2.8/24.03-lts-sp2/Dockerfile @@ -0,0 +1,28 @@ +ARG BASE=openeuler/openeuler:24.03-lts-sp2 + +FROM ${BASE} +ARG VERSION=4.2.8 + +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.8/24.03-lts-sp2/NettyDemo.java b/Others/netty/4.2.8/24.03-lts-sp2/NettyDemo.java new file mode 100644 index 0000000000000000000000000000000000000000..dc1387337472a2a1c41209f6d50fe26f2585fff3 --- /dev/null +++ b/Others/netty/4.2.8/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.8/24.03-lts-sp2/pom.xml.template b/Others/netty/4.2.8/24.03-lts-sp2/pom.xml.template new file mode 100644 index 0000000000000000000000000000000000000000..8d92328bb50c4c28a30234cb9112d6646df63245 --- /dev/null +++ b/Others/netty/4.2.8/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 b7460927ec7c46af8169c3677271a80e2da443fc..ffe8ac3b702e21a12669aa7113420e4c4500745e 100644 --- a/Others/netty/README.md +++ b/Others/netty/README.md @@ -18,6 +18,7 @@ The tag of each `netty` docker image is consist of the version of `netty` and th | Tag | Currently | Architectures | |--------------------------------------------------------------------------------------------------------------------------------|----------------------------------------|---------------| +|[4.2.8-oe2403sp2](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/netty/4.2.8/24.03-lts-sp2/Dockerfile) | netty 4.2.8 on openEuler 24.03-LTS-SP2 | amd64, arm64 | | [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 @@ -116,4 +117,4 @@ In this usage, users can select the corresponding `{Tag}` based on their require Any input will be echoed back by the server. # 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). +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/netty/doc/image-info.yml b/Others/netty/doc/image-info.yml index 63d79cd0888c9774c80257aa514df315dde31aab..76a48e268e5bf8ef948d2b27c3861ce139300a53 100644 --- a/Others/netty/doc/image-info.yml +++ b/Others/netty/doc/image-info.yml @@ -11,6 +11,7 @@ tags: | | Tag | Currently | Architectures | |--------------------------------------------------------------------------------------------------------------------------------|----------------------------------------|---------------| + |[4.2.8-oe2403sp2](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/netty/4.2.8/24.03-lts-sp2/Dockerfile) | netty 4.2.8 on openEuler 24.03-LTS-SP2 | amd64, arm64 | | [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 | diff --git a/Others/netty/meta.yml b/Others/netty/meta.yml index 256328e71a2cf5b5de48ce44178cdf68f8cb98f7..9b52f1d9f4fbd7b305442c3ae61f4a0e00ea1a46 100644 --- a/Others/netty/meta.yml +++ b/Others/netty/meta.yml @@ -3,4 +3,6 @@ 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 + path: 4.2.5/24.03-lts-sp2/Dockerfile +4.2.8-oe2403sp2: + path: 4.2.8/24.03-lts-sp2/Dockerfile \ No newline at end of file