diff --git a/.dockerignore b/.dockerignore index 7549a713..ab6ea41b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,10 +7,15 @@ build/ **/node_modules/ # IDEs and editors -/.idea +.idea/ # misc **/.git* *.spec screenshots/ README.md + +# runtime data +data/* +!data/config.ini +log/* diff --git a/Dockerfile b/Dockerfile index 58889d71..82bc1a22 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,20 +14,22 @@ RUN wget https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.xz \ && ln -s /node-v10.16.0-linux-x64/bin/npm /usr/local/bin/npm # 后端依赖 -COPY requirements.txt /blivechat/ -RUN pip3 install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple -r /blivechat/requirements.txt +WORKDIR /blivechat +COPY requirements.txt ./ +RUN pip3 install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt # 前端依赖 -WORKDIR /blivechat/frontend -COPY frontend/package*.json ./ +WORKDIR ./frontend +COPY frontend/package.json frontend/package-lock.json ./ RUN npm i --registry=https://registry.npm.taobao.org -# 编译 -COPY . /blivechat +# 编译前端 +COPY . ../ RUN npm run build # 运行 -WORKDIR /blivechat +WORKDIR .. +VOLUME /blivechat/data /blivechat/log /blivechat/frontend/dist EXPOSE 12450 ENTRYPOINT ["python3", "main.py"] CMD ["--host", "0.0.0.0", "--port", "12450"] diff --git a/README.md b/README.md index 987d8be0..7c34d926 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,11 @@ ### 四、Docker(自建服务器) 1. ```sh - docker run -d -p 12450:12450 xfgryujk/blivechat:latest + docker run --name blivechat -d -p 12450:12450 \ + --mount source=blc-data,target=/blivechat/data \ + --mount source=blc-log,target=/blivechat/log \ + --mount source=blc-frontend,target=/blivechat/frontend/dist \ + xfgryujk/blivechat:latest ``` 2. 用浏览器打开[http://localhost:12450](http://localhost:12450),以下略