mirror of https://github.com/openspug/spug
U 更新文档
parent
e63942a8aa
commit
094d331bf0
|
@ -1,40 +0,0 @@
|
|||
# Copyright: (c) OpenSpug Organization. https://github.com/openspug/spug
|
||||
# Copyright: (c) <spug.dev@gmail.com>
|
||||
# Released under the AGPL-3.0 License.
|
||||
|
||||
FROM python:3.6.10-alpine3.11 as builder
|
||||
|
||||
RUN echo -e "http://mirrors.aliyun.com/alpine/v3.11/main\nhttp://mirrors.aliyun.com/alpine/v3.11/community" > /etc/apk/repositories
|
||||
RUN apk update && apk add --no-cache nodejs-npm git build-base openldap-dev supervisor
|
||||
RUN apk add --no-cache --virtual .build-deps openssl-dev gcc musl-dev python3-dev libffi-dev make \
|
||||
&& mkdir /etc/supervisor.d
|
||||
|
||||
RUN git clone https://github.com/openspug/spug.git --depth=1 /spug && cd /spug && git pull
|
||||
|
||||
RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && pip install --upgrade pip && pip install wheel && pip wheel -r /spug/spug_api/requirements.txt --wheel-dir=/pippacks/wheels \
|
||||
&& pip wheel gunicorn --wheel-dir=/pippacks/wheels \
|
||||
&& apk del .build-deps
|
||||
RUN cd /spug/spug_web/ && npm i --registry=https://registry.npm.taobao.org && npm run build
|
||||
|
||||
|
||||
|
||||
FROM python:3.6.10-alpine3.11
|
||||
ENV VERSION=2.2.0
|
||||
RUN echo -e "http://mirrors.aliyun.com/alpine/v3.11/main\nhttp://mirrors.aliyun.com/alpine/v3.11/community" > /etc/apk/repositories
|
||||
|
||||
# 这里也是可以优化的地方,有一些软件可以外置,可作为dockerfile参数项决定需不需要build进来
|
||||
RUN apk update && apk add --no-cache nginx mariadb supervisor redis bash git openssh-client openldap-dev
|
||||
|
||||
COPY --from=builder /pippacks /pippacks
|
||||
COPY --from=builder /spug /spug
|
||||
COPY --from=builder /spug/spug_web/build /var/www/build
|
||||
RUN cd /spug/spug_api/ && pip install --no-index --find-links=/pippacks/wheels -r requirements.txt && pip install gunicorn --no-index --find-links=/pippacks/wheels
|
||||
|
||||
RUN rm -rf /pippacks
|
||||
|
||||
ADD spug.ini /etc/supervisor.d/spug.ini
|
||||
ADD default.conf /etc/nginx/conf.d/default.conf
|
||||
ADD entrypoint.sh /entrypoint.sh
|
||||
|
||||
|
||||
ENTRYPOINT ["sh", "/entrypoint.sh"]
|
|
@ -1,26 +0,0 @@
|
|||
server {
|
||||
listen 80;
|
||||
server_name _; # 修改为自定义的访问域名
|
||||
root /var/www/build/;
|
||||
|
||||
location ^~ /api/ {
|
||||
rewrite ^/api(.*) $1 break;
|
||||
|
||||
proxy_pass http://127.0.0.1:9001;
|
||||
proxy_redirect off;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
|
||||
location ^~ /api/ws/ {
|
||||
rewrite ^/api(.*) $1 break;
|
||||
|
||||
proxy_pass http://127.0.0.1:9002;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
|
||||
|
||||
error_page 404 /index.html;
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Copyright: (c) OpenSpug Organization. https://github.com/openspug/spug
|
||||
# Copyright: (c) <spug.dev@gmail.com>
|
||||
# Released under the AGPL-3.0 License.
|
||||
|
||||
set -e
|
||||
|
||||
# init nginx
|
||||
if [ ! -d /run/nginx ]; then
|
||||
mkdir -p /run/nginx
|
||||
chown -R nginx.nginx /run/nginx
|
||||
fi
|
||||
|
||||
# init spug
|
||||
if [ ! -f /spug/spug_api/db.sqlite3 ]; then
|
||||
cd /spug/spug_api
|
||||
python manage.py initdb
|
||||
python manage.py useradd -u admin -p spug.dev -s -n 管理员
|
||||
fi
|
||||
|
||||
nginx
|
||||
supervisord -c /etc/supervisord.conf
|
|
@ -1,40 +0,0 @@
|
|||
; # Copyright: (c) OpenSpug Organization. https://github.com/openspug/spug
|
||||
; # Copyright: (c) <spug.dev@gmail.com>
|
||||
; # Released under the AGPL-3.0 License.
|
||||
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
|
||||
[program:redis]
|
||||
command = bash -c 'redis-server'
|
||||
autostart = true
|
||||
|
||||
[program:spug-api]
|
||||
command = bash /spug/spug_api/tools/start-api.sh
|
||||
autostart = true
|
||||
stdout_logfile = /spug/spug_api/logs/api.log
|
||||
redirect_stderr = true
|
||||
|
||||
[program:spug-ws]
|
||||
command = bash /spug/spug_api/tools/start-ws.sh
|
||||
autostart = true
|
||||
stdout_logfile = /spug/spug_api/logs/ws.log
|
||||
redirect_stderr = true
|
||||
|
||||
[program:spug-worker]
|
||||
command = bash /spug/spug_api/tools/start-worker.sh
|
||||
autostart = true
|
||||
stdout_logfile = /spug/spug_api/logs/worker.log
|
||||
redirect_stderr = true
|
||||
|
||||
[program:spug-monitor]
|
||||
command = bash /spug/spug_api/tools/start-monitor.sh
|
||||
autostart = true
|
||||
stdout_logfile = /spug/spug_api/logs/monitor.log
|
||||
redirect_stderr = true
|
||||
|
||||
[program:spug-scheduler]
|
||||
command = bash /spug/spug_api/tools/start-scheduler.sh
|
||||
autostart = true
|
||||
stdout_logfile = /spug/spug_api/logs/scheduler.log
|
||||
redirect_stderr = true
|
|
@ -0,0 +1,36 @@
|
|||
FROM centos:7.8.2003
|
||||
|
||||
ENV TZ=Asia/Shanghai
|
||||
RUN yum install -y epel-release https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm && yum install -y --setopt=tsflags=nodocs nginx redis mariadb-server mariadb-devel python36 python36-devel openldap-devel supervisor git gcc wget sshpass && yum -y clean all --enablerepo='*'
|
||||
|
||||
RUN pip3 install --upgrade pip -i https://pypi.doubanio.com/simple/
|
||||
RUN pip3 install --no-cache-dir -i https://pypi.doubanio.com/simple/ \
|
||||
gunicorn \
|
||||
mysqlclient \
|
||||
apscheduler==3.6.3 \
|
||||
asgiref==3.2.10 \
|
||||
Django==2.2.22 \
|
||||
channels==2.3.1 \
|
||||
channels_redis==2.4.1 \
|
||||
paramiko==2.7.2 \
|
||||
django-redis==4.10.0 \
|
||||
requests==2.22.0 \
|
||||
GitPython==3.0.8 \
|
||||
python-ldap==3.2.0 \
|
||||
openpyxl==3.0.3
|
||||
|
||||
ENV LANG=en_US.UTF-8
|
||||
RUN echo -e '\n# Source definitions\n. /etc/profile\n' >> /root/.bashrc
|
||||
RUN mkdir /data
|
||||
COPY init_spug /usr/bin/
|
||||
COPY nginx.conf /etc/nginx/
|
||||
COPY ssh_config /etc/ssh/
|
||||
COPY spug.ini /etc/supervisord.d/
|
||||
COPY my.cnf /etc/
|
||||
COPY redis.conf /etc/
|
||||
COPY entrypoint.sh /
|
||||
COPY spug.tar.gz /tmp/
|
||||
|
||||
VOLUME /data
|
||||
EXPOSE 80
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
|
@ -0,0 +1,53 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
set -e
|
||||
|
||||
if [ -e /root/.bashrc ]; then
|
||||
source /root/.bashrc
|
||||
fi
|
||||
|
||||
if [ ! -d /data/spug ]; then
|
||||
tar xf /tmp/spug.tar.gz -C /data/
|
||||
SECRET_KEY=$(< /dev/urandom tr -dc '!@#%^.a-zA-Z0-9' | head -c50)
|
||||
cat > /data/spug/spug_api/spug//overrides.py << EOF
|
||||
DEBUG = False
|
||||
ALLOWED_HOSTS = ['127.0.0.1']
|
||||
SECRET_KEY = '${SECRET_KEY}'
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ATOMIC_REQUESTS': True,
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': 'spug',
|
||||
'USER': 'spug',
|
||||
'PASSWORD': 'spug.dev',
|
||||
'HOST': 'localhost',
|
||||
'OPTIONS': {
|
||||
'unix_socket': '/var/lib/mysql/mysql.sock',
|
||||
'charset': 'utf8mb4',
|
||||
'sql_mode': 'STRICT_TRANS_TABLES',
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ ! -d /data/mysql ]; then
|
||||
mkdir -p /data/mysql
|
||||
mysql_install_db
|
||||
chown -R mysql.mysql /data/mysql
|
||||
|
||||
tfile=`mktemp`
|
||||
cat >> $tfile << EOF
|
||||
use mysql;
|
||||
flush privileges;
|
||||
create database spug character set utf8mb4 collate utf8mb4_unicode_ci;
|
||||
grant all on spug.* to spug@'localhost' identified by 'spug.dev';
|
||||
flush privileges;
|
||||
EOF
|
||||
|
||||
/usr/libexec/mysqld --user=mysql --bootstrap < $tfile
|
||||
rm -f $tfile
|
||||
fi
|
||||
|
||||
exec supervisord -c /etc/supervisord.conf
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
set -e
|
||||
set -u
|
||||
|
||||
python3 /data/spug/spug_api/manage.py updatedb
|
||||
python3 /data/spug/spug_api/manage.py user add -u $1 -p $2 -n 管理员 -s
|
|
@ -0,0 +1,9 @@
|
|||
[mysqld]
|
||||
datadir=/data/mysql
|
||||
log-error=/data/mysql/mysql.log
|
||||
pid-file=/data/mysql/mysql.pid
|
||||
socket=/var/lib/mysql/mysql.sock
|
||||
symbolic-links=0
|
||||
max_connections=1000
|
||||
|
||||
!includedir /etc/my.cnf.d
|
|
@ -0,0 +1,77 @@
|
|||
# For more information on configuration, see:
|
||||
# * Official English Documentation: http://nginx.org/en/docs/
|
||||
# * Official Russian Documentation: http://nginx.org/ru/docs/
|
||||
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
error_log /var/log/nginx/error.log;
|
||||
pid /run/nginx.pid;
|
||||
|
||||
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
|
||||
include /usr/share/nginx/modules/*.conf;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
server_tokens off;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# Load modular configuration files from the /etc/nginx/conf.d directory.
|
||||
# See http://nginx.org/en/docs/ngx_core_module.html#include
|
||||
# for more information.
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
server_name _;
|
||||
root /data/spug/spug_web/build;
|
||||
client_max_body_size 100m;
|
||||
add_header X-Frame-Options SAMEORIGIN always;
|
||||
|
||||
gzip on;
|
||||
gzip_min_length 1k;
|
||||
gzip_buffers 4 16k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_comp_level 7;
|
||||
gzip_types text/plain text/css text/javascript application/javascript application/json;
|
||||
gzip_disable "MSIE [1-6]\.";
|
||||
gzip_vary on;
|
||||
|
||||
location ^~ /api/ {
|
||||
rewrite ^/api(.*) $1 break;
|
||||
proxy_pass http://127.0.0.1:9001;
|
||||
proxy_read_timeout 180s;
|
||||
proxy_redirect off;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
location ^~ /api/ws/ {
|
||||
rewrite ^/api(.*) $1 break;
|
||||
proxy_pass http://127.0.0.1:9002;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri /index.html;
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,46 @@
|
|||
[supervisord]
|
||||
nodaemon=true
|
||||
|
||||
[program:nginx]
|
||||
command = nginx -g "daemon off;"
|
||||
autostart = true
|
||||
|
||||
[program:redis]
|
||||
command = redis-server /etc/redis.conf
|
||||
autostart = true
|
||||
|
||||
[program:mariadb]
|
||||
command = /usr/libexec/mysqld --user=mysql
|
||||
autostart = true
|
||||
|
||||
[program:spug-api]
|
||||
command = sh /data/spug/spug_api/tools/start-api.sh
|
||||
autostart = true
|
||||
stdout_logfile = /data/spug/spug_api/logs/api.log
|
||||
redirect_stderr = true
|
||||
|
||||
[program:spug-ws]
|
||||
command = sh /data/spug/spug_api/tools/start-ws.sh
|
||||
autostart = true
|
||||
stdout_logfile = /data/spug/spug_api/logs/ws.log
|
||||
redirect_stderr = true
|
||||
|
||||
[program:spug-worker]
|
||||
command = sh /data/spug/spug_api/tools/start-worker.sh
|
||||
autostart = true
|
||||
stdout_logfile = /data/spug/spug_api/logs/worker.log
|
||||
redirect_stderr = true
|
||||
|
||||
[program:spug-monitor]
|
||||
command = sh /data/spug/spug_api/tools/start-monitor.sh
|
||||
autostart = true
|
||||
startsecs = 3
|
||||
stdout_logfile = /data/spug/spug_api/logs/monitor.log
|
||||
redirect_stderr = true
|
||||
|
||||
[program:spug-scheduler]
|
||||
command = sh /data/spug/spug_api/tools/start-scheduler.sh
|
||||
autostart = true
|
||||
startsecs = 3
|
||||
stdout_logfile = /data/spug/spug_api/logs/scheduler.log
|
||||
redirect_stderr = true
|
|
@ -0,0 +1,2 @@
|
|||
Host *
|
||||
StrictHostKeyChecking no
|
Loading…
Reference in New Issue