完善docker

This commit is contained in:
John Smith 2019-07-07 23:01:42 +08:00
parent b95ef95cfd
commit 1eedee1119
3 changed files with 55 additions and 39 deletions

16
.dockerignore Normal file
View File

@ -0,0 +1,16 @@
# compiled output
**/__pycache__/
build/
**/dist/
# dependencies
**/node_modules/
# IDEs and editors
/.idea
# misc
**/.git*
*.spec
screenshots/
README.md

View File

@ -1,25 +1,33 @@
FROM ubuntu:bionic
# 运行时
FROM python:3.6.8-slim-stretch
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak \
&& echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ stretch main contrib non-free">>/etc/apt/sources.list \
&& echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-updates main contrib non-free">>/etc/apt/sources.list \
&& echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-backports main contrib non-free">>/etc/apt/sources.list \
&& echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian-security stretch/updates main contrib non-free">>/etc/apt/sources.list \
&& apt-get update \
&& apt-get install -y wget tar xz-utils
RUN wget https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.xz \
&& tar -xvf node-v10.16.0-linux-x64.tar.xz \
&& rm node-v10.16.0-linux-x64.tar.xz \
&& ln -s /node-v10.16.0-linux-x64/bin/node /usr/local/bin/node \
&& ln -s /node-v10.16.0-linux-x64/bin/npm /usr/local/bin/npm
COPY . ./blivechat
# 后端依赖
COPY requirements.txt /blivechat/
RUN pip3 install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple -r /blivechat/requirements.txt
RUN apt update && apt install python3 wget git curl tar python3-distutils -y
# 前端依赖
WORKDIR /blivechat/frontend
COPY frontend/package*.json ./
RUN npm i --registry=https://registry.npm.taobao.org
RUN wget -q https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.xz && \
tar xf node-v10.16.0-linux-x64.tar.xz && \
ln -s /node-v10.16.0-linux-x64/bin/node /usr/bin/node && \
ln -s /node-v10.16.0-linux-x64/bin/npm /usr/bin/npm
# 编译
COPY . /blivechat
RUN npm run build
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3 get-pip.py
RUN cd /blivechat/ && \
pip install -r requirements.txt && \
git reset --hard 2d86449 && \
git clone https://github.com/xfgryujk/blivedm.git && \
cd blivedm && git reset --hard 003d89e
RUN cd /blivechat/frontend && npm i && npm run build
CMD /usr/bin/python3 /blivechat/main.py --host 0.0.0.0 --port 80
EXPOSE 80/tcp
EXPOSE 80/udp
# 运行
WORKDIR /blivechat
EXPOSE 80
ENTRYPOINT ["python3", "main.py"]
CMD ["--host", "0.0.0.0", "--port", "80"]

View File

@ -21,40 +21,32 @@
```bat
blivechat.exe --host 127.0.0.1 --port 80
```
3. 用浏览器打开[http://localhost](http://localhost)输入房间ID进入房间复制房间URL
3. 用浏览器打开[http://localhost](http://localhost)输入房间ID保存配置,进入房间复制房间URL
4. 可选用样式生成器生成样式复制CSS
5. 在OBS中添加浏览器源输入URL和自定义CSS或者可以在首页的样式设置里输入CSS
### 源代码版
1. 编译前端需要安装NPM
1. 编译前端需要安装Node.js和npm
```sh
cd frontend
npm i
npm run build
```
2. 运行服务器:
2. 运行服务器需要Python3.6以上版本)
```sh
pip3 install -r requirements.txt
python3 main.py
```
或者可以指定host和端口号
```sh
python3 main.py --host 127.0.0.1 --port 80
```
3. 用浏览器打开[http://localhost](http://localhost)输入房间ID进入房间复制房间URL
3. 用浏览器打开[http://localhost](http://localhost)输入房间ID保存配置,进入房间复制房间URL
4. 可选用样式生成器生成样式复制CSS
5. 在OBS中添加浏览器源输入URL和自定义CSS或者可以在首页的样式设置里输入CSS
### 使用Docker运行(仅x64)
1. 安装[docker](https://www.runoob.com/docker/ubuntu-docker-install.html)
2. 安装镜像
`docker build -t blivechat:latest .`
3. 运行镜像
`docker run -d --name blivechat -p 80:80 blivechat`
其中80:80的第一个80为映射到主机的端口号可替换为其它端口。
3. 用浏览器打开[http://localhost](http://localhost)输入房间ID进入房间复制房间URL
4. 可选用样式生成器生成样式复制CSS
5. 在OBS中添加浏览器源输入URL和自定义CSS或者可以在首页的样式设置里输入CSS
### Docker
1. ```sh
docker run -d -p 80:80 xfgryujk/blivechat
```
2. 以下略