:::tip
When we need to extend Apache Answer's functionality, such as adding OAuth login, we can design plugins to implement these features.
:::
You can find a list of officially supported plugins for Apache Answer here.
The Apache Answer binary supports packaging different required plugins into the binary.
:::tip
We use the build command provided with the Apache Answer binary to rebuild a version of Apache Answer with the plugin.
:::
For example, let's see how to build an Apache Answer binary that includes the GitHub third-party login plugin.
You can specify the plugins to use with the --with parameter:
# Build Answer with the GitHub connector plugin $ ./answer build --with github.com/apache/answer-plugins/connector-github
You can also specify the plugin version:
# Build Answer with the GitHub connector plugin version 1.0.0 $ ./answer build --with github.com/apache/answer-plugins/connector-github@1.0.0 --output ./new_answer
You can use multiple plugins at the same time:
$ ./answer build \ --with github.com/apache/answer-plugins/connector-github \ --with github.com/apache/answer-plugins/connector-google
If you need to use a local plugin, you can use the following command:
$ ./answer build --with github.com/apache/answer-plugins/connector-github@1.0.0=/my-local-space
You can use the following command to build a Linux-amd64 binary on macOS:
$ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 ./answer build --with github.com/apache/answer-plugins/connector-github
You can use the ANSWER_MODULE environment variable to specify the Answer version:
$ ANSWER_MODULE=github.com/apache/answer@v1.2.0-RC1 ./answer build --with github.com/apache/answer-plugins/connector-github
:::tip
You can use the plugin command to list the current binary containing plugins.
:::
$ ./new_answer plugin # Output: # github connector[0.0.1] made by answerdev # google connector[0.0.1] made by answerdev
FROM apache/answer as answer-builder FROM golang:1.22-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 pnpm@10.7.0 RUN answer build \ --with github.com/apache/answer-plugins/connector-basic \ --with github.com/apache/answer-plugins/storage-s3 \ --with github.com/apache/answer-plugins/search-elasticsearch \ --output /usr/bin/new_answer FROM alpine LABEL maintainer="linkinstar@apache.org" 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 update the --with parameter to add more plugins that you need.
# Create a Dockerfile and copy the content above $ vim Dockerfile $ docker build -t answer-with-plugin . $ docker run -d -p 9080:80 -v answer-data:/data --name answer answer-with-plugin
/script/plugin_list file in the root directory, one per line.github.com/apache/answer-plugins/connector-basic@latest github.com/apache/answer-plugins/reviewer-basic@latest github.com/apache/answer-plugins/captcha-basic@latest github.com/apache/answer-plugins/editor_formula@latest
docker build -t <name[:tag]> . command to start building the image.docker run -d -p 9080:80 -v answer-data:/data --name <container_name> <image_name> command to start the container and locally verify whether the image is built successfully.The Apache Answer with the plugin version is used in the same way as before. You can find the plugin's configuration in the admin page.
:::caution
Note that if you are upgrading from a non-plugin version to a plugin version, you also need to execute the upgrade command (also considered as an upgrade).
:::
You need to build a new Apache Answer binary with the new plugin version, then replace the old Apache Answer binary with the new one. As with normal upgrades, you need to execute different upgrade steps depending on the deployment method. For example, if you are using binary deployment, you need to execute the upgrade command.
:::tip
We recommend the use of official plugins. If you want to use third-party plugins, refer to the following.
:::
Please refer to the documentation for details.
Since Go is a static language, there is no friendly plugin mechanism. Instead of a dynamic approach, we use recompilation for deployment. Please refer to the blog for details.