sugar404 commited on
Commit
49a5a10
·
verified ·
1 Parent(s): a37c733

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +127 -0
Dockerfile ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:20-slim as nodebuilder
2
+
3
+ FROM python:3.11-slim-bullseye as builder
4
+ ARG QL_MAINTAINER="whyour"
5
+ LABEL maintainer="${QL_MAINTAINER}"
6
+ ARG QL_URL=https://github.com/${QL_MAINTAINER}/qinglong.git
7
+ ARG QL_BRANCH=debian
8
+
9
+ ENV QL_DIR=/ql \
10
+ QL_BRANCH=${QL_BRANCH}
11
+
12
+ COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
13
+ COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
14
+ RUN set -x && \
15
+ ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
16
+ apt-get update && \
17
+ apt-get install --no-install-recommends -y libatomic1 git && \
18
+ git config --global user.email "qinglong@@users.noreply.github.com" && \
19
+ git config --global user.name "qinglong" && \
20
+ git config --global http.postBuffer 524288000 && \
21
+ git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR}
22
+
23
+ RUN mkdir /tmp/build
24
+ RUN cp ${QL_DIR}/package.json ${QL_DIR}/.npmrc ${QL_DIR}/pnpm-lock.yaml /tmp/build/
25
+
26
+ RUN npm i -g [email protected] && \
27
+ cd /tmp/build && \
28
+ pnpm install --prod
29
+
30
+ FROM python:3.11-slim-bullseye
31
+
32
+ ARG QL_MAINTAINER="whyour"
33
+ LABEL maintainer="${QL_MAINTAINER}"
34
+ ARG QL_URL=https://github.com/${QL_MAINTAINER}/qinglong.git
35
+ ARG QL_BRANCH=debian
36
+
37
+ ENV PNPM_HOME=/root/.local/share/pnpm \
38
+ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.local/share/pnpm:/root/.local/share/pnpm/global/5/node_modules:$PNPM_HOME \
39
+ NODE_PATH=/usr/local/bin:/usr/local/pnpm-global/5/node_modules:/usr/local/lib/node_modules:/root/.local/share/pnpm/global/5/node_modules \
40
+ LANG=C.UTF-8 \
41
+ SHELL=/bin/bash \
42
+ PS1="\u@\h:\w \$ " \
43
+ QL_DIR=/ql \
44
+ QL_BRANCH=${QL_BRANCH} \
45
+ VIRTUAL_ENV=/opt/venv
46
+
47
+ COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
48
+ COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
49
+
50
+ RUN set -x && \
51
+ ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
52
+ ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx && \
53
+ apt-get update && \
54
+ apt-get upgrade -y && \
55
+ apt-get install --no-install-recommends -y git \
56
+ curl \
57
+ cron \
58
+ wget \
59
+ tzdata \
60
+ perl \
61
+ openssl \
62
+ openssh-client \
63
+ nginx \
64
+ jq \
65
+ procps \
66
+ netcat \
67
+ sshpass \
68
+ unzip \
69
+ libatomic1 \
70
+ python3-venv \
71
+ python3-pip && \
72
+ apt-get clean && \
73
+ ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
74
+ echo "Asia/Shanghai" >/etc/timezone && \
75
+ git config --global user.email "qinglong@@users.noreply.github.com" && \
76
+ git config --global user.name "qinglong" && \
77
+ git config --global http.postBuffer 524288000 && \
78
+ npm install -g [email protected] pm2 ts-node && \
79
+ python3 -m venv $VIRTUAL_ENV && \
80
+ . $VIRTUAL_ENV/bin/activate && \
81
+ pip install --no-cache-dir huggingface_hub && \
82
+ rm -rf /root/.pnpm-store && \
83
+ rm -rf /root/.local/share/pnpm/store && \
84
+ rm -rf /root/.cache && \
85
+ rm -rf /root/.npm && \
86
+ chmod u+s /usr/sbin/cron && \
87
+ ulimit -c 0
88
+
89
+ ARG SOURCE_COMMIT
90
+ RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} && \
91
+ cd ${QL_DIR} && \
92
+ cp -f .env.example .env && \
93
+ chmod 777 ${QL_DIR}/shell/*.sh && \
94
+ chmod 777 ${QL_DIR}/docker/*.sh && \
95
+ git clone --depth=1 -b ${QL_BRANCH} https://github.com/${QL_MAINTAINER}/qinglong-static.git /static && \
96
+ mkdir -p ${QL_DIR}/static && \
97
+ cp -rf /static/* ${QL_DIR}/static && \
98
+ rm -rf /static && \
99
+ rm -f ${QL_DIR}/docker/docker-entrypoint.sh
100
+
101
+ COPY docker-entrypoint.sh ${QL_DIR}/docker
102
+ COPY sync_data.sh /
103
+ RUN chmod +x /sync_data.sh
104
+
105
+ RUN mkdir -p /ql/data/{config,log,db,scripts,repo,raw,deps} && \
106
+ chmod -R 777 /ql && \
107
+ chmod -R 777 /var && \
108
+ chmod -R 777 /usr/local && \
109
+ chmod -R 777 /etc/nginx && \
110
+ chmod -R 777 /run && \
111
+ chmod -R 777 /usr && \
112
+ chmod -R 777 /root
113
+
114
+ COPY --from=builder /tmp/build/node_modules/. /ql/node_modules/
115
+
116
+ WORKDIR ${QL_DIR}
117
+
118
+ RUN useradd -m -u 1000 user
119
+ USER user
120
+
121
+ HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
122
+ CMD curl -sf --noproxy '*' http://127.0.0.1:5400/api/health || exit 1
123
+
124
+ ENTRYPOINT ["./docker/docker-entrypoint.sh"]
125
+
126
+ VOLUME /ql/data
127
+ EXPOSE 5700