# 配置参数(指定基础镜像版本)
ARG BASE_TAG=15.5
# 基于 openSUSE 构建
FROM opensuse/leap:$BASE_TAG
# 配置参数
ARG GROUP_ID=1024 \
GROUP_NAME=openssl \
USER_ID=1024 \
USER_NAME=openssl \
USER_HOME=/home/openssl \
USER_SHELL=/bin/bash \
INSTALL_PATH=/opt/openssl \
OPENSSL_VERSION=3.3.0
# 更新应用并安装基础应用、清除 zypper 缓存
RUN set -ex && \
zypper refresh && \
zypper update -y && \
zypper clean
# 设置时区、新建用户组及用户、配置目录权限
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
groupadd $GROUP_NAME -g $GROUP_ID && \
useradd $USER_NAME -g $GROUP_ID -d $USER_HOME -s $USER_SHELL -u $USER_ID && \
mkdir -pv $USER_HOME $INSTALL_PATH && \
chown -R $GROUP_NAME.$USER_NAME $USER_HOME $INSTALL_PATH
# 安装 OpenSSL
ADD openssl-$OPENSSL_VERSION.tar.gz $USER_HOME
RUN zypper install -y perl gcc make && \
cd $USER_HOME && \
chown -R $GROUP_NAME.$USER_NAME $USER_HOME && \
cd openssl-$OPENSSL_VERSION && \
./Configure --prefix=$INSTALL_PATH && \
make install && \
rm -rf $USER_HOME/* && \
zypper remove -y perl gcc make && \
chown -R $GROUP_NAME.$USER_NAME $INSTALL_PATH && \
ln -s $INSTALL_PATH/lib64/libssl.so.3 /usr/lib64/libssl.so.3 && \
ln -s $INSTALL_PATH/lib64/libcrypto.so.3 /usr/lib64/libcrypto.so.3 && \
mv /usr/bin/openssl /usr/bin/openssl.bak && \
ln -s $INSTALL_PATH/bin/openssl /usr/bin/openssl
# 设置工作目录
WORKDIR $USER_HOME
# 设置启动用户
USER $GROUP_NAME:$USER_NAME
# 设置执行启动脚本
CMD ["/bin/bash"]
# 配置参数(指定基础镜像版本)
ARG BASE_TAG=15.5
# 基于 openSUSE 构建
FROM opensuse/leap:$BASE_TAG
# 指定端口号
EXPOSE 10080
# 配置参数
ARG GROUP_ID=1024 \
GROUP_NAME=kiwix \
USER_ID=1024 \
USER_NAME=kiwix \
USER_HOME=/home/kiwix \
USER_SHELL=/bin/bash
# 更新应用并安装基础应用、清除 zypper 缓存
RUN set -ex && \
zypper refresh && \
zypper update -y && \
zypper install -y curl && \
zypper clean
# 设置时区、新建用户组及用户、配置目录权限
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
groupadd $GROUP_NAME -g $GROUP_ID && \
useradd $USER_NAME -g $GROUP_ID -d $USER_HOME -s $USER_SHELL -u $USER_ID && \
mkdir -pv $USER_HOME && \
chown -R $GROUP_NAME.$USER_NAME $USER_HOME
# 配置环境变量
ARG KIWIX_SERVE_VERSION=3.7.0
ENV KIWIX_HOME=/opt/kiwix-serve/$KIWIX_SERVE_VERSION \
KIWIX_ZIM_FILE_DIR=/data
# 安装 Kiwix Server
COPY kiwix-serve $KIWIX_HOME/kiwix-serve
COPY entrypoint.sh $KIWIX_HOME/entrypoint.sh
RUN mkdir -pv $KIWIX_ZIM_FILE_DIR && \
chown -R $GROUP_NAME.$USER_NAME $KIWIX_HOME $KIWIX_ZIM_FILE_DIR && \
chmod -R 755 $KIWIX_HOME $KIWIX_ZIM_FILE_DIR
# 健康检查
HEALTHCHECK --interval=10s --timeout=3s CMD curl -f http://127.0.0.1:10080 || exit 1
# 设置工作目录
WORKDIR $KIWIX_HOME
# 设置启动用户
USER $GROUP_NAME:$USER_NAME
# 设置执行启动脚本
CMD ["/bin/bash","-c","./entrypoint.sh"]