mirror of
https://github.com/whyour/qinglong.git
synced 2026-06-30 20:35:09 +08:00
添加dockerfile
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
FROM node:lts-alpine
|
||||
LABEL maintainer="whyour"
|
||||
ARG JD_BASE_URL=https://github.com/whyour/qinglong
|
||||
ARG JD_BASE_BRANCH=master
|
||||
ARG JD_SCRIPTS_URL=https://github.com/RikudouPatrickstar/jd_scripts
|
||||
ARG JD_SCRIPTS_BRANCH=master
|
||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
|
||||
LANG=zh_CN.UTF-8 \
|
||||
SHELL=/bin/bash \
|
||||
PS1="\u@\h:\w \$ " \
|
||||
JD_DIR=/jd
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
||||
&& apk update -f \
|
||||
&& apk upgrade \
|
||||
&& apk --no-cache add -f bash \
|
||||
coreutils \
|
||||
moreutils \
|
||||
git \
|
||||
wget \
|
||||
curl \
|
||||
nano \
|
||||
tzdata \
|
||||
perl \
|
||||
openssl \
|
||||
nginx \
|
||||
&& rm -rf /var/cache/apk/* \
|
||||
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||
&& echo "Asia/Shanghai" > /etc/timezone \
|
||||
&& touch ~/.bashrc \
|
||||
&& git clone -b ${JD_BASE_BRANCH} ${JD_BASE_URL} ${JD_DIR} \
|
||||
&& cd ${JD_DIR} \
|
||||
&& curl -o- -L https://yarnpkg.com/install.sh | bash \
|
||||
&& yarn install \
|
||||
&& yarn build \
|
||||
&& git clone -b ${JD_SCRIPTS_BRANCH} ${JD_SCRIPTS_URL} ${JD_DIR}/scripts \
|
||||
&& cd ${JD_DIR}/scripts \
|
||||
&& npm install \
|
||||
&& npm install -g pm2 \
|
||||
&& rm -rf /root/.npm
|
||||
WORKDIR ${JD_DIR}
|
||||
ENTRYPOINT bash ${JD_DIR}/docker/docker-entrypoint.sh
|
||||
@@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo -e "======================1. 检测配置文件========================\n"
|
||||
[ ! -d ${JD_DIR}/config ] && mkdir -p ${JD_DIR}/config
|
||||
|
||||
if [ ! -s ${JD_DIR}/config/crontab.list ]
|
||||
then
|
||||
echo -e "检测到config配置目录下不存在crontab.list或存在但文件为空,从示例文件复制一份用于初始化...\n"
|
||||
cp -fv ${JD_DIR}/sample/crontab.list.sample ${JD_DIR}/config/crontab.list
|
||||
sed -i "s,MY_PATH,${JD_DIR},g" ${JD_DIR}/config/crontab.list
|
||||
sed -i "s,ENV_PATH=,PATH=$PATH,g" ${JD_DIR}/config/crontab.list
|
||||
fi
|
||||
crond
|
||||
crontab ${JD_DIR}/config/crontab.list
|
||||
echo -e "成功添加定时任务...\n"
|
||||
|
||||
if [ ! -s ${JD_DIR}/config/config.sh ]; then
|
||||
echo -e "检测到config配置目录下不存在config.sh,从示例文件复制一份用于初始化...\n"
|
||||
cp -fv ${JD_DIR}/sample/config.sh.sample ${JD_DIR}/config/config.sh
|
||||
echo
|
||||
fi
|
||||
|
||||
if [ ! -s ${JD_DIR}/config/auth.json ]; then
|
||||
echo -e "检测到config配置目录下不存在auth.json,从示例文件复制一份用于初始化...\n"
|
||||
cp -fv ${JD_DIR}/sample/auth.json ${JD_DIR}/config/auth.json
|
||||
echo
|
||||
fi
|
||||
|
||||
if [ ! -s /etc/nginx/conf.d/front.conf ]
|
||||
then
|
||||
echo -e "检测到nginx配置不存在...\n"
|
||||
cp -fv ${JD_DIR}/docker/front.conf /etc/nginx/conf.d/front.conf
|
||||
fi
|
||||
|
||||
echo -e "======================2. 更新源代码========================\n"
|
||||
bash ${JD_DIR}/git_pull.sh
|
||||
echo
|
||||
|
||||
echo -e "======================4. 启动挂机程序========================\n"
|
||||
. ${JD_DIR}/config/config.sh
|
||||
if [ -n "${Cookie1}" ]; then
|
||||
bash ${JD_DIR}/jd.sh hangup 2>/dev/null
|
||||
echo -e "挂机程序启动成功...\n"
|
||||
else
|
||||
echo -e "config.sh中还未填入有效的Cookie,可能是首次部署容器,因此不启动挂机程序...\n"
|
||||
fi
|
||||
|
||||
echo -e "======================5. 启动控制面板========================\n"
|
||||
pm2 start ${JD_DIR}/build/app.js
|
||||
echo -e "控制面板启动成功...\n"
|
||||
|
||||
echo -e "\n容器启动成功...\n"
|
||||
|
||||
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
|
||||
set -- node "$@"
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
@@ -0,0 +1,18 @@
|
||||
upstream api {
|
||||
server localhost:5678;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 5700;
|
||||
root /jd/dist;
|
||||
ssl_session_timeout 5m;
|
||||
|
||||
location /deploy {
|
||||
proxy_pass http://api;
|
||||
}
|
||||
|
||||
location / {
|
||||
index index.html index.htm;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user