Chatgpt-on-wechat プロジェクト Docker デプロイメントの問題 Dockerfile.alpine ファイルの内容の解釈

FROM python:3.10-alpine

# 设置Docker镜像的作者和时区
LABEL maintainer="[email protected]"
ARG TZ='Asia/Shanghai'

# 指定chatgpt-on-wechat的版本号
ARG CHATGPT_ON_WECHAT_VER

# 设置一个环境变量BUILD_PREFIX,表示容器中chatgpt-on-wechat安装的路径
ENV BUILD_PREFIX=/app

RUN 
	# 安装必要的包,包括  bash、curl、wget
	apk add --no-cache \
        bash \
        curl \
        wget \
	# 把获取最新的版本号设置为环境变量
    && export BUILD_GITHUB_TAG=${CHATGPT_ON_WECHAT_VER:-`curl -sL "https://api.github.com/repos/zhayujie/chatgpt-on-wechat/releases/latest" | \
        grep '"tag_name":' | \
        sed -E 's/.*"([^"]+)".*/\1/'`} \
    && wget -t 3 -T 30 -nv -O chatgpt-on-wechat-${BUILD_GITHUB_TAG}.tar.gz \
            https://github.com/zhayujie/chatgpt-on-wechat/archive/refs/tags/${BUILD_GITHUB_TAG}.tar.gz \
    && tar -xzf chatgpt-on-wechat-${BUILD_GITHUB_TAG}.tar.gz \
    && mv chatgpt-on-wechat-${BUILD_GITHUB_TAG} ${BUILD_PREFIX} \
    && rm chatgpt-on-wechat-${BUILD_GITHUB_TAG}.tar.gz \
    && cd ${BUILD_PREFIX} \
    && cp config-template.json ${BUILD_PREFIX}/config.json \
    && /usr/local/bin/python -m pip install --no-cache --upgrade pip \
    && pip install --no-cache -r requirements.txt \
    && pip install --no-cache -r requirements-optional.txt \
    && apk del curl wget

# 设置启动路径
WORKDIR ${BUILD_PREFIX}

#添加一个entrypoint.sh  脚本作为容器启动时的入口点,该脚本用于启动chatgpt-on-wechat
ADD ./entrypoint.sh /entrypoint.sh

# 创建一个名为noroot的用户,并将BUILD_PREFIX目录的所有权交给该用户
RUN chmod +x /entrypoint.sh \
    && adduser -D -h /home/noroot -u 1000 -s /bin/bash noroot \
    && chown -R noroot:noroot ${BUILD_PREFIX}
	
# 切换用户
USER noroot

当  Docker  容器启动时,会默认执行  entrypoint.sh  脚本
ENTRYPOINT ["/entrypoint.sh"]

おすすめ

転載: blog.csdn.net/a18302465887/article/details/130324879