mirror of https://github.com/openspug/spug
A 添加Dockerfile
parent
7208ba803e
commit
8430639b6f
|
@ -0,0 +1,28 @@
|
|||
# Copyright: (c) OpenSpug Organization. https://github.com/openspug/spug
|
||||
# Copyright: (c) <spug.dev@gmail.com>
|
||||
# Released under the MIT License.
|
||||
|
||||
FROM python:3.6.10-alpine3.11
|
||||
|
||||
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 nginx mariadb nodejs-npm git build-base openldap-dev supervisor redis bash
|
||||
RUN apk add --no-cache --virtual .build-deps openssl-dev gcc musl-dev python3-dev libffi-dev openssl-dev make \
|
||||
&& mkdir /etc/supervisor.d
|
||||
|
||||
|
||||
ENV VERSION=2.2.0
|
||||
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 --no-cache-dir -r /spug/spug_api/requirements.txt \
|
||||
&& pip install --no-cache-dir gunicorn \
|
||||
&& apk del .build-deps
|
||||
|
||||
RUN cd /spug/spug_web/ && npm i --registry=https://registry.npm.taobao.org && npm run build \
|
||||
&& mv /spug/spug_web/build /var/www/
|
||||
|
||||
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"]
|
|
@ -0,0 +1,26 @@
|
|||
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;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
# Copyright: (c) OpenSpug Organization. https://github.com/openspug/spug
|
||||
# Copyright: (c) <spug.dev@gmail.com>
|
||||
# Released under the MIT 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
|
|
@ -0,0 +1,37 @@
|
|||
; # Copyright: (c) OpenSpug Organization. https://github.com/openspug/spug
|
||||
; # Copyright: (c) <spug.dev@gmail.com>
|
||||
; # Released under the MIT License.
|
||||
|
||||
[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
|
Loading…
Reference in New Issue