This commit is contained in:
yangyu 2018-07-20 13:13:55 +08:00
parent d74a15a0ae
commit eaf27af2a4
3 changed files with 66 additions and 0 deletions

26
hexo/Dockerfile Normal file
View File

@ -0,0 +1,26 @@
FROM centos:7
MAINTAINER Yang <yangyufans@qq.com>
RUN yum install wget git-core -y
RUN wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
ENV NODE_VERSION=v10.7.0
RUN source ~/.bash_profile \
&& nvm install $NODE_VERSION \
&& npm install -g hexo-cli
RUN mkdir /logs
ENV NODE_HOME /root/.nvm/versions/node/$NODE_VERSION
ENV PATH $PATH:$NODE_HOME/bin
EXPOSE 80
COPY start.sh /
RUN chmod 777 /start.sh
ENTRYPOINT ["/start.sh"]

23
hexo/README.md Normal file
View File

@ -0,0 +1,23 @@
# mindoc
## 创建镜像
```bash
docker build -t ccr.ccs.tencentyun.com/yy-dk/hexo:latest .
```
也可以直接下载镜像
```bash
docker pull ccr.ccs.tencentyun.com/yy-dk/hexo:latest
```
## 创建容器
```bash
docker run -d \
--privileged=true \
-p 8080:80 \
-e BRANCH=master \
-e REPOSITORY=http://gitlab+deploy-token-6:an_zUzQceWQW4bX1b4Ws@git.yangyufans.com:yangyufans/hexo-test.git \
--name hexo-test ccr.ccs.tencentyun.com/yy-dk/hexo:latest
```
- BRANCH 分支名称可在本地部署使用develop预览线上环境用master
- REPOSITORY 仓库地址
> http://<用户名>:< token >@<仓库地址>
## 自动部署
发布文章只需要将文章提交到对应的仓库docker 容器自动更新文章内容

17
hexo/start.sh Normal file
View File

@ -0,0 +1,17 @@
#!/bin/bash
if [ ! -e /hexo ]; then
if [ -n "$REPOSITORY" ]; then
cd /;
git clone -b $BRANCH $REPOSITORY hexo;
fi
fi
hexo server --cwd /hexo -p 80 > /logs/hexo.log 2>&1 &
while true;
do
cd /hexo; git pull > /dev/null 2>&1 ;
sleep 5;
done