宿州网站建设哪家公司好,个人网站制作方法,湖北省建设信息港网站,全国室内设计公司排名本文介绍开源问答社区平台Answer的容器化部署。 起因
笔者一直想搭建一个类似stack overflower这样的平台#xff0c;自使用了Typora#xff0c;就正式全面用MarkdownTyporagit来积累自己的个人知识库#xff0c;但没有做到web化#xff0c;现在也还在探索更好的方法。
无…本文介绍开源问答社区平台Answer的容器化部署。 起因
笔者一直想搭建一个类似stack overflower这样的平台自使用了Typora就正式全面用MarkdownTyporagit来积累自己的个人知识库但没有做到web化现在也还在探索更好的方法。
无意间看到了 Answer 项目觉得可能满足需求。其实这个项目早在 2022 年就已经由 SegmentFault 团队开源了去年就进入了Apache 软件基金会孵化器。只是我知道的晚而已。
本文直接使用官方提供的docker镜像来部署。该项目使用 Golang 编写有时间可以研究一下当然这是后话。
概述
Answer主要功能有摘自官方文档
提问和回答 - 提出问题并从你的用户和团队那里获得答案。组织内容 - 将你的内容组织为分类和标签。集成 - 与你现有的工具和服务集成。游戏化 - 奖励用户的贡献。现代用户界面 - 现代且响应式的用户界面。可扩展 - 使用插件扩展 Answer。开源 - 免费且开源。
服务部署
官方有详细的安装文档这里结合自己的实际情况给出步骤。
下载镜像
通过以下命令下载官方镜像
docker pull apache/answer注也可以在docker-comose阶段自动下载。虽然自动方便不过笔者喜欢按部就班做。
容器启动脚本
docker-compose.yaml文件
# cat docker-compose.yaml
version: 3
services:answer:image: apache/answercontainer_name: answerports:- 9080:80restart: on-failurevolumes:- ./answer-data:/data# - /etc/localtime:/etc/localtime#environment:# - TZAsia/Shanghai
#volumes:
# answer-data:./datadocker-compose.yaml文件根据实际情况作了修改说明如下
Anserver使用目录/data存在数据将其映射至宿主机目录。映射外部端口8090。本想自动设置时区但经测试无效因此保留注释。
启动
docker-compose up -d启动日志如下
Attaching to answer
answer | [upload-dir] try to install...
answer | [upload-dir] install success, upload directory is /data/uploads
answer | [i18n] try to install i18n bundle...
answer | [i18n] find i18n bundle 42
answer | [i18n] install af_ZA.yaml bundle...
answer | [i18n] install af_ZA.yaml bundle success
answer | [i18n] install ar_SA.yaml bundle...
...
answer | [i18n] install zh_CN.yaml bundle...
answer | [i18n] install zh_CN.yaml bundle success
answer | [i18n] install zh_TW.yaml bundle...
answer | [i18n] install zh_TW.yaml bundle success
answer | install all initial environment done
answer | [SUCCESS] answer installation service will run at: http://localhost:80/install/ 使用说明
输入http://ip:9080/根据提示进行安装。
页面配置
步骤1选择语言。 步骤2选择数据库。为简单起见使用了sqlite3。
值得说明的是Answer 支持MarialDB/MySQL、PostgreSQL 和 SQLite 数据库。前2者需要配置数据库信息如数据库地址、用户、密码等见下图。而SQLite不需要额外的配置。
步骤3创建配置文件 步骤4配置网站信息注意这里填写的用户是管理员。
登录后页面如下
添加问题/回答
根据网页提示添加即可。需要说明的是问题必须有对应的标签可自定义添加也可用管理员登录统一添加。页面示例
添加用户
路径后台管理-用户管理。
可以批量添加用户。格式为用户名,邮箱,密码注意事项
用户名长度需大于4字符。邮箱不能与已存在用户的相同。密码长度需大于8字符。
示例如下
可以修改用户状态如停用、删除、提升至管理员等。
网站设置
路径后台管理-站点设置。
一般的设置较简单根据网站提示即可。这里说一下笔者设置的地方。
登录设置不允许用户注册。
特权设置使用级别1。
小结
就目前情况看即使搭建了这个平台即使在内部推行了这个平台使用者还是自己而已。但无论如何还是走出了一步还需看后续效果。
附
官方网站https://answer.apache.org/
源码https://github.com/apache/incubator-answer
启动日志有删改
$ docker-compose logs
Attaching to answer
answer | [upload-dir] try to install...
answer | [upload-dir] install success, upload directory is /data/uploads
answer | [i18n] try to install i18n bundle...
answer | [i18n] find i18n bundle 42
answer | install all initial environment done
answer | [SUCCESS] answer installation service will run at: http://localhost:80/install/
[fengxuanmaster incubator-answer]$ docker-compose logs -f
Attaching to answer
answer | [upload-dir] try to install...
answer | [upload-dir] install success, upload directory is /data/uploads
answer | [i18n] try to install i18n bundle...
answer | [i18n] find i18n bundle 42
answer | install all initial environment done
answer | [SUCCESS] answer installation service will run at: http://localhost:80/install/
answer | [config-file] try to create at /data/conf/config.yaml
answer | [config-file] create directory success, config file is /data/conf/config.yaml
answer | [config-file] install success
answer | check table not exist
answer | [i18n] try to install i18n bundle...
answer | [i18n] find i18n bundle 42answer | [i18n] install zh_CN.yaml file exist, try to replace it
answer | [i18n] install zh_CN.yaml bundle...
answer | [i18n] install zh_CN.yaml bundle success
answer | [i18n] install zh_TW.yaml file exist, try to replace it
answer | [i18n] install zh_TW.yaml bundle...
answer | [i18n] install zh_TW.yaml bundle success
answer | try to create cache directory /data/cache
answer | try to load cache file from /data/cache/cache.db
answer | open /data/cache/cache.db: no such file or directory
answer | try to create database directory /data
answer | try to save cache file to /data/cache/cache.db
answer | upgrade done
answer | config file path: /data/conf/config.yaml
answer | Answer is starting..........................
answer | 2024-01-14 16:03:00.773 INFO data/data.go:118 try to load cache file from /data/cache/cache.db
answer | start cron
answer | answer Version: 1.2.1 Revision: d8c5577