BBrother commited on
Commit
af56f66
1 Parent(s): 7e8a0c1

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +46 -0
Dockerfile ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 使用基础镜像
2
+ FROM golang:alpine AS builder
3
+
4
+ # 安装必要的工具
5
+ RUN apk update && apk add --no-cache \
6
+ curl \
7
+ tar \
8
+ jq
9
+
10
+ # 创建新的工作目录
11
+ WORKDIR /app
12
+
13
+
14
+ # 下载并解压文件,并给予所有用户读写和执行权限
15
+ RUN version=$(basename $(curl -sL -o /dev/null -w %{url_effective} https://github.com/pandora-next/deploy/releases/latest)) \
16
+ && base_url="https://github.com/pandora-next/deploy/releases/expanded_assets/$version" \
17
+ && latest_url="https://github.com/$(curl -sL $base_url | grep "href.*amd64.*\.tar.gz" | sed 's/.*href="//' | sed 's/".*//')" \
18
+ && curl -Lo PandoraNext.tar.gz $latest_url \
19
+ && tar -xzf PandoraNext.tar.gz --strip-components=1 \
20
+ && rm PandoraNext.tar.gz \
21
+ && chmod 777 -R .
22
+
23
+ # 获取tokens.json
24
+ RUN --mount=type=secret,id=TOKENS_JSON,dst=/etc/secrets/TOKENS_JSON \
25
+ if [ -f /etc/secrets/TOKENS_JSON ]; then \
26
+ cat /etc/secrets/TOKENS_JSON > tokens.json \
27
+ && chmod 777 tokens.json; \
28
+ else \
29
+ echo "TOKENS_JSON not found, skipping"; \
30
+ fi
31
+
32
+ # 获取config.json
33
+ RUN --mount=type=secret,id=CONFIG_JSON,dst=/etc/secrets/CONFIG_JSON \
34
+ cat /etc/secrets/CONFIG_JSON > config.json && chmod 777 config.json
35
+
36
+ # 修改PandoraNext的执行权限
37
+ RUN chmod 777 ./PandoraNext
38
+
39
+ # 创建全局缓存目录并提供最宽松的权限
40
+ RUN mkdir /.cache && chmod 777 /.cache
41
+
42
+ # 开放端口
43
+ EXPOSE 7860
44
+
45
+ # 启动命令
46
+ CMD ["./PandoraNext"]