mirror of https://gitee.com/answerdev/answer.git
doc: update install and readme doc
This commit is contained in:
parent
2b1ad94791
commit
000f459acf
130
INSTALL.md
130
INSTALL.md
|
@ -1,103 +1,69 @@
|
|||
# How to build and install
|
||||
# Answer installation guide
|
||||
## Environment Preparation
|
||||
- Memory >= 512M
|
||||
- If using MySQL version >= 5.7
|
||||
|
||||
Before installing Answer, you need to install the base environment first.
|
||||
- database
|
||||
- [MySQL](http://dev.mysql.com) Version >= 5.7
|
||||
|
||||
You can then install Answer in several ways:
|
||||
|
||||
- [Deploy with Docker](#Docker-compose-for-Answer)
|
||||
- [Binary installation](#Install-Answer-using-binary)
|
||||
- [Source installation](#Compile-the-image)
|
||||
|
||||
## Docker-compose for Answer
|
||||
## Installing with docker
|
||||
### Step 1: Start the project with the docker command
|
||||
```bash
|
||||
$ mkdir answer && cd answer
|
||||
$ wget https://raw.githubusercontent.com/answerdev/answer/main/docker-compose.yaml
|
||||
$ docker-compose up
|
||||
docker run -d -p 9080:80 -v answer-data:/data --name answer answerdev/answer:latest
|
||||
```
|
||||
|
||||
In browser, open URL [http://127.0.0.1:9080/](http://127.0.0.1:9080/).
|
||||
### Step 2: Access the installation path for project installation
|
||||
[http://127.0.0.1:9080/install](http://127.0.0.1:9080/install)
|
||||
|
||||
You can log in with the default administrator username (**`admin@admin.com`**) and password (**`admin`**).
|
||||
After selecting the language click next to select the appropriate database, if you just want to experience it currently, it is recommended to select sqlite as the database directly, as shown below
|
||||
|
||||
## Docker for Answer
|
||||
Visit [Docker Hub](https://hub.docker.com/r/answerdev/answer) or GitHub Container registry to see all available images and tags.
|
||||
! [install-database](docs/img/install-database.png)
|
||||
|
||||
### Usage
|
||||
To persist data beyond the life of a Docker container, use a volume (/var/data -> /data). You can modify this based on your situation.
|
||||
Then click next to create the configuration file, click next to enter the basic website information and administrator information, as shown below
|
||||
|
||||
```
|
||||
# Pull image from Docker Hub.
|
||||
$ docker pull answerdev/answer:latest
|
||||
! [install- site-info](docs/img/install- site-info.png)
|
||||
|
||||
# Create local directory for volume.
|
||||
$ mkdir -p /var/data
|
||||
Click Next to complete the installation
|
||||
|
||||
# Run the image first
|
||||
$ docker run --name=answer -p 9080:80 -v /var/data:/data answerdev/answer
|
||||
### Step 3: After installation, visit the project path to start using
|
||||
[http://127.0.0.1:9080/](http://127.0.0.1:9080/)
|
||||
|
||||
# After successful first startup, a configuration file will be generated in the /var/data directory
|
||||
# /var/data/conf/config.yaml
|
||||
# Need to modify the Mysql database address in the configuration file
|
||||
vim /var/data/conf/config.yaml
|
||||
Login with the administrator username and password you just created.
|
||||
|
||||
# Modify database connection
|
||||
# connection: [username]:[password]@tcp([host]:[port])/[DbName]
|
||||
...
|
||||
|
||||
# After configuring the configuration file, you can start the container again to start the service
|
||||
$ docker start answer
|
||||
## Installing with docker-compose
|
||||
### Step 1: Start the project with the docker-compose command
|
||||
```bash
|
||||
mkdir answer && cd answer
|
||||
wget https://raw.githubusercontent.com/answerdev/answer/main/docker-compose.yaml
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
## Install Answer using binary
|
||||
### Step 2: Access the installation path for project installation
|
||||
[http://127.0.0.1:9080/install](http://127.0.0.1:9080/install)
|
||||
|
||||
1. Unzip the compressed package
|
||||
2. Use the command `cd` to enter the directory you just created
|
||||
3. Execute the command `./answer init`
|
||||
4. Answer will generate a `./data` directory in the current directory
|
||||
5. Enter the `data` directory and modify the `config.yaml` file
|
||||
6. Modify the database connection identify your database connection information
|
||||
`connection: [username]:[password]@tcp([host]:[port])/[DbName]`
|
||||
7. Use `cd ..` to return the directory from step 2, and execute `./answer run -c ./data/conf/config.yaml`
|
||||
The exact configuration is the same as for docker use
|
||||
|
||||
## Available Commands
|
||||
Usage: `answer [command]`
|
||||
### Step 3: After installation, access the project path to start using
|
||||
[http://127.0.0.1:9080/](http://127.0.0.1:9080/)
|
||||
|
||||
- `help`: Help about any command
|
||||
- `init`: Init answer application
|
||||
- `run`: Run answer application
|
||||
- `check`: Check answer required environment
|
||||
- `dump`: Backup answer data
|
||||
## Install with binary
|
||||
### Step 1: Download the binaries
|
||||
[https://github.com/answerdev/answer/releases](https://github.com/answerdev/answer/releases)
|
||||
Download the version you need for your current system
|
||||
|
||||
## config.yaml Description
|
||||
Here is a sample/default config.yaml file, as would be created from `answer init`.
|
||||
```
|
||||
server:
|
||||
http:
|
||||
addr: 0.0.0.0:80 #Project access port number
|
||||
data:
|
||||
database:
|
||||
connection: root:root@tcp(127.0.0.1:3306)/answer #MySQL database connection address
|
||||
cache:
|
||||
file_path: "/tmp/cache/cache.db" #Cache file storage path
|
||||
i18n:
|
||||
bundle_dir: "/data/i18n" #Internationalized file storage directory
|
||||
swaggerui:
|
||||
show: true #Whether to display the swaggerapi documentation, address /swagger/index.html
|
||||
protocol: http #swagger protocol header
|
||||
host: 127.0.0.1 #An accessible IP address or domain name
|
||||
address: ':80' #accessible port number
|
||||
service_config:
|
||||
secret_key: "answer" #encryption key
|
||||
web_host: "http://127.0.0.1" #Page access using domain name address
|
||||
upload_path: "./uploads" #upload directory
|
||||
### Step 2: Install using command line
|
||||
> The following command -C specifies the data directory required for answer, you can modify it as you see fit
|
||||
|
||||
```bash
|
||||
. /answer init -C . /answer-data/
|
||||
```
|
||||
|
||||
## Compile the image
|
||||
If you have modified the source files and want to repackage the image, you can use the following to repackage the image
|
||||
Then visit: [http://127.0.0.1:9080/install](http://127.0.0.1:9080/install) to install, the configuration is the same as using docker installation
|
||||
|
||||
### Step 3: Start with command line
|
||||
After the installation is complete, the program will exit, so use the command to start the project formally
|
||||
```bash
|
||||
. /answer run -C . /answer-data/
|
||||
```
|
||||
docker build -t answer:v1.0.0 .
|
||||
```
|
||||
## common problem
|
||||
1. The project cannot be started: the main program startup depends on proper configuraiton of the configuration file, `config.yaml`, as well as the internationalization translation directory (`i18n`), and the upload file storage directory (`uploads`). Ensure that the configuration file is loaded when the project starts, such as when using `answer run -c config.yaml` and that the `config.yaml` correctly specifies the i18n and uploads directories.
|
||||
|
||||
After normal startup you can access [http://127.0.0.1:9080/](http://127.0.0.1:9080/) to log in using the administrator username password specified during installation
|
||||
|
||||
## Installation FAQ
|
||||
- Having trouble reinstalling using docker? The default command we give is to use `answer-data` to name the volume, so if you don't need the original data again, please delete it voluntarily `docker volume rm answer-data`
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
# Answer 安装指引
|
||||
## 环境准备
|
||||
- 内存 >= 512M
|
||||
- 如果使用 MySQL 版本 >= 5.7
|
||||
|
||||
## 使用 docker 安装
|
||||
### 步骤 1: 使用 docker 命令启动项目
|
||||
|
@ -50,31 +53,16 @@ docker-compose up
|
|||
```bash
|
||||
./answer init -C ./answer-data/
|
||||
```
|
||||
server:
|
||||
http:
|
||||
addr: 0.0.0.0:80 #项目访问端口号
|
||||
data:
|
||||
database:
|
||||
connection: root:root@tcp(127.0.0.1:3306)/answer #mysql数据库连接地址
|
||||
cache:
|
||||
file_path: "/tmp/cache/cache.db" #缓存文件存放路径
|
||||
i18n:
|
||||
bundle_dir: "/data/i18n" #国际化文件存放目录
|
||||
swaggerui:
|
||||
show: true #是否显示swaggerapi文档,地址 /swagger/index.html
|
||||
protocol: http #swagger 协议头
|
||||
host: 127.0.0.1 #可被访问的ip地址或域名
|
||||
address: ':80' #可被访问的端口号
|
||||
service_config:
|
||||
secret_key: "answer" #加密key
|
||||
web_host: "http://127.0.0.1" #页面访问使用域名地址
|
||||
upload_path: "./upfiles" #上传目录
|
||||
|
||||
然后访问:[http://127.0.0.1:9080/install](http://127.0.0.1:9080/install) 进行安装,具体配置与使用 docker 安装相同
|
||||
|
||||
### 步骤 3: 使用命令行启动
|
||||
安装完成之后程序会退出,请使用命令正式启动项目
|
||||
```bash
|
||||
./answer run -C ./answer-data/
|
||||
```
|
||||
|
||||
## 编译镜像
|
||||
如果修改了源文件并且要重新打包镜像可以使用以下语句重新打包镜像
|
||||
```
|
||||
docker build -t answer:v1.0.0 .
|
||||
```
|
||||
## 常见问题
|
||||
1. 项目无法启动,answer 主程序启动依赖配置文件 config.yaml 、国际化翻译目录 /i18n 、上传文件存放目录 /upfiles,需要确保项目启动时加载了配置文件 answer run -c config.yaml 以及在 config.yaml 正确的指定 i18n 和 upfiles 目录的配置项
|
||||
正常启动后可以访问 [http://127.0.0.1:9080/](http://127.0.0.1:9080/) 使用安装时指定的管理员用户名密码进行登录
|
||||
|
||||
## 安装常见问题
|
||||
- 使用 docker 重新安装遇到问题?默认我们给出的命令是使用 `answer-data` 命名卷,所以如果重新不需要原来的数据,请主动进行删除 `docker volume rm answer-data`
|
||||
|
|
4
Makefile
4
Makefile
|
@ -1,6 +1,6 @@
|
|||
.PHONY: build clean ui
|
||||
|
||||
VERSION=0.0.1
|
||||
VERSION=0.3.0
|
||||
BIN=answer
|
||||
DIR_SRC=./cmd/answer
|
||||
DOCKER_CMD=docker
|
||||
|
@ -40,6 +40,6 @@ install-ui-packages:
|
|||
|
||||
ui:
|
||||
@npm config set registry https://repo.huaweicloud.com/repository/npm/
|
||||
@cd ui && echo "REACT_APP_VERSION=$(VERSION)" >> .env && pnpm install && pnpm build && cd -
|
||||
@cd ui && pnpm install && pnpm build && cd -
|
||||
|
||||
all: clean build
|
||||
|
|
|
@ -22,7 +22,7 @@ To learn more about the project, visit [answer.dev](https://answer.dev).
|
|||
### Running with docker
|
||||
|
||||
```bash
|
||||
docker run -d -p 9080:80 -v $PWD/answer-data:/data --name answer answerdev/answer:latest
|
||||
docker run -d -p 9080:80 -v answer-data:/data --name answer answerdev/answer:latest
|
||||
```
|
||||
|
||||
For more information, see [INSTALL.md](./INSTALL.md)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
### 使用 docker 快速搭建
|
||||
|
||||
```bash
|
||||
docker run -d -p 9080:80 -v $PWD/answer-data:/data --name answer answerdev/answer:latest
|
||||
docker run -d -p 9080:80 -v answer-data:/data --name answer answerdev/answer:latest
|
||||
```
|
||||
|
||||
其他安装配置细节请参考 [INSTALL.md](./INSTALL.md)
|
||||
|
|
Loading…
Reference in New Issue