incubator-answer icon indicating copy to clipboard operation
incubator-answer copied to clipboard

How to add a WeChat authentication plugin to a system deployed using the `docker run` method?

Open vipelanchen opened this issue 1 year ago • 7 comments

求助: 我使用docker run -d -p 9080:80 -v answer-data:/data -e SKIP_FILE_ACCESS_VERIFY=true --name answer apache/answer:latest 部署的论坛 现在想使用企业微信插件,请问怎么在插件中心增加和启用这个插件 https://github.com/apache/answer-plugins/tree/main/user-center-wecom

vipelanchen avatar Nov 21 '25 01:11 vipelanchen

@LinkinStars 老师,是否能够提供一下帮助

vipelanchen avatar Nov 21 '25 02:11 vipelanchen

@vipelanchen You can use docker to build an image that contains any plugins. Then start it with the new docker image.

FROM apache/answer:1.7.0 as answer-builder

FROM golang:1.23.4-alpine AS golang-builder

COPY --from=answer-builder /usr/bin/answer /usr/bin/answer

RUN apk --no-cache add \
    build-base git bash nodejs npm go && \
    npm install -g [email protected]

RUN ANSWER_MODULE=github.com/apache/[email protected] answer build \
    --with github.com/apache/answer-plugins/user-center-wecom@latest \
    --output /usr/bin/new_answer

FROM alpine:latest
LABEL maintainer="[email protected]"

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

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
RUN chmod 755 /entrypoint.sh

VOLUME /data
EXPOSE 80
ENTRYPOINT ["/entrypoint.sh"]

You can add plugins via --with.

FYI: https://answer.apache.org/docs/plugins#docker-build

LinkinStars avatar Nov 21 '25 02:11 LinkinStars

收到,非常感谢老师的回复 再次请教一下,是否有更简单的办法,比如通过docker exec -it answer bash 登录到容器内部,进行本地编译来实现

Image

vipelanchen avatar Nov 21 '25 03:11 vipelanchen

@vipelanchen If the original deployment was binary-based, this approach may be appropriate. However, it is not recommended for Docker deployments, as restarting or upgrading the image would result in plugin loss, necessitating reinstallation.

LinkinStars avatar Nov 21 '25 03:11 LinkinStars

@LinkinStars 老师您好,按照之前您给与帮助的 dockerfile 内容,进行构建,一直会有报错。麻烦您给与指导

Image

vipelanchen avatar Nov 25 '25 05:11 vipelanchen

@vipelanchen It is evident that due to network constraints, you may occasionally need to configure a proxy to access the site properly. You can try to set ENV GOPROXY=https://goproxy.cn in dockerfile

LinkinStars avatar Nov 25 '25 09:11 LinkinStars

@LinkinStars 非常感谢老师的回复,已经可以成功 bulid images了

vipelanchen avatar Nov 27 '25 01:11 vipelanchen