mirror of https://github.com/stilleshan/subweb.git
support custom api url by environment
This commit is contained in:
parent
6b01a7bbe9
commit
5bb2743cb8
|
@ -8,5 +8,6 @@ RUN npm run build
|
|||
|
||||
FROM nginx:1.16-alpine
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
COPY start.sh /
|
||||
EXPOSE 80
|
||||
CMD [ "nginx", "-g", "daemon off;" ]
|
||||
CMD [ "sh", "-c", "/start.sh" ]
|
||||
|
|
25
README.md
25
README.md
|
@ -16,25 +16,26 @@ Docker [stilleshan/subweb](https://hub.docker.com/r/stilleshan/subweb)*
|
|||
### docker 本地版
|
||||
*适用于本机部署使用*
|
||||
```shell
|
||||
docker run -d --name subweb --restart always -p 18080:80 stilleshan/subweb
|
||||
docker run -d --name subweb --restart always \
|
||||
-p 18080:80 \
|
||||
stilleshan/subweb
|
||||
```
|
||||
|
||||
访问 `http://127.0.0.1:18080`
|
||||
|
||||
### docker 在线版 (自定义后端 API)
|
||||
*适用于服务器部署,配合域名反代使用*
|
||||
|
||||
**修改自定义 subconverter API 地址需要自行编译构建镜像. **
|
||||
### docker 自定义后端 API 地址
|
||||
修改`API_URL`环境变量为你的后端 API 地址
|
||||
```shell
|
||||
git clone https://github.com/stilleshan/subweb
|
||||
cd subweb
|
||||
# 修改 .env.productionn 中 VUE_APP_BASE_API_URL 为你 subconverter 后端 API 地址.
|
||||
docker build -t subweb .
|
||||
# 构建镜像
|
||||
docker run -d --name subweb --restart always -p 18080:80 subweb
|
||||
# 启动容器
|
||||
docker run -d --name subweb --restart always \
|
||||
-p 18080:80 \
|
||||
-e API_URL=https://sub.ops.ci \
|
||||
stilleshan/subweb
|
||||
```
|
||||
|
||||
访问 `http://127.0.0.1:18080`
|
||||
> *推荐使用 nginx 反向代理部署*
|
||||
|
||||
|
||||
## 链接
|
||||
- [GitHub - stilleshan/subweb](https://github.com/stilleshan/subweb)
|
||||
- [GitHub - stilleshan/subconverter](https://github.com/stilleshan/subconverter)
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#/bin/sh
|
||||
|
||||
if [ $API_URL ]; then
|
||||
echo "当前 API 地址为: $API_URL"
|
||||
for js in /usr/share/nginx/html/js/*.js
|
||||
do
|
||||
sed -i "s#http://127.0.0.1:25500#$API_URL#g" $js
|
||||
done
|
||||
else
|
||||
echo "当前为默认本地 API 地址: http://127.0.0.1:25500"
|
||||
echo "如需修改请在容器启动时使用 -e API_URL='https://sub.ops.ci' 传递环境变量"
|
||||
fi
|
||||
|
||||
nginx -g "daemon off;"
|
Loading…
Reference in New Issue