Skip to content
This repository was archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
docker init
Browse files Browse the repository at this point in the history
  • Loading branch information
ghosx committed Apr 21, 2020
0 parents commit 006f72f
Show file tree
Hide file tree
Showing 162 changed files with 27,905 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/__pycache__
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
README.md
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
venv/
TiebaProject/__pycache__/*
SignIn/__pycache__/
db.sqlite3
.github/
*.pyc
.vscode/
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 贴吧云签到云回复Docker版

## 项目简介

独立开发的基于Django的贴吧云签到云回网站

作者维护的地址:http://sign.heeeepin.com/

## 安装

1. 安装docker

`curl -sSL https://get.docker.com | sh`

2. 安装docker-compose

`curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.5/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose`

3. 下载本项目并启动

``

## 讨论群

TG: https://t.me/tiebasign

qq群: 818794879

## LICENSE

[WTFPL – Do What the Fuck You Want to Public License](http://www.wtfpl.net/about/)
45 changes: 45 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: '3.4'

services:
db:
build:
context: ./mysql
dockerfile: Dockerfile
volumes:
- /home/tieba/mysql/data:/var/lib/mysql
- /home/tieba/mysql/log:/var/log/mysql
restart: always
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --init-connect='SET NAMES utf8mb4;'
expose:
- "3306"
environment:
- MYSQL_DATABASE=tiebaproject
- MYSQL_ROOT_PASSWORD=1BQnsRlwhOE5qfuY
web:
build:
context: ./web
dockerfile: Dockerfile
volumes:
- /home/tieba/django:/var/log/tieba
command: bash start.sh
ports:
- "8000:8000"
links:
- db
depends_on:
- db
restart: always
nginx:
build: ./nginx
ports:
- "80:80"
volumes:
- ./web/static:/usr/share/nginx/html/static
- /home/tieba/nginx:/home/logs
links:
- web
depends_on:
- web
restart: always


5 changes: 5 additions & 0 deletions mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 使用docker仓库中的基础nginx镜像
FROM mysql:5.6
# 使用自定义的mysqld.cnf
RUN rm /etc/mysql/mysql.conf.d/mysqld.cnf
ADD mysqld.cnf /etc/mysql/mysql.conf.d/
35 changes: 35 additions & 0 deletions mysql/mysqld.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.
#
# This program is also distributed with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation. The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have included with MySQL.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#
# The MySQL Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
log-error = /var/log/mysql/error.log
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
12 changes: 12 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 使用docker仓库中的基础nginx镜像
FROM nginx
# 开放端口
EXPOSE 80 8000
# 删除nginx原有配置文件
RUN rm /etc/nginx/conf.d/default.conf
# 将自己写的配置文件添加到容器
ADD nginx.conf /etc/nginx/conf.d/
# 创建web应用的静态文件存储
RUN mkdir -p /usr/share/nginx/html/static
# 创建存放日志的文件夹
RUN mkdir -p /home/logs
20 changes: 20 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
server {
listen 80;
server_name localhost;
charset utf-8;

error_log /home/logs/nginx_error.log;
access_log /home/logs/nginx_access.log;

location /static {
alias /usr/share/nginx/html/static;
}

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://web:8000;
}

}
23 changes: 23 additions & 0 deletions web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.6

EXPOSE 8000

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE 1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED 1

# change the pip source
ADD pip.conf /etc/pip.conf

# Install pip requirements
ADD requirements.txt .
RUN python -m pip install -r requirements.txt

RUN mkdir app
WORKDIR /app
ADD . /app


13 changes: 13 additions & 0 deletions web/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <[email protected]>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.
4 changes: 4 additions & 0 deletions web/SignIn/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.apps import AppConfig

# 要修改名称的app,我的是common;
default_app_config = 'SignIn.apps.SignConfig'
75 changes: 75 additions & 0 deletions web/SignIn/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
from django.contrib import admin
from .models import User, Sign, SignLog, SignTotal


class UserAdmin(admin.ModelAdmin):
list_display = ('username', 'email', 'email_notice', 'token',
'共关注', '已签到', '未签到', '是否有效用户', 'created_time', 'update_time')
list_editable = ('email', 'email_notice')
search_fields = ('username', 'email')
list_display_links = ('username',)
list_per_page = 30
date_hierarchy = 'created_time'
actions = ('make_new_user',)

def make_new_user(self, request, queryset): # 定义动作
rows_updated = queryset.update(flag=0)
if rows_updated == 1:
message_bit = "one user changed"
else:
message_bit = "%s users changed" % rows_updated
self.message_user(request, "%s successfully ." % message_bit)

make_new_user.short_description = "刷新关注的贴吧并签到" # 重写动作显示名称

def get_queryset(self, request):
qs = super().get_queryset(request)
if request.user.is_superuser:
return qs
return qs.filter(username=request.user.username)


class SignAdmin(admin.ModelAdmin):
list_display = ('id', 'name', 'fid', 'is_sign',
'retry_time', 'status', 'user')
search_fields = ('id', 'name', 'fid', 'status', 'user__username')
actions = ['re_sign', ]

def re_sign(self, request, queryset): # 定义动作
rows_updated = queryset.update(is_sign=0, retry_time=0, status="")
if rows_updated == 1:
message_bit = "one tieba resign"
else:
message_bit = "%s tieba resign" % rows_updated
self.message_user(request, "%s successfully ." % message_bit)

re_sign.short_description = "重新签到" # 重写动作显示名称

def get_queryset(self, request):
qs = super().get_queryset(request)
if request.user.is_superuser:
return qs
u = User.objects.get(username=request.user.username)
return qs.filter(user=u)


class SignLogAdmin(admin.ModelAdmin):
list_display = ('id', 'name', 'update_time', 'ret_log', 'user')
search_fields = ('id', 'name', 'user__username')

def get_queryset(self, request):
qs = super().get_queryset(request)
if request.user.is_superuser:
return qs
u = User.objects.get(username=request.user.username)
return qs.filter(user=u)


class SignTotalAdmin(admin.ModelAdmin):
list_display = ('id', 'number')


admin.site.register(User, UserAdmin)
admin.site.register(Sign, SignAdmin)
admin.site.register(SignLog, SignLogAdmin)
admin.site.register(SignTotal, SignTotalAdmin)
6 changes: 6 additions & 0 deletions web/SignIn/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class SignConfig(AppConfig):
name = 'SignIn'
verbose_name = '贴吧签到'
Binary file added web/SignIn/migrations/.BEGIN.swp
Binary file not shown.
Loading

0 comments on commit 006f72f

Please sign in to comment.