官网的打包netty-tcnative 太麻烦,也有问题,自己写了一个
FROM centos:7.6.1810
ARG gcc_version=10.2-2020.11
ARG openssl_version=1_1_1d
ENV OPENSSL_VERSION $openssl_version
RUN set -x && \
yum -y install epel-release && \
yum -y install wget tar git make autoconf automake libtool openssl-devel ninja-build gcc-c++ patch unzip zip
# Install Java
RUN yum install -y java-1.8.0-openjdk-devel golang
ENV JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk/"
# gcc 10编译器
RUN yum install centos-release-scl -y
RUN yum install devtoolset-10-gcc* -y
RUN scl enable devtoolset-10 bash
RUN echo "source /opt/rh/devtoolset-10/enable" >> ~/.bash_profile
RUN source /opt/rh/devtoolset-10/enable
# Install CMake
RUN yum install -y cmake3 && ln -s /usr/bin/cmake3 /usr/bin/cmake
# Cross compile OpenSSL - share
RUN set -x && \
wget https://github.com/openssl/openssl/archive/OpenSSL_$OPENSSL_VERSION.tar.gz && \
tar xvf OpenSSL_$OPENSSL_VERSION.tar.gz && \
pushd openssl-OpenSSL_$OPENSSL_VERSION && \
./config --prefix=/opt/openssl-$OPENSSL_VERSION-share shared && \
make && make install && \
popd
RUN set -x && \
curl -O https://mirrors.aliyun.com/apache/maven/maven-3/3.9.4/binaries/apache-maven-3.9.4-bin.tar.gz && \
tar -xzvf apache-maven-3.9.4-bin.tar.gz
# 使用gitee镜像,github有可能失败
RUN git clone https://gitee.com/mirrors/netty-tcnative
RUN set -x && \
pushd netty-tcnative && \
git checkout netty-tcnative-parent-2.0.61.Final && \
popd
# 注销了,网络原因下载包失败导致镜像创建失败,创建成功后进入docker再执行
#RUN set -x && \
#pushd netty-tcnative && \
#/apache-maven-3.9.4/bin/mvn clean package -am -pl openssl-dynamic -DskipTests && \
#popd
运行
d:>docker build -f nettybuild -t nettybuild .
# 进入docker
$/apache-maven-3.9.4/bin/mvn clean package -am -pl openssl-dynamic -DskipTests`
默认打包集成的openssl1.0,最后mvn打包会执行的结果是针对libssl1.10版本(docker自带的,不知道为啥不能自动识别最新安装的动态链接库),需要进入netty-tcnative/pom.xml ,在插件 hawtjni-maven-plugin 增加SSL配置和verbose
<verbose>true</verbose>
<configureArgs>
<configureArg>--with-ssl=/opt/openssl-1_1_1d-share</configureArg>
</configureArgs>
这样打包的tc-natvice依赖最新的openssl1.1