Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker build with plugin from answer base image always gets stuck here and does not proceed. #242

Open
zeallean opened this issue Nov 6, 2024 · 1 comment

Comments

@zeallean
Copy link

zeallean commented Nov 6, 2024

when I build with plugin in docker. the docker file like this:

# 第一阶段:使用 answer-builder 构建 answer
FROM apache/answer as answer-builder

# 第二阶段:使用 golang 构建插件和新的 answer
FROM golang:1.19-alpine AS golang-builder

# 设置国内 Go 模块代理
ENV GOPROXY=https://goproxy.cn,direct

# 复制 answer 可执行文件
# set alpine linux 代理
COPY --from=answer-builder /usr/bin/answer /usr/bin/answer
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories

# 安装构建所需依赖和 pnpm
RUN apk --no-cache add \
    build-base git bash nodejs npm go && \
    npm config set registry https://registry.npmmirror.com && \
    npm install -g [email protected] && \
    pnpm config set registry https://registry.npmmirror.com && \
	echo "Dependencies installed successfully"

# 增加 npm 和 pnpm 的超时时间和重试次数
RUN npm config set fetch-retries 5 && \
    npm config set fetch-retry-mintimeout 20000 && \
    npm config set fetch-retry-maxtimeout 120000 && \
    pnpm config set fetch-retries 5 && \
    pnpm config set fetch-retry-mintimeout 20000 && \
    pnpm config set fetch-retry-maxtimeout 120000

# 启用缓存机制,避免重复下载依赖
RUN npm config set cache /root/.npm-cache --global && \
    pnpm config set store-dir /root/.pnpm-store

# 强制更新 Browserslist 数据库,使用国内的 npm 镜像
RUN npm config set registry https://registry.npmmirror.com && \
    npx update-browserslist-db@latest || true

# 使用 answer build 构建插件并输出新的 answer
RUN answer build \
    --with github.com/apache/incubator-answer-plugins/user-center-wecom \
    --output /usr/bin/new_answer \
&& ls -l /usr/bin/new_answer

# 第三阶段:最终构建镜像
FROM alpine
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
LABEL maintainer="[email protected]"

# 设置默认时区为 Asia/Shanghai
ARG TIMEZONE
ENV TIMEZONE=${TIMEZONE:-"Asia/Shanghai"}

# 安装基础依赖和设置时区
RUN apk update \
    && apk --no-cache add \
        bash \
        ca-certificates \
        curl \
        dumb-init \
        gettext \
        openssh \
        sqlite \
        gnupg \
        tzdata \
    && ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
    && echo "${TIMEZONE}" > /etc/timezone

# 复制新构建的 answer 可执行文件和其他必要文件
COPY --from=golang-builder /usr/bin/new_answer /usr/bin/answer
COPY --from=answer-builder /data /data
COPY --from=answer-builder /entrypoint.sh /entrypoint.sh

# 设置 entrypoint 脚本的执行权限
RUN chmod 755 /entrypoint.sh

# 挂载 /data 目录
VOLUME /data

# 暴露 80 端口
EXPOSE 80

# 设置 entrypoint
ENTRYPOINT ["/entrypoint.sh"]

the process always stuck here.

=> [answer golang-builder 8/8] RUN answer build     --with github.com/apache/incubator-answer-plugins/user-center-wecom     --output /usr/bin/new_answer && ls -l /usr/bin/new_answer                                                                              1302.2s 
 => => # > [email protected] build /go/answer_build43967365/vendor/github.com/apache/incubator-answer/ui                                                                                                                                                                  
 => => # > node ./scripts/env.js && react-app-rewired build                                                                                                                                                                                                                 
 => => # Creating an optimized production build...                                                                                                                                                                                                                          
 => => # Browserslist: caniuse-lite is outdated. Please run:                                                                                                                                                                                                                
 => => #   npx update-browserslist-db@latest                                                                                                                                                                                                                                
 => => #   Why you should do it regularly: https://github.com/browserslist/update-db#readme 

Because I am in China, so reference to the official configuration file, I have added a lot of proxy settings, does this have anything to do with the unsuccessful build?

@LinkinStars
Copy link
Member

@zeallean There's nothing wrong with the dockerfile itself, I built it very quickly using the dockerfile you provided because of the proxy. The step you're stuck on isn't downloading but compiling.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants