50 lines
1.6 KiB
Plaintext
50 lines
1.6 KiB
Plaintext
# 配置参数(指定基础镜像版本)
|
|
ARG BASE_TAG=3.19.1
|
|
|
|
# 基于 AlpineLinux 构建
|
|
FROM alpine:$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
|
|
|
|
# 更新应用并安装基础应用
|
|
RUN set -ex && \
|
|
apk add --no-cache tzdata bash bash-doc bash-completion
|
|
|
|
# 设置时区、新建用户组及用户、配置目录权限
|
|
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
|
addgroup $GROUP_NAME -g $GROUP_ID && \
|
|
adduser $USER_NAME -G $GROUP_NAME -h $USER_HOME -s $USER_SHELL -u $USER_ID -D && \
|
|
mkdir -pv $USER_HOME && \
|
|
chown -R $GROUP_NAME.$USER_NAME $USER_HOME
|
|
|
|
# 安装 OpenSSL
|
|
ADD openssl-$OPENSSL_VERSION.zip $USER_HOME/openssl-$OPENSSL_VERSION.zip
|
|
RUN apk add --no-cache unzip perl && \
|
|
cd $USER_HOME && \
|
|
unzip openssl-$OPENSSL_VERSION.zip && \
|
|
rm -rf openssl-$OPENSSL_VERSION.zip && \
|
|
apk del unzip && \
|
|
chown -R $GROUP_NAME.$USER_NAME $USER_HOME && \
|
|
mv /usr/lib/libssl.so.3 /usr/lib/libssl.so.3.bak && \
|
|
mv /usr/lib/libcrypto.so.3 /usr/lib/libcrypto.so.3.bak && \
|
|
ln -s $USER_HOME/openssl-$OPENSSL_VERSION/lib64/libssl.so.3 /usr/lib/libssl.so.3 && \
|
|
ln -s $USER_HOME/openssl-$OPENSSL_VERSION/lib64/libcrypto.so.3 /usr/lib/libcrypto.so.3 && \
|
|
ln -s $USER_HOME/openssl-$OPENSSL_VERSION/bin/openssl /usr/bin/openssl
|
|
|
|
# 设置工作目录
|
|
WORKDIR $USER_HOME
|
|
|
|
# 设置启动用户
|
|
USER $GROUP_NAME:$USER_NAME
|
|
|
|
# 设置执行启动脚本
|
|
CMD ["/bin/bash"]
|