From eaf27af2a42e4396b33e0e8d61dc3dc993fe593a Mon Sep 17 00:00:00 2001 From: yangyu Date: Fri, 20 Jul 2018 13:13:55 +0800 Subject: [PATCH] hexo --- hexo/Dockerfile | 26 ++++++++++++++++++++++++++ hexo/README.md | 23 +++++++++++++++++++++++ hexo/start.sh | 17 +++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 hexo/Dockerfile create mode 100644 hexo/README.md create mode 100644 hexo/start.sh diff --git a/hexo/Dockerfile b/hexo/Dockerfile new file mode 100644 index 0000000..8683f29 --- /dev/null +++ b/hexo/Dockerfile @@ -0,0 +1,26 @@ +FROM centos:7 + +MAINTAINER Yang + +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"] \ No newline at end of file diff --git a/hexo/README.md b/hexo/README.md new file mode 100644 index 0000000..2d8087e --- /dev/null +++ b/hexo/README.md @@ -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 容器自动更新文章内容 diff --git a/hexo/start.sh b/hexo/start.sh new file mode 100644 index 0000000..dbdb872 --- /dev/null +++ b/hexo/start.sh @@ -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 \ No newline at end of file