-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
181 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,99 @@ | ||
# 环境变量 | ||
|
||
#### 创建&编辑任务时 | ||
### 定义方式 | ||
|
||
在 compose 中的环境变量分为两种: | ||
|
||
- 直接在某个服务中定义的环境变量 | ||
- 通过 --env-file 指定环境变量文件 | ||
|
||
##### 在服务中定义环境变量 | ||
|
||
``` | ||
services: | ||
nginx: | ||
image: nginx | ||
environment: | ||
PASSWORD: 123456 | ||
``` | ||
|
||
在上面的例子中,对 nginx 服务定义了一个环境变量。在创建容器后,定义的值会注入到容器的环境变量中。 | ||
|
||
|
||
##### 在 .env 文件中定义 | ||
|
||
``` | ||
services: | ||
nginx: | ||
image: nginx | ||
environment: | ||
PASSWORD: # 假如这里的值不为空,则下方的 .env 文件定义的无效 | ||
``` | ||
|
||
在上面的例子中,在 mysql 服务中声明了一定环境变量,但是款对其赋值。这时候可以新建 .env 文件对其赋值。 | ||
|
||
``` | ||
PASSWORD=789456 | ||
``` | ||
|
||
### 多个服务环境变量同名的问题 | ||
|
||
``` | ||
services: | ||
nginx: | ||
image: nginx | ||
environment: | ||
PASSWORD: | ||
mysql: | ||
image: mysql:5.7 | ||
image: mysql | ||
environment: | ||
MYSQL_ROOT_PASSWORD: 123456 | ||
MYSQL_DATABASE: | ||
MYSQL_PASSWORD: "123456" | ||
PASSWORD: | ||
``` | ||
在 compose 中可以定义服务所用到的环境变量,这些环境变量在添加任务的时候,可以通过【管理】服务进行修改。 | ||
|
||
![compose-env](https://cdn.w7.cc/dpanel/compose-env-1.png) | ||
在上方的例子中,两个服务中都使用了 PASSWORD 环境变量,这时候在 .env 文件中定义的值同时会影响到这两个服务。\ | ||
这样全局式的环境变量有时候并不是期望的效果,如果希望可以分别指定,需要在在定义的环境变量上再加一层【环境变量】。 | ||
|
||
#### 运行时修改 | ||
|
||
在部署 compose 任务的时候,也可以再次对环境变量进行修改。 | ||
``` | ||
services: | ||
nginx: | ||
image: nginx | ||
environment: | ||
PASSWORD: ${NGINX_PASSWORD} | ||
mysql: | ||
image: mysql | ||
environment: | ||
PASSWORD: ${MYSQL_PASSWORD} | ||
``` | ||
|
||
![compose-env](https://cdn.w7.cc/dpanel/compose-env-2.png?a=1) | ||
``` | ||
NGINX_PASSWORD=123456 | ||
MYSQL_PASSWORD=789456 | ||
#### 多 Docker 环境 | ||
``` | ||
|
||
如果你有多个【[Docker 环境](zh-cn/manual/setting/docker-env)】在部署你也可以为每个环境新建私有的【[覆盖配置](/zh-cn/manual/compose/override)】。\ | ||
多环境的覆盖配置文件以 环境名.yaml 或是 环境名.yml 命名。 | ||
### 使用环境变量区分环境差异 | ||
|
||
假设你当前有两个 docker 环境,分别是 local 及 remote。那么你可以通过下面的方式为每个环境创建私有的覆盖配置。\ | ||
环境级别的覆盖配置优先级最高,你可以在环境配置中对 yaml 中的任何配置进行修改。 | ||
如果你有多个【[Docker 环境](zh-cn/manual/setting/docker-env)】在部署希望根据不同的环境使用不同的镜像版本,可以给 image 声明一个环境变量。 | ||
|
||
``` | ||
/dpanel | ||
├─ /compose | ||
│ ├─ /lucky | ||
│ │ ├─ 1.override.yaml 自定义的覆盖配置 | ||
│ │ ├─ local.yaml local 环境的私有配置 | ||
│ │ ├─ remote.yaml remote 环境的私有配置 | ||
│ │ └─ compose.yaml | ||
│ └─ ... | ||
└─ .... | ||
services: | ||
nginx: | ||
image: ${NGINX_IMAGE} | ||
environment: | ||
PASSWORD: 123456 | ||
``` | ||
|
||
这样在部署的时候就可以动态的调整应该使用哪个镜像来部署,对于 compose.yaml 中其它的参也可以通过此方便来定义。 | ||
|
||
|
||
### 面板中如何定义? | ||
|
||
要创建 compose 任务时,面板会自动查找 yaml 中的环境变量,并生成列表。\ | ||
在创建任务的时候,你需要给这些值定义其默认值。 | ||
|
||
![compose-env-3](https://cdn.w7.cc/dpanel/compose-env-3.png) | ||
|
||
在部署的时候,可根据当前的情况进行重定义,重定义操作只会影响到本次部署。 | ||
|
||
![compose-env-3](https://cdn.w7.cc/dpanel/compose-env-4.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# 应用商店 | ||
|
||
### 添加第三方应用商店 | ||
|
||
> DPanel 面板支持同时添加多个应用商店 | ||
通过【系统】- 【应用商店】-【添加第三方商店】来创建一个应用商店。\ | ||
创建完成后,会在【Compose】菜单中显示【应用商店】菜单。 | ||
|
||
![compose-store-2](https://cdn.w7.cc/dpanel/compose-store-2.png) | ||
|
||
### 更新商店 | ||
|
||
在 DPanel 面板中添加应用商店时,会将商店的数据离线保存至面板的 /dpanel/store 目录中。\ | ||
如果该商店有更新,需要在【应用商店】列表中手动进行更新数据。 | ||
|
||
### 支持类型 | ||
|
||
只要符合 docker compose 的规范,都可以接入到 DPanel 的第三方应用商店中。\ | ||
DPanel 面板需要根据不同的规范协议解析出商店的说明信息。 | ||
|
||
欢迎大家提交 Issue 丰富第三方应用商店,目前支持以下两种规范的商店。 | ||
|
||
|商店类型|示例仓库|说明| | ||
|---|---|---| | ||
|1panel|https://github.com/1Panel-dev/appstore|[规范说明](https://github.com/1Panel-dev/appstore/wiki/%E5%A6%82%E4%BD%95%E6%8F%90%E4%BA%A4%E8%87%AA%E5%B7%B1%E6%83%B3%E8%A6%81%E7%9A%84%E5%BA%94%E7%94%A8)| | ||
|CasaOS|https://github.com/Cp0204/CasaOS-AppStore-Play|[规范说明](https://awesome.casaos.io/content/3rd-party-app-stores/create-your-first-custom-appstore.html)| | ||
|
||
### 全商店搜索 | ||
|
||
在多个不同的应用商店中,难免会出现相同或是差异的应用。在 DPanel 面板中,提供了检索所有商店的功能。\ | ||
方便快速的去查找自己需要的的应用。 | ||
|
||
![compose-store-3](https://cdn.w7.cc/dpanel/compose-store-3.png) |