diff --git a/.gitignore b/.gitignore index e343837..cb4e9d0 100644 --- a/.gitignore +++ b/.gitignore @@ -133,3 +133,7 @@ dmypy.json #自己用的推送(( push_main.py + +# 避免上传配置文件 +.idea/ +config/*.json diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..50456b0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM python:3.8-slim-buster +LABEL maintainer="mailto@wolfbolin.com" + +# Why need these step? +# - fast mirror source +# - procps contains useful proccess control commands like: free, kill, pkill, ps, top +# - wget is quite basic tool +# - vim for online debugging +# - sync timezone +RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list \ + && sed -i 's/security.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list \ + && apt-get update && apt-get install -y --no-install-recommends procps wget vim \ + && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime + +# Project environment +WORKDIR /var/app +COPY . /var/app +COPY ./Config/openssl.cnf /etc/ssl + +RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip \ + && pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt + +# Docker operation parameters +ENV MULTI TRUE + +CMD if [ $MULTI==TRUE ];then python main_multi.py autorun;else python main.py;fi diff --git a/make-docker.sh b/make-docker.sh new file mode 100644 index 0000000..e6e5008 --- /dev/null +++ b/make-docker.sh @@ -0,0 +1,18 @@ +#!/bin/bash +docker_name="mihoyo-bbs" +docker stop ${docker_name} +docker rm ${docker_name} +echo -e "\033[5;36mOrz 旧容器(镜像)已清理\033[0m" + +time_now=$(date "+%m%d%H") +docker build -f Dockerfile --tag ${docker_name}:"${time_now}" . +echo -e "\033[5;36mOrz 镜像重建完成\033[0m" + +docker run -itd \ + --name ${docker_name} \ + --log-opt max-size=1m \ + -v $(pwd):/var/app \ + ${docker_name}:"${time_now}" +echo -e "\033[5;36mOrz 镜像启动完成\033[0m" +docker ps -a +docker logs ${docker_name} -f \ No newline at end of file diff --git a/restart-docker.sh b/restart-docker.sh new file mode 100644 index 0000000..a05ac34 --- /dev/null +++ b/restart-docker.sh @@ -0,0 +1,4 @@ +#!/bin/bash +docker_name="mihoyo-bbs" +docker restart ${docker_name} +docker logs -f ${docker_name} \ No newline at end of file