parent
08c6b7b87f
commit
0e2578738f
@ -1,13 +0,0 @@ |
|||||||
#!/bin/bash |
|
||||||
# |
|
||||||
# |
|
||||||
w_path=`pwd` |
|
||||||
s_path=`dirname ${w_path}` |
|
||||||
|
|
||||||
#first build fir_client |
|
||||||
docker pull node:14.17.3 |
|
||||||
docker run --rm -v ${s_path}/fir_client:/fir_client -it node:14.17.3 sh /fir_client/build.sh |
|
||||||
|
|
||||||
## secode build fir_ser |
|
||||||
cd ../ |
|
||||||
docker build . -t flyapps |
|
@ -1,6 +0,0 @@ |
|||||||
#!/bin/bash |
|
||||||
sed -i '/^\[program:init/,$d' /etc/supervisor/conf.d/flyapps.conf |
|
||||||
supervisorctl stop init &>/dev/null |
|
||||||
supervisorctl stop end &>/dev/null |
|
||||||
echo 'init end------------------------------------------' |
|
||||||
exit 0 |
|
@ -1,58 +0,0 @@ |
|||||||
[program:nginx] |
|
||||||
command=/usr/sbin/nginx -g 'daemon off;' |
|
||||||
stdout_logfile=/data/logs/nginx.log |
|
||||||
stderr_logfile=/data/logs/nginx.err |
|
||||||
#user=nginx |
|
||||||
autostart=true |
|
||||||
autorestart=true |
|
||||||
startsecs=1 |
|
||||||
|
|
||||||
[program:redis] |
|
||||||
command=/usr/bin/redis-server /etc/redis/redis.conf |
|
||||||
stdout_logfile=/data/logs/redis.log |
|
||||||
stderr_logfile=/data/logs/redis.err |
|
||||||
autostart=true |
|
||||||
autorestart=true |
|
||||||
startsecs=3 |
|
||||||
daemonize=no |
|
||||||
[program:flyapps] |
|
||||||
directory=/data/flyapps/fir_ser/ |
|
||||||
command=/usr/local/bin/uwsgi --ini uwsgi.conf |
|
||||||
user=www-data |
|
||||||
stdout_logfile=/data/logs/flyapps.log |
|
||||||
stderr_logfile=/data/logs/flyapps.err |
|
||||||
autostart=true |
|
||||||
autorestart=true |
|
||||||
startsecs=3 |
|
||||||
daemonize=no |
|
||||||
|
|
||||||
[program:celery] |
|
||||||
directory=/data/flyapps/fir_ser/ |
|
||||||
command=/usr/local/bin/celery -A fir_ser worker --beat --scheduler django --loglevel=debug |
|
||||||
user=www-data |
|
||||||
stdout_logfile=/data/logs/celery.log |
|
||||||
stderr_logfile=/data/logs/celery.err |
|
||||||
autostart=true |
|
||||||
autorestart=true |
|
||||||
startsecs=3 |
|
||||||
daemonize=no |
|
||||||
|
|
||||||
[program:init] |
|
||||||
startsecs=1 |
|
||||||
stdout_logfile=/data/logs/init.log |
|
||||||
stderr_logfile=/data/logs/init.err |
|
||||||
command=/data/flyapps/init.sh |
|
||||||
user=www-data |
|
||||||
autostart=true |
|
||||||
autorestart=false |
|
||||||
daemonize=no |
|
||||||
|
|
||||||
[program:end] |
|
||||||
startsecs=1 |
|
||||||
stdout_logfile=/data/logs/init.log |
|
||||||
stderr_logfile=/data/logs/init.err |
|
||||||
command=/data/flyapps/end.sh |
|
||||||
autostart=true |
|
||||||
autorestart=false |
|
||||||
daemonize=no |
|
||||||
|
|
@ -1,5 +0,0 @@ |
|||||||
#!/bin/bash |
|
||||||
cd /data/flyapps/fir_ser/ |
|
||||||
python manage.py makemigrations && python manage.py migrate |
|
||||||
python manage.py loaddata dumpdata.json |
|
||||||
exit 0 |
|
@ -1,10 +0,0 @@ |
|||||||
#!/bin/bash |
|
||||||
# |
|
||||||
# |
|
||||||
docker network create flyapps |
|
||||||
docker run --net flyapps --name mariadb -e MARIADB_ROOT_PASSWORD=root -d mariadb:10.5 |
|
||||||
docker exec -it mariadb mysql -proot -e 'create database flyapp default character set utf8 COLLATE utf8_general_ci;' |
|
||||||
docker exec -it mariadb mysql -proot -e "grant all on flyapp.* to flyuser@'%' identified by 'KGzKjZpWBp4R4RSa';" |
|
||||||
|
|
||||||
|
|
||||||
docker run --net flyapps --link mariadb:mariadb -p 443:443 --name flyapps -d flyapps |
|
@ -1,41 +0,0 @@ |
|||||||
[uwsgi] |
|
||||||
# 对外提供 http 服务的端口 |
|
||||||
#http = 127.0.0.1:8899 |
|
||||||
|
|
||||||
#listen = 512 # set max connections to 1024 in uWSGI |
|
||||||
|
|
||||||
#the local unix socket file than commnuincate to Nginx 用于和 nginx 进行数据交互的端口 |
|
||||||
socket = 127.0.0.1:8899 |
|
||||||
|
|
||||||
# the base directory (full path) django 程序的主目录 |
|
||||||
chdir = /data/flyapps/fir_ser |
|
||||||
|
|
||||||
# Django's wsgi file |
|
||||||
wsgi-file = fir_ser/wsgi.py |
|
||||||
|
|
||||||
touch-reload = fir_ser |
|
||||||
#uwsgi 内部解析数据包大小为4K ,自己可以增加64k |
|
||||||
buffer-size = 65536 |
|
||||||
# maximum number of worker processes |
|
||||||
processes = 8 |
|
||||||
|
|
||||||
#thread numbers startched in each worker process |
|
||||||
threads = 4 |
|
||||||
|
|
||||||
#monitor uwsgi status 通过该端口可以监控 uwsgi 的负载情况 |
|
||||||
stats = 127.0.0.1:9191 |
|
||||||
|
|
||||||
# 如果以nginx用户运行,则需要授权 ruby 权限 chmod ug+s /usr/local/rvm/rubies/ruby-2.7.0/bin/ruby /usr/bin/isign 否则,会导致登录信息保存失败 |
|
||||||
uid=www-data |
|
||||||
gid=www-data |
|
||||||
|
|
||||||
# clear environment on exit |
|
||||||
vacuum = true |
|
||||||
|
|
||||||
enable-threads = true |
|
||||||
|
|
||||||
# 后台运行,并输出日志 |
|
||||||
#daemonize = ./flyapp.log |
|
||||||
|
|
||||||
# 为了让阿里云cdn可以缓存数据 |
|
||||||
del-header=cache-control |
|
@ -1,46 +0,0 @@ |
|||||||
FROM python:3.6.14-slim |
|
||||||
|
|
||||||
# Fixes some weird terminal issues such as broken clear / CTRL+L |
|
||||||
ARG PIP_MIRROR=https://mirrors.aliyun.com/pypi/simple |
|
||||||
|
|
||||||
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list \ |
|
||||||
&& sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list \ |
|
||||||
&& apt update |
|
||||||
|
|
||||||
RUN apt-get install g++ wget nginx redis supervisor -y |
|
||||||
RUN apt-get install libssl-dev openssl libmariadb-dev sqlite -y |
|
||||||
RUN rm -rf /var/lib/apt/lists/* |
|
||||||
|
|
||||||
|
|
||||||
RUN mkdir -pv /data/flyapps |
|
||||||
RUN mkdir -pv /data/logs/ |
|
||||||
|
|
||||||
COPY fir_client/dist /data/flyapps/fir_client |
|
||||||
|
|
||||||
RUN cd /opt/ && wget https://github.com/nineaiyu/zsign/archive/refs/tags/v1.1.1.tar.gz |
|
||||||
RUN cd /opt/ && tar xvf v1.1.1.tar.gz && cd zsign-1.1.1/ && g++ *.cpp common/*.cpp -lcrypto -O3 -std=c++11 -o zsign && cp zsign /usr/bin/ |
|
||||||
# install pip |
|
||||||
COPY fir_ser /data/flyapps/fir_ser |
|
||||||
RUN cd /data/flyapps/fir_ser/ && pip install -U setuptools pip -i ${PIP_MIRROR} --ignore-installed && pip install --no-cache-dir -r requirements.txt -i ${PIP_MIRROR} && pip install --no-cache-dir uwsgi -i ${PIP_MIRROR} |
|
||||||
|
|
||||||
RUN rm -rf /var/cache/yum/ |
|
||||||
|
|
||||||
COPY Docker/flyapps.conf /etc/supervisor/conf.d/flyapps.conf |
|
||||||
COPY Docker/uwsgi.conf /data/flyapps/fir_ser/uwsgi.conf |
|
||||||
COPY Docker/flyapps-vhost.conf /etc/nginx/conf.d/flyapps-vhost.conf |
|
||||||
COPY Docker/app.hehelucky.cn.pem /data/flyapps/app.hehelucky.cn.pem |
|
||||||
COPY Docker/app.hehelucky.cn.key /data/flyapps/app.hehelucky.cn.key |
|
||||||
RUN chown -R www-data:www-data /data/flyapps/fir_ser/ |
|
||||||
|
|
||||||
|
|
||||||
RUN sed -i "/^daemonize/s@yes@no@" /etc/redis/redis.conf |
|
||||||
|
|
||||||
|
|
||||||
#RUN cd /data/flyapps/&& source py3/bin/activate && cd fir_ser/ && python manage.py makemigrations && python manage.py migrate |
|
||||||
COPY Docker/init.sh /data/flyapps/init.sh |
|
||||||
COPY Docker/end.sh /data/flyapps/end.sh |
|
||||||
EXPOSE 443 |
|
||||||
#ENTRYPOINT ["/data/flyapps/init.sh"] |
|
||||||
#ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf", "-n"] |
|
||||||
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf", "-n"] |
|
||||||
|
|
@ -0,0 +1,12 @@ |
|||||||
|
#!/bin/bash |
||||||
|
# |
||||||
|
# |
||||||
|
# shellcheck disable=SC2006 |
||||||
|
s_path=`pwd` |
||||||
|
|
||||||
|
#first build fir_client |
||||||
|
docker pull node:14.17.3 |
||||||
|
\cp -a build_client.sh fir_client/ |
||||||
|
docker run --rm -v "${s_path}"/fir_client:/fir_client -it node:14.17.3 sh /fir_client/build_client.sh |
||||||
|
|
||||||
|
cd "${s_path}"/fir_ser/ && docker build . -t flyapps |
@ -0,0 +1,7 @@ |
|||||||
|
#!/bin/bash |
||||||
|
# |
||||||
|
# |
||||||
|
|
||||||
|
cd /fir_client/ && yarn config set registry https://registry.npm.taobao.org && yarn install && yarn build |
||||||
|
|
||||||
|
|
@ -0,0 +1,41 @@ |
|||||||
|
FROM python:3.6.14-slim |
||||||
|
|
||||||
|
# Fixes some weird terminal issues such as broken clear / CTRL+L |
||||||
|
ARG PIP_MIRROR=https://mirrors.aliyun.com/pypi/simple |
||||||
|
|
||||||
|
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list \ |
||||||
|
&& sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list \ |
||||||
|
&& apt update |
||||||
|
|
||||||
|
RUN apt-get install g++ wget -y |
||||||
|
RUN apt-get install libssl-dev openssl libmariadb-dev -y |
||||||
|
RUN rm -rf /var/lib/apt/lists/* |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#COPY fir_client/dist /data/flyapps/fir_client |
||||||
|
|
||||||
|
#RUN cd /opt/ && wget https://github.com/nineaiyu/zsign/archive/refs/tags/v1.1.2.tar.gz |
||||||
|
COPY zsign-1.1.2.tar.gz /opt/zsign-1.1.2.tar.gz |
||||||
|
RUN cd /opt/ && tar xvf zsign-1.1.2.tar.gz && cd zsign-1.1.2/ && g++ *.cpp common/*.cpp -lcrypto -O3 -std=c++11 -o zsign && cp zsign /usr/bin/ |
||||||
|
# install pip |
||||||
|
COPY requirements.txt /opt/requirements.txt |
||||||
|
RUN cd /opt/ && pip install -U setuptools pip -i ${PIP_MIRROR} --ignore-installed && pip install --no-cache-dir -r requirements.txt -i ${PIP_MIRROR} && pip install --no-cache-dir uwsgi -i ${PIP_MIRROR} |
||||||
|
|
||||||
|
RUN rm -rf /var/cache/yum/ |
||||||
|
|
||||||
|
#COPY Docker/flyapps.conf /etc/supervisor/conf.d/flyapps.conf |
||||||
|
#COPY Docker/uwsgi.conf /data/flyapps/fir_ser/uwsgi.conf |
||||||
|
#COPY Docker/flyapps-vhost.conf /etc/nginx/conf.d/flyapps-vhost.conf |
||||||
|
#COPY Docker/app.hehelucky.cn.pem /data/flyapps/app.hehelucky.cn.pem |
||||||
|
#COPY Docker/app.hehelucky.cn.key /data/flyapps/app.hehelucky.cn.key |
||||||
|
|
||||||
|
WORKDIR /data/fir_ser/ |
||||||
|
RUN addgroup --system --gid 101 nginx \ |
||||||
|
&& adduser --system --disabled-login --ingroup nginx --no-create-home --home /nonexistent --gecos "nginx user" --shell /bin/false --uid 101 nginx |
||||||
|
|
||||||
|
#EXPOSE 443 |
||||||
|
#ENTRYPOINT ["./entrypoint.sh"] |
||||||
|
#ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf", "-n"] |
||||||
|
CMD ["python", "manage.py", "start", "all","-u","nginx","-usm","1"] |
||||||
|
|
@ -1,25 +0,0 @@ |
|||||||
#!/bin/bash |
|
||||||
# |
|
||||||
|
|
||||||
source /www/flyapps/py3/bin/activate && cd /www/flyapps/fir_ser/ |
|
||||||
chown www.www -R /www/flyapps/fir_ser/ |
|
||||||
stop(){ |
|
||||||
pgrep -f uwsgi |xargs -i kill {} |
|
||||||
sleep 1 |
|
||||||
pgrep -f celery |xargs -i kill {} |
|
||||||
} |
|
||||||
start(){ |
|
||||||
uwsgi --ini uwsgi.conf |
|
||||||
sleep 1 |
|
||||||
celery multi start 4 -A fir_ser -l INFO -c4 --pidfile=/var/run/celery/%n.pid --logfile=logs/%p.log |
|
||||||
sleep 1 |
|
||||||
nohup celery -A fir_ser beat --uid=1000 --pidfile=logs/beat.pid --scheduler django -l INFO --logfile=logs/beat.log & |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
restart(){ |
|
||||||
stop |
|
||||||
sleep 1 |
|
||||||
start |
|
||||||
} |
|
||||||
$@ |
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,41 @@ |
|||||||
|
#!/bin/bash |
||||||
|
# |
||||||
|
# |
||||||
|
|
||||||
|
# shellcheck disable=SC2006 |
||||||
|
s_path=`pwd` |
||||||
|
|
||||||
|
docker network create flyapps |
||||||
|
docker run --net flyapps --name redis -d redis:6.2.5 redis-server --requirepass nineven --bind '0.0.0.0' |
||||||
|
|
||||||
|
docker run --net flyapps --name mariadb -e MARIADB_ROOT_PASSWORD=root -v "${s_path}"/data/mysql:/var/lib/mysql -d mariadb:10.5 |
||||||
|
sleep 3 |
||||||
|
|
||||||
|
code=1 |
||||||
|
count=1 |
||||||
|
while [ ${code} -ne 0 ];do |
||||||
|
docker exec -it mariadb mysql -proot -e 'show databases;' |
||||||
|
code=$? |
||||||
|
((count+=1)) |
||||||
|
if [ "$count" -gt 30 ];then |
||||||
|
echo "30s away, but mysql service is not available" |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
sleep 2 |
||||||
|
echo "check whether mysql service is ready..." |
||||||
|
done |
||||||
|
|
||||||
|
docker exec -it mariadb mysql -proot -e 'create database flyapp default character set utf8 COLLATE utf8_general_ci;' |
||||||
|
docker exec -it mariadb mysql -proot -e "grant all on flyapp.* to flyuser@'%' identified by 'KGzKjZpWBp4R4RSa';" |
||||||
|
|
||||||
|
|
||||||
|
docker run --sysctl net.core.somaxconn=4096 --net flyapps \ |
||||||
|
-v "${s_path}"/fir_ser:/data/fir_ser \ |
||||||
|
-v "${s_path}"/data/files:/data/fir_ser/files \ |
||||||
|
-v "${s_path}"/data/supersign:/data/fir_ser/supersign \ |
||||||
|
--name flyapps -d flyapps |
||||||
|
|
||||||
|
docker run --net flyapps --name nginx -d -p 80:80 -p 443:443 \ |
||||||
|
-v "${s_path}"/fir_client/dist:/data/fir_client \ |
||||||
|
-v "${s_path}"/nginx.conf.d:/etc/nginx/conf.d nginx:1.21.3 |
||||||
|
|
Loading…
Reference in new issue