Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

求助 #29

Open
lushi78778 opened this issue Jan 1, 2024 · 0 comments
Open

求助 #29

lushi78778 opened this issue Jan 1, 2024 · 0 comments

Comments

@lushi78778
Copy link

最初我是想给这个项目写一个dockerfile方便部署

//config.sh
[ $CF_DOMAIN ] && {
[ "$CF_DOMAIN" == "DIRECT" ] && sed -i "/\[/,/]/cexport const proxy = []" src/config/index.ts || \
sed -i "/\[/,/]/cexport const proxy = ['https://$CF_DOMAIN']" src/config/index.ts;
}
[ $BASE_PATH ] || BASE_PATH="/${REPO_NAME}"
[ "$BASE_PATH" != "/pikpak" ] && sed -i "s|/pikpak|$BASE_PATH|g" vite.config.ts
[ $INVITE_CODE ] && sed -i "s|apk/url/225815|apk/url/$INVITE_CODE|g" src/views/login.vue
[ $CF_INVITE ] && sed -i "s/invite.z7.workers.dev/$CF_INVITE/g" src/views/register.vue src/views/sms.vue src/views/testtest.vue
[ $CNAME_DOMAIN ] && echo "$CNAME_DOMAIN" > public/CNAME
//Dockerfile
# 构建应用
FROM node:18 AS builder

# 使用了 ENV 指令来设置默认的环境变量值。
# 如果在运行容器时没有设置这些环境变量,它们将采用这些默认值。

# CF反代的域名(写DIRECT就是不走反代)
ENV CF_DOMAIN=DIRECT
ENV REPO_NAME=/pikpak
# 设置你的专属邀请链接
ENV INVITE_CODE=62619818
# # 这个没看懂是啥 好像是开发者自己某的小福利,may 挣点邀请天数
# ENV CF_INVITE=
# # 如果你设置了CNAME这里写你的域名
ENV CNAME_DOMAIN=pikpak-hqk9.onrender.com

WORKDIR /app
COPY . .
RUN npm install
# 执行配置脚本 主要是懒得改了~~
RUN chmod a+x config.sh
RUN /bin/bash config.sh
RUN npm run build

# 最小化镜像
FROM node:18-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
RUN npm install -g http-server

# 默认端口
EXPOSE 12445
CMD ["http-server", "dist", "-p", "12445"]

上面是我编写的文件,应该是没问题的(成功部署),但测试时候我发现一些问题
image

很奇怪不知道为什么没有出现host
环境变量:
image

后来我在本地试了一下

$env:CF_DOMAIN="DIRECT"
$env:REPO_NAME="/"

sed -i "/\[/,/]/cexport const proxy = []" src/config/index.ts  
sed -i "s|/pikpak|$BASE_PATH|g" vite.config.ts

npm run serve

image

image

是我写错了配置吗?求帮助

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant