添加docker支持
This commit is contained in:
parent
fbc0c1e4f1
commit
1158907a6f
49
Dockerfile
Normal file
49
Dockerfile
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
FROM node:15-buster
|
||||||
|
|
||||||
|
RUN apt update && apt install software-properties-common -y && apt clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CC86BB64
|
||||||
|
|
||||||
|
RUN add-apt-repository "deb http://ppa.launchpad.net/rmescandon/yq/ubuntu focal main" -y
|
||||||
|
|
||||||
|
RUN apt update && apt install sqlite python git moreutils yq -y && apt clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /tmp
|
||||||
|
|
||||||
|
ADD https://golang.org/dl/go1.15.5.linux-amd64.tar.gz /tmp/go1.15.5.linux-amd64.tar.gz
|
||||||
|
|
||||||
|
RUN tar -C /usr/local -xzf go1.15.5.linux-amd64.tar.gz && echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile
|
||||||
|
|
||||||
|
WORKDIR /opt
|
||||||
|
|
||||||
|
RUN git clone https://github.com/kallydev/privacy
|
||||||
|
|
||||||
|
WORKDIR /opt/privacy/server
|
||||||
|
|
||||||
|
RUN export PATH=$PATH:/usr/local/go/bin && go build -o app main/main.go
|
||||||
|
|
||||||
|
WORKDIR /opt/privacy/website
|
||||||
|
|
||||||
|
RUN yarn install && yarn build
|
||||||
|
|
||||||
|
ADD entrypoint.sh /opt/privacy/entrypoint.sh
|
||||||
|
|
||||||
|
RUN chmod +x /opt/privacy/entrypoint.sh
|
||||||
|
|
||||||
|
VOLUME [ "/opt/privacy/database", "/opt/privacy/source" ]
|
||||||
|
|
||||||
|
ENV qq=true
|
||||||
|
ENV jd=true
|
||||||
|
ENV sf=false
|
||||||
|
ENV wb=false
|
||||||
|
|
||||||
|
ENV host=0.0.0.0
|
||||||
|
ENV port=80
|
||||||
|
|
||||||
|
ENV mask=true
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
WORKDIR /opt/privacy
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/opt/privacy/entrypoint.sh" ]
|
10
README.md
10
README.md
@ -25,7 +25,7 @@
|
|||||||
在项目文件夹根目录下创建并进入 database 文件夹,创建数据库。
|
在项目文件夹根目录下创建并进入 database 文件夹,创建数据库。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mkdir database & cd database
|
mkdir database && cd database
|
||||||
sqlite3 database.db
|
sqlite3 database.db
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -65,11 +65,11 @@ CREATE TABLE sf
|
|||||||
|
|
||||||
2. 导入 QQ 库
|
2. 导入 QQ 库
|
||||||
|
|
||||||
把 `6.9更新总库.txt` 文件放到项目根目录下,然后执行 `python scripts/qq.py`。
|
把 `6.9更新总库.txt` 文件放到项目根目录下的`source`目录,然后执行 `python scripts/qq.py`。
|
||||||
|
|
||||||
3. 导入京东库
|
3. 导入京东库
|
||||||
|
|
||||||
把 `www_jd_com_12g.txt` 文件放到项目根目录下,然后执行 `python scripts/jd.py`。
|
把 `www_jd_com_12g.txt` 文件放到项目根目录下的`source`目录,然后执行 `python scripts/jd.py`。
|
||||||
|
|
||||||
- 创建索引
|
- 创建索引
|
||||||
|
|
||||||
@ -100,8 +100,8 @@ npm install -g yarn
|
|||||||
2. 安装 Golang
|
2. 安装 Golang
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt install -y snap
|
sudo apt install -y snapd
|
||||||
sudo snap install golang --classic
|
sudo snap install go --classic
|
||||||
```
|
```
|
||||||
|
|
||||||
3. 下载源代码
|
3. 下载源代码
|
||||||
|
20
docker-compose.yaml
Normal file
20
docker-compose.yaml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
version: "3.3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
server:
|
||||||
|
build: .
|
||||||
|
image: privacy
|
||||||
|
network_mode: bridge
|
||||||
|
volumes:
|
||||||
|
- ./database:/opt/privacy/database
|
||||||
|
- ./source:/opt/privacy/source
|
||||||
|
environment:
|
||||||
|
- qq=true
|
||||||
|
- jd=true
|
||||||
|
- sf=false
|
||||||
|
- wb=false
|
||||||
|
- host=0.0.0.0
|
||||||
|
- port=80
|
||||||
|
- mask=true
|
||||||
|
ports:
|
||||||
|
- 80:80
|
27
entrypoint.sh
Normal file
27
entrypoint.sh
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 设置环境变量
|
||||||
|
yq w config.yaml database.tables.qq $qq | yq w - database.tables.jd $jd | yq w - database.tables.sf $sf | yq w - database.tables.wb $wb | yq w - http.host $host | yq w - http.port $port | yq w - mask $mask | sponge config.yaml
|
||||||
|
|
||||||
|
# 如果不存在数据库,创建
|
||||||
|
if [[ ! -f database/database.db ]];then
|
||||||
|
mkdir -p database && sqlite3 database/database.db < scripts/database/create_database.sql
|
||||||
|
if [[ -f source/6.9更新总库.txt ]];then python scripts/qq.py;fi
|
||||||
|
if [[ -f source/www_jd_com_12g.txt ]];then python scripts/jd.py;fi
|
||||||
|
sqlite3 database/database.db < scripts/database/create_index.sql
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 如果需要重新导入qq
|
||||||
|
if [[ -f database/.reimportqq ]];then
|
||||||
|
if [[ -f source/6.9更新总库.txt ]];then python scripts/qq.py;fi
|
||||||
|
rm database/.reimportqq
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 如果需要重新导入jd
|
||||||
|
if [[ -f database/.reimportjd ]];then
|
||||||
|
if [[ -f source/www_jd_com_12g.txt ]];then python scripts/jd.py;fi
|
||||||
|
rm database/.reimportjd
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 启动服务器
|
||||||
|
cd server && ./app
|
@ -107,5 +107,5 @@ class Converter(object):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
converter = Converter("database/database.db", "www_jd_com_12g.txt")
|
converter = Converter("database/database.db", "source/www_jd_com_12g.txt")
|
||||||
converter.start()
|
converter.start()
|
||||||
|
@ -99,5 +99,5 @@ class Scanner:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
scanner = Scanner("database/database.db", "6.9更新总库.txt")
|
scanner = Scanner("database/database.db", "source/6.9更新总库.txt")
|
||||||
scanner.start()
|
scanner.start()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user