Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

feat: update all default config file path to absolute path

LinkinStarebda51ba2930
diff --git a/Dockerfile b/Dockerfile
index 53d65fbc..590fa0a1 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -21,7 +21,6 @@ WORKDIR ${BUILD_DIR}
COPY --from=node-builder /tmp/build ${BUILD_DIR}/ui/build
RUN make clean build && \
cp answer /usr/bin/answer && \
- mkdir -p /tmp/cache && chmod 777 /tmp/cache && \
mkdir -p /data/conf && chmod 777 /data/conf && cp configs/config.yaml /data/conf/config.yaml && \
mkdir -p /data/upfiles && chmod 777 /data/upfiles && \
mkdir -p /data/i18n && chmod 777 /data/i18n && cp -r i18n/*.yaml /data/i18n
@@ -34,7 +33,8 @@ RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.li
&& apt -y update \
&& apt -y upgrade \
&& apt -y install ca-certificates openssl tzdata curl netcat dumb-init \
- && apt -y autoremove
+ && apt -y autoremove \
+ && mkdir -p /tmp/cache
COPY --from=golang-builder /data /data
VOLUME /data
diff --git a/INSTALL.md b/INSTALL.md
index 3827a1fc..0d414968 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -27,9 +27,9 @@ $ mkdir -p /var/data
$ docker run --name=answer -p 9080:80 -v /var/data:/data answer/answer
# After the first startup, a configuration file will be generated in the /var/data directory
-# /var/data/config.yaml
+# /var/data/conf/config.yaml
# Need to modify the Mysql database address in the configuration file
-vim /var/data/config.yaml
+vim /var/data/conf/config.yaml
# Modify database connection
# connection: [username]:[password]@tcp([host]:[port])/[DbName]
@@ -51,7 +51,7 @@ $ docker start answer
6. Modify the database connection address to your database connection address
connection: [username]:[password]@tcp([host]:[port])/[DbName]
- 7. Exit the data directory and execute ./answer run -c ./data/config.yaml
+ 7. Exit the data directory and execute ./answer run -c ./data/conf/config.yaml
## config.yaml Description
diff --git a/INSTALL_CN.md b/INSTALL_CN.md
index 744d5249..d3f2ec09 100644
--- a/INSTALL_CN.md
+++ b/INSTALL_CN.md
@@ -27,9 +27,9 @@ $ mkdir -p /var/data
$ docker run --name=answer -p 9080:80 -v /var/data:/data answer/answer
# 第一次启动后会在/var/data 目录下生成配置文件
-# /var/data/config.yaml
+π# /var/data/conf/config.yaml
# 需要修改配置文件中的Mysql 数据库地址
-vim /var/data/config.yaml
+vim /var/data/conf/config.yaml
# 修改数据库连接 connection: [username]:[password]@tcp([host]:[port])/[DbName]
...
@@ -50,7 +50,7 @@ $ docker start answer
6. 将数据库连接地址修改为你的数据库连接地址
connection: [username]:[password]@tcp([host]:[port])/[DbName]
- 7. 退出data 目录 执行 ./answer run -c ./data/config.yaml
+ 7. 退出data 目录 执行 ./answer run -c ./data/conf/config.yaml
## 配置文件 config.yaml 参数说明
diff --git a/docker-compose.yaml b/docker-compose.yaml
index fd1fa19b..b22a539c 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -10,6 +10,8 @@ services:
condition: service_healthy
links:
- db
+ volumes:
+ - answer-data:/data
db:
image: mariadb:10.4.7
ports:
@@ -22,3 +24,5 @@ services:
test: [ "CMD", "mysqladmin" ,"ping", "-uroot", "-proot"]
timeout: 20s
retries: 10
+volumes:
+ answer-data:
diff --git a/internal/cli/install.go b/internal/cli/install.go
index 00200715..74a1f574 100644
--- a/internal/cli/install.go
+++ b/internal/cli/install.go
@@ -15,9 +15,9 @@ import (
)
const (
- defaultConfigFilePath = "data/config.yaml"
- defaultUploadFilePath = "data/upfiles"
- defaultI18nPath = "data/i18n"
+ defaultConfigFilePath = "/data/conf/config.yaml"
+ defaultUploadFilePath = "/data/upfiles"
+ defaultI18nPath = "/data/i18n"
)
// InstallAllInitialEnvironment install all initial environment
diff --git a/script/entrypoint.sh b/script/entrypoint.sh
index 11f2f2fa..95a17980 100755
--- a/script/entrypoint.sh
+++ b/script/entrypoint.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-if [ ! -f "/data/config.yaml" ]; then
+if [ ! -f "/data/conf/config.yaml" ]; then
/usr/bin/answer init
fi
/usr/bin/answer run -c /data/conf/config.yaml
diff --git a/script/prebuild.sh b/script/prebuild.sh
deleted file mode 100644
index 6c7da8a7..00000000
--- a/script/prebuild.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env bash
-
-git clone https://git.backyard.segmentfault.com/opensource/pacman.git /tmp/sf-pacman
-
-cat <<'EOF' > go.work
-go 1.18
-
-use (
- .
- /tmp/sf-pacman
- /tmp/sf-pacman/contrib/cache/redis
- /tmp/sf-pacman/contrib/cache/memory
- /tmp/sf-pacman/contrib/conf/viper
- /tmp/sf-pacman/contrib/log/zap
- /tmp/sf-pacman/contrib/i18n
- /tmp/sf-pacman/contrib/server/http
-)
-EOF
-
-go work sync