Skip to content

Commit

Permalink
Merge pull request #33 from Chengyumeng/develop
Browse files Browse the repository at this point in the history
优化云环境下开发和部署方案
  • Loading branch information
chengyumeng committed Apr 5, 2018
2 parents 6c6c476 + cf8f9e0 commit 94504c1
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,4 @@ ENV/
# 开发者自定义
.DS_Store
.idea/
hack/_dev
15 changes: 7 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
.PHONY: docker-build composer build
.PHONY: docker-build docker-run build

USER := $(shell id -u)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
VERSION := $(shell git describe --always --tags | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")

docker-build:
docker build -t spider163:$(VERSION) -f hack/spider/Dockerfile .
docker build -t mysql163:$(VERSION) -f hack/mysql/Dockerfile .
docker build -t chengtian/spider163:$(VERSION) -f hack/spider/Dockerfile .

composer:
docker-compose -p "spider163-$(BRANCH)-$(USER)" up
docker-run:
cd hack && docker-compose up

build:
pip install -r requirements.txt
python setup.py install
python setup.py clean
pip install -e .


6 changes: 3 additions & 3 deletions doc/2018.Q1.TODO.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#### 主要方向
* 文件类下载(mp3等)
* 文件类下载(mp3等)[完成下载mp3]
* 搜索框架(基于ES,可能衍生子项目)
* 最小安装的探索(MySQL依赖太复杂)
* 最小安装的探索(MySQL依赖太复杂)[生成word]
* 迁移到python3 [验证性完成]
* k8s下部署(提供官方镜像)
* 支持生成PDF
* 支持生成PDF[完成支持word,pdf可手动生成]

#### 优化
* web ui
Expand Down
17 changes: 14 additions & 3 deletions docker-compose.yaml → hack/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
version: '2'
services:
mysql163:
image: mysql163
image: mysql:5.6.36
container_name: mysql163
networks:
- default
environment:
MYSQL_DATABASE: "spider163"
MYSQL_ROOT_PASSWORD: "a1b2c3d4e"
volumes:
- ./_dev/mysql:/var/lib/mysql:z
ports:
- "3336:3306"
expose:
- "3306"
spider163:
image: spider163
image: chengtian/spider163:2.7.5
container_name: spider163
volumes:
- ../:/root/code
ports:
# 将容器端口与宿主机绑定, 以便外部访问
- "1163:1163"
- "1630:1630"
expose:
- "1630"
links:
- mysql163:mysql163.localhost
depends_on:
- mysql163
networks:
- default
networks:
Expand Down
2 changes: 0 additions & 2 deletions hack/mysql/Dockerfile

This file was deleted.

6 changes: 3 additions & 3 deletions hack/spider/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM python:2.7
FROM python:3.6
RUN mkdir /root/code & mkdir /root/spider163
WORKDIR /root/code
ADD ./ /root/code/
ADD hack/spider/spider163.conf /root/spider163/spider163.conf
RUN pip install -i http://mirrors.aliyun.com/pypi/simple --trusted-host=mirrors.aliyun.com -r requirements.txt && python setup.py install && spider163 --help
CMD spider163 webserver
RUN pip install -e . -i http://mirrors.aliyun.com/pypi/simple --trusted-host=mirrors.aliyun.com && spider163 --help
ENTRYPOINT spider163 webserver


3 changes: 2 additions & 1 deletion hack/spider/spider163.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[core]
db=mysql://root:[email protected]/spider?charset=utf8mb4
db=mysql://root:[email protected]/spider163?charset=utf8mb4
port=1630
2 changes: 1 addition & 1 deletion spider163/spider/music.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def views_capture(self,source=None):
else:
if source.startswith("曲风:") is False:
source = "曲风:" + source
urls = self.session.query(pysql.Playlist163).filter(pysql.Playlist163.done == 'N',pysql.Playlist163.dsc==source).order(pysql.Playlist163.id).limit(1)
urls = self.session.query(pysql.Playlist163).filter(pysql.Playlist163.done == 'N',pysql.Playlist163.dsc==source).order_by(pysql.Playlist163.id).limit(1)
for url in urls:
print("正在抓取歌单《{}》的歌曲……".format(tools.encode(url.title)))
songs = self.view_capture(url.link)
Expand Down

0 comments on commit 94504c1

Please sign in to comment.