From 0bbf9d35b692e8a0da66047f3190850e1e8fb908 Mon Sep 17 00:00:00 2001 From: vran Date: Mon, 18 Apr 2022 16:21:34 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9Aupdate=20docker=20file=20and=20doc?= =?UTF-8?q?=20(#104)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add DATABASIR_JWT_SECRET config * feat:update docs --- Dockerfile | 3 --- api/src/main/resources/application.properties | 2 +- docs/README/deploy/docker-deploy.md | 18 +++++++++--------- docs/README/deploy/jar-deploy.md | 4 ++++ local.Dockerfile | 5 +---- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 36c02fc..b88aebc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,4 @@ WORKDIR /app COPY --from=build /app/api/build/libs/databasir.jar /app/databasir.jar EXPOSE 8080 -#-Ddatabasir.datasource.username=${databasir.datasource.username} -#-Ddatabasir.datasource.password=${databasir.datasource.password} -#-Ddatabasir.datasource.url=${databasir.datasource.url} ENTRYPOINT ["sh", "-c","java -Ddatabasir.db.url=${DATABASIR_DB_URL} -Ddatabasir.db.username=${DATABASIR_DB_USERNAME} -Ddatabasir.db.password=${DATABASIR_DB_PASSWORD} -jar /app/databasir.jar"] diff --git a/api/src/main/resources/application.properties b/api/src/main/resources/application.properties index baf91d4..10e19ec 100644 --- a/api/src/main/resources/application.properties +++ b/api/src/main/resources/application.properties @@ -12,4 +12,4 @@ spring.flyway.baseline-on-migrate=true spring.flyway.locations=classpath:db/migration # driver directory databasir.db.driver-directory=drivers -databasir.jwt.secret=${random.uuid} \ No newline at end of file +databasir.jwt.secret=${DATABASIR_JWT_SECRET:${random.uuid}} \ No newline at end of file diff --git a/docs/README/deploy/docker-deploy.md b/docs/README/deploy/docker-deploy.md index d2880e8..49a66cf 100644 --- a/docs/README/deploy/docker-deploy.md +++ b/docs/README/deploy/docker-deploy.md @@ -5,7 +5,7 @@ ## 环境要求 1. Docker -2. Mysql +2. Mysql 5.7+ ## 测活接口 @@ -38,13 +38,14 @@ docker run -p 8888:8080 --name my-databasir -e DATABASIR_DB_URL=127.0.0.1:3306 - **docker 启动命令参数说明** -| 参数 | 说明 | -| ---------------------------------- | ------------------------------------------------- | -| --name my-databasir | 启动的镜像名称 | -| -e DATABASIR_DB_URL=127.0.0.1:3306 | 数据库连接地址 | -| -e DATABASIR_DB_USERNAME=root | 数据库连接用户名 | -| -e DATABASIR_DB_PASSWORD=123456 | 数据库连接密码 | -| -p 8888:8080 | 将 databasir 的 8080 端口映射到宿主机的 8888 端口 | +| 参数 | 说明 | 必填 | +| ---------------------------------- | ------------------------------------------------------------ | ---- | +| --name my-databasir | 启动的镜像名称 | | +| -e DATABASIR_DB_URL=127.0.0.1:3306 | 数据库连接地址 | 是 | +| -e DATABASIR_DB_USERNAME=root | 数据库连接用户名 | 是 | +| -e DATABASIR_DB_PASSWORD=123456 | 数据库连接密码 | 是 | +| -e DATABASIR_JWT_SECRET=databasir | 生成用户登录 Token 的秘钥,如果部署了多个实例,那多个实例之间的秘钥要保持一致。默认为 UUID | 否 | +| -p 8888:8080 | 将 databasir 的 8080 端口映射到宿主机的 8888 端口 | | ## 登录验证 @@ -54,4 +55,3 @@ docker run -p 8888:8080 --name my-databasir -e DATABASIR_DB_URL=127.0.0.1:3306 - - 密码:`databasir` 这时候访问 http://localhost:8888 进入登录页,输入上面的账号和密码即可成功登入,到此就算部署完成 - diff --git a/docs/README/deploy/jar-deploy.md b/docs/README/deploy/jar-deploy.md index 7b99eff..88e3b72 100644 --- a/docs/README/deploy/jar-deploy.md +++ b/docs/README/deploy/jar-deploy.md @@ -20,10 +20,14 @@ databasir.db.username=root databasir.db.password=123456 # 数据库地址 databasir.db.url=127.0.0.1:3306 +# 登录 token 生成秘钥,可选 +databasir.jwt.secret=${random.uuid} ``` 4. 通过 `java -jar Databasir.jar` 启动应用即可 +**注意:**如果部署了多个 databasir 实例,一定要定义 `databasir.jwt.secret` 的值,从而使得多个实例之间的 `databasir.jwt.secret` 保持一致 + ## 登录验证 应用启动完成后会默认创建 Databasir 管理员用户 diff --git a/local.Dockerfile b/local.Dockerfile index e3c6819..a464d62 100644 --- a/local.Dockerfile +++ b/local.Dockerfile @@ -3,7 +3,4 @@ WORKDIR /app ADD api/build/libs/databasir.jar /app/databasir.jar EXPOSE 8080 -#-Ddatabasir.datasource.username=${databasir.datasource.username} -#-Ddatabasir.datasource.password=${databasir.datasource.password} -#-Ddatabasir.datasource.url=${databasir.datasource.url} -ENTRYPOINT ["sh", "-c","java -Ddatabasir.db.url=${DATABASIR_DB_URL} -Ddatabasir.db.username=${DATABASIR_DB_USERNAME} -Ddatabasir.db.password=${DATABASIR_DB_PASSWORD} -jar /app/databasir.jar"] +ENTRYPOINT ["sh", "-c","java -XX:+PrintCommandLineFlags -Ddatabasir.db.url=${DATABASIR_DB_URL} -Ddatabasir.db.username=${DATABASIR_DB_USERNAME} -Ddatabasir.db.password=${DATABASIR_DB_PASSWORD} -jar /app/databasir.jar"]