commit
8a818d78d3
@ -0,0 +1,10 @@
|
|||||||
|
FROM python:3
|
||||||
|
ENV PYTHONUNBUFFERED 1
|
||||||
|
WORKDIR /code/DjangoBlog/
|
||||||
|
RUN apt-get install default-libmysqlclient-dev -y && \
|
||||||
|
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||||
|
ADD requirements.txt requirements.txt
|
||||||
|
RUN pip install -Ur requirements.txt -i https://mirrors.aliyun.com/pypi/simple && \
|
||||||
|
pip install gunicorn[gevent] -i https://mirrors.aliyun.com/pypi/simple
|
||||||
|
ADD . .
|
||||||
|
#ENTRYPOINT ["/code/DjangoBlog/bin/docker_start.sh"]
|
||||||
@ -1,24 +0,0 @@
|
|||||||
server {
|
|
||||||
server_name blog.lylinux.org;
|
|
||||||
root /var/www/DjangoBlog/;
|
|
||||||
listen 80;
|
|
||||||
keepalive_timeout 70;
|
|
||||||
|
|
||||||
location /static/ {
|
|
||||||
expires max;
|
|
||||||
alias /var/www/DjangoBlog/collectedstatic/;
|
|
||||||
}
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header Host $http_host;
|
|
||||||
proxy_set_header X-NginX-Proxy true;
|
|
||||||
proxy_redirect off;
|
|
||||||
if (!-f $request_filename) {
|
|
||||||
proxy_pass http://127.0.0.1:8000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
user nginx;
|
||||||
|
worker_processes auto;
|
||||||
|
|
||||||
|
error_log /var/log/nginx/error.log notice;
|
||||||
|
pid /var/run/nginx.pid;
|
||||||
|
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
http {
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
keepalive_timeout 65;
|
||||||
|
|
||||||
|
#gzip on;
|
||||||
|
|
||||||
|
server {
|
||||||
|
root /code/DjangoBlog/collectedstatic/;
|
||||||
|
listen 80;
|
||||||
|
keepalive_timeout 70;
|
||||||
|
location /static/ {
|
||||||
|
expires max;
|
||||||
|
alias /code/DjangoBlog/collectedstatic/;
|
||||||
|
}
|
||||||
|
location / {
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_set_header X-NginX-Proxy true;
|
||||||
|
proxy_redirect off;
|
||||||
|
if (!-f $request_filename) {
|
||||||
|
proxy_pass http://djangoblog:8000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: mysql:latest
|
||||||
|
restart: always
|
||||||
|
command:
|
||||||
|
- mysqld
|
||||||
|
- --max_connections=3000
|
||||||
|
- --wait_timeout=600
|
||||||
|
- --interactive_timeout=600
|
||||||
|
- --thread_cache_size=50
|
||||||
|
- --default-authentication-plugin=mysql_native_password
|
||||||
|
- --character-set-server=utf8
|
||||||
|
- --collation-server=utf8_general_ci
|
||||||
|
environment:
|
||||||
|
- MYSQL_DATABASE=djangoblog
|
||||||
|
- MYSQL_ROOT_PASSWORD=DjAnGoBlOg!2!Q@W#E
|
||||||
|
ports:
|
||||||
|
- 3306:3306
|
||||||
|
volumes:
|
||||||
|
- ./bin/datas/mysql/:/var/lib/mysql
|
||||||
|
depends_on:
|
||||||
|
- memcached
|
||||||
|
container_name: db
|
||||||
|
|
||||||
|
djangoblog:
|
||||||
|
build: .
|
||||||
|
restart: always
|
||||||
|
command: bash -c 'sh /code/DjangoBlog/bin/docker_start.sh'
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
volumes:
|
||||||
|
- ./collectedstatic:/code/DjangoBlog/collectedstatic
|
||||||
|
environment:
|
||||||
|
- DJANGO_MYSQL_DATABASE=djangoblog
|
||||||
|
- DJANGO_MYSQL_USER=root
|
||||||
|
- DJANGO_MYSQL_PASSWORD=DjAnGoBlOg!2!Q@W#E
|
||||||
|
- DJANGO_MYSQL_HOST=db
|
||||||
|
- DJANGO_MYSQL_PORT=3306
|
||||||
|
- DJANGO_MEMCACHED_LOCATION=memcached:11211
|
||||||
|
links:
|
||||||
|
- db
|
||||||
|
- memcached
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
container_name: djangoblog
|
||||||
|
nginx:
|
||||||
|
restart: always
|
||||||
|
image: nginx:latest
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
- "443:443"
|
||||||
|
volumes:
|
||||||
|
- ./bin/nginx.conf:/etc/nginx/nginx.conf
|
||||||
|
- ./collectedstatic:/code/DjangoBlog/collectedstatic
|
||||||
|
links:
|
||||||
|
- djangoblog:djangoblog
|
||||||
|
container_name: nginx
|
||||||
|
|
||||||
|
memcached:
|
||||||
|
restart: always
|
||||||
|
image: memcached:latest
|
||||||
|
container_name: memcached
|
||||||
|
ports:
|
||||||
|
- "11211:11211"
|
||||||
@ -1,69 +0,0 @@
|
|||||||
FROM alpine:3.11
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY ./requirements.txt .
|
|
||||||
|
|
||||||
RUN echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.11/main" > /etc/apk/repositories \
|
|
||||||
&& echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.11/community" >> /etc/apk/repositories \
|
|
||||||
&& echo "https://mirror.tuna.tsinghua.edu.cn/alpine/edge/testing" >> /etc/apk/repositories
|
|
||||||
|
|
||||||
RUN apk --update --no-cache add python3 py3-pip py-gunicorn nginx mariadb-connector-c \
|
|
||||||
&& apk --update --no-cache add --virtual .build-deps \
|
|
||||||
tzdata \
|
|
||||||
# mysqlclient dependencies
|
|
||||||
python3-dev \
|
|
||||||
mariadb-connector-c-dev \
|
|
||||||
gcc \
|
|
||||||
musl-dev \
|
|
||||||
# Pillow dependencies
|
|
||||||
jpeg-dev \
|
|
||||||
zlib-dev \
|
|
||||||
freetype-dev \
|
|
||||||
lcms2-dev \
|
|
||||||
openjpeg-dev \
|
|
||||||
tiff-dev \
|
|
||||||
tk-dev \
|
|
||||||
tcl-dev \
|
|
||||||
harfbuzz-dev \
|
|
||||||
fribidi-dev \
|
|
||||||
&& pip3 install --upgrade pip \
|
|
||||||
&& mkdir -p /run/nginx \
|
|
||||||
&& pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple \
|
|
||||||
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
|
||||||
&& echo "Asia/Shanghai" > /etc/timezone \
|
|
||||||
&& apk del .build-deps
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
RUN python3 manage.py collectstatic --noinput \
|
|
||||||
&& python3 manage.py compress --force
|
|
||||||
|
|
||||||
COPY ./docker-support/nginx.conf /etc/nginx/conf.d/default.conf
|
|
||||||
|
|
||||||
ENV DJANGO_DEBUG False
|
|
||||||
ENV DJANGO_SECRET_KEY DJANGO_BLOG_CHANGE_ME
|
|
||||||
|
|
||||||
ENV DJANGO_MYSQL_DATABASE djangoblog
|
|
||||||
ENV DJANGO_MYSQL_USER root
|
|
||||||
ENV DJANGO_MYSQL_PASSWORD djangoblog_123
|
|
||||||
ENV DJANGO_MYSQL_HOST 127.0.0.1
|
|
||||||
ENV DJANGO_MYSQL_PORT 3306
|
|
||||||
|
|
||||||
ENV DJANGO_MEMCACHED_ENABLE True
|
|
||||||
ENV DJANGO_MEMCACHED_LOCATION 127.0.0.1:11211
|
|
||||||
|
|
||||||
ENV DJANGO_BAIDU_NOTIFY_URL http://data.zz.baidu.com/urls?site=https://www.example.org&token=CHANGE_ME
|
|
||||||
|
|
||||||
ENV DJANGO_EMAIL_TLS False
|
|
||||||
ENV DJANGO_EMAIL_SSL True
|
|
||||||
ENV DJANGO_EMAIL_HOST smtp.example.org
|
|
||||||
ENV DJANGO_EMAIL_PORT 465
|
|
||||||
ENV DJANGO_EMAIL_USER SMTP_USER_CHANGE_ME
|
|
||||||
ENV DJANGO_EMAIL_PASSWORD SMTP_PASSWORD_CHANGE_ME
|
|
||||||
|
|
||||||
ENV DJANGO_ADMIN_EMAIL admin@example.org
|
|
||||||
|
|
||||||
ENV DJANGO_WXADMIN_PASSWORD DJANGO_BLOG_CHANGE_ME
|
|
||||||
ENV DJANGO_WEROBOT_TOKEN DJANGO_BLOG_CHANGE_ME
|
|
||||||
|
|
||||||
EXPOSE 80
|
|
||||||
ENTRYPOINT ["sh","./docker-support/entrypoint.sh"]
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
version: '3'
|
|
||||||
services:
|
|
||||||
mysql:
|
|
||||||
image: mysql:5.7
|
|
||||||
restart: always
|
|
||||||
environment:
|
|
||||||
MYSQL_ROOT_PASSWORD: djangoblog_123
|
|
||||||
MYSQL_DATABASE: djangoblog
|
|
||||||
volumes:
|
|
||||||
- mysql:/var/lib/mysql
|
|
||||||
ports:
|
|
||||||
- '3306:3306'
|
|
||||||
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
|
||||||
memcached:
|
|
||||||
image: memcached:1.6-alpine
|
|
||||||
restart: always
|
|
||||||
ports:
|
|
||||||
- '11211:11211'
|
|
||||||
command: memcached -m 64
|
|
||||||
volumes:
|
|
||||||
mysql: ~
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
cd /app
|
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
|
||||||
nginx
|
|
||||||
gunicorn DjangoBlog.wsgi:application \
|
|
||||||
--name djangoblog \
|
|
||||||
--user root \
|
|
||||||
--group root \
|
|
||||||
--bind 127.0.0.1:8000 \
|
|
||||||
--log-level=debug \
|
|
||||||
--log-file=- \
|
|
||||||
--workers $(grep -c ^processor /proc/cpuinfo) \
|
|
||||||
--worker-class gevent
|
|
||||||
else
|
|
||||||
python3 ./manage.py $1
|
|
||||||
fi
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
server {
|
|
||||||
root /app/;
|
|
||||||
listen 80;
|
|
||||||
keepalive_timeout 70;
|
|
||||||
|
|
||||||
location /static/ {
|
|
||||||
expires max;
|
|
||||||
alias /app/collectedstatic/;
|
|
||||||
}
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header Host $http_host;
|
|
||||||
proxy_set_header X-NginX-Proxy true;
|
|
||||||
proxy_redirect off;
|
|
||||||
if (!-f $request_filename) {
|
|
||||||
proxy_pass http://127.0.0.1:8000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in new issue