NightWish


  • Home

  • Categories

  • About

  • Archives

  • Tags

Docker 持续部署hexo blog到github page上和云虚拟机上

Posted on 2020-09-21 | In Jenkins | Visitors

目标:

1.通过Dockerfile创建新的image

2.通过image创建容器去运行jenkins

3.启动nginx 容器挂载hexo blog

4.通过jenkins同时部署blog到github和nginx

5.push 新创建的image到docker hub

步骤:

1.创建一个目录dockerhexo

2.创建一个新目录名为Docker_file,创建Dockerfile:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#jenkins稳定版本
FROM jenkins/jenkins:lts
#切换root用户
USER root
RUN apt-get update \
#安装jsnode12.x版本
&& curl -sL https://deb.nodesource.com/setup_12.x | bash - \
&& apt-get install -y nodejs \
#安装hexo
&& npm install -g hexo-cli \
#安装hexo-deployer
&& npm install hexo-deployer-git
#切换回jenkins用户
User jenkins

2.运行 docker build生成image:

1
2
3
docker build -t zxlman/jenkinshexo .
#如果 需要no cache build image如下:
docker build --no-cache -t jenkinshexo .
Read more »

第一个Docker容器

Posted on 2020-09-19 | In Docker | Visitors

目标:

  1. 在linux虚拟机上安装docker

  2. 编写Dockefile 编译出一个image去运行nginx服务器

步骤:

1.ssh登录linux虚拟机,安装docker ,详见官方文档:https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository

2.在用户跟目录下面创建一个DockerTest的目录,并且创建一个名为Dockerfile的文件,内容如下:

1
2
3
4
5
6
7
8
#This is a sample Image
FROM ubuntu:18.04
MAINTAINER kevin

RUN apt-get update
RUN apt-get install -y nginx
#RUN /etc/init.d/nginx restart 不管用
CMD ["nginx", "-g", "daemon off;"]
Read more »

Docker Command

Posted on 2020-09-19 | In Docker | Visitors
1
2
3
4
5
6
7
8
9
10
# 列出本机的所有 image 文件。
$ docker image ls

# 删除 image 文件
$ docker image rm [imageName]

docker image pull library/hello-world # 从dockhub上拉取image
docker image pull hello-world
docker image ls
docker container run hello-world
Read more »

Hexo blog 安装SSL证书

Posted on 2020-08-29 | In Ubutun | Visitors

背景和目标:

域名:nightwish.tech(阿里云申请)

虚拟机:Azure Ubutun(公司给的MSDN 订阅)

Web server: Nginx

Hexo 的个人静态博客host在Azure Ubutun虚拟机的Nginx上,可以通过 http:nightwish.tech去访问,但是无法https 访问,希望通过申请SSL 证书可以通过https访问博客

步骤:

  1. https://letsencrypt.org/zh-cn/ 可以申请免费的SSL证书,有效期3个月
  1. 根据官网的安装文档 推荐使用cerbot安装证书 https://certbot.eff.org/lets-encrypt/ubuntuxenial-nginx

    2.1 通过SSH 登录虚拟机,执行如下命令

    1
    2
    sudo snap install --classic certbot
    sudo certbot --nginx
Read more »

如何使用Jenkins pipline持续部署Hexo blog到Ubutun和Github

Posted on 2020-08-27 | In Jenkins | Visitors

步骤:

  1. 创建一个Jenkins Pipeline project:

Read more »

如何使用Jenkins freestyle持续部署 Hexo 博客

Posted on 2020-08-27 | In Jenkins | Visitors

目标:

自动化部署 blog到github page上

步骤:

1.创建一个FreeStyle的Jenkins project

Read more »

如何创建运行一个Pipeline Project

Posted on 2020-08-25 | In Jenkins | Visitors

Pipeline是一个流程,这个流程定义了完成过一个CI/CD流程的步骤,通过执行这个流程代替手工自动去完成CI/CD,这个流程是由使用者自己定义的。本文的目的是以最简单的方式构建一个pipline的project

  1. 用.netCore构建一个最简单的Nunit单元测试项目,SourceCode详见https://github.com/nightwish2016/JenkinsPiplineTesting,其中有一个case会失败
1
2
3
4
git clone git@github.com:nightwish2016/JenkinsPiplineTesting.git
cd JenkinsPiplineTesting
dotnet build
dotnet test


Read more »

Jenkins上安装Blue Ocean

Posted on 2020-08-25 | In Jenkins | Visitors

Jenkins Blue Ocean

Blue ocean 是Jenkins的一种新的UI 界面

Blue ocan Plugin 安装:


Read more »

在Ubuntun虚拟机上安装Jenkins

Posted on 2020-08-25 | In Jenkins | Visitors

Ubutun版本:

步骤:

  1. 通过SSH登录AZure 的linux虚拟机(感谢我司赠送的每月$150的MSDN订阅)

  2. 运行如下shell脚本安装Jenkins,祥见官方文档:https://www.jenkins.io/doc/book/installing/#long-term-support-release

    1
    2
    3
    4
    5
    wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
    sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > \
    /etc/apt/sources.list.d/jenkins.list'
    sudo apt-get update
    sudo apt-get install jenkins
  3. 查看运行Jenkins service:

    1
    service jenkins status

    查看Azure上VM的8080端口打开:

    image-20200825172908227

Read more »

Git Command

Posted on 2020-07-27 | In Git | Visitors
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
mkdir mygit
git init
git add readme.txt
git commit -m "git test"
git status
git diff readme.txt
git log //查看修改内容
如果嫌输出信息太多,看得眼花缭乱的,可以试试加上--pretty=oneline参数:
git log --pretty=oneline
git reset --hard HEAD^ //回退到上一个版本
git reset --hard HEAD^ //回退到上上个版本
git reset --hard HEAD~100 //回退到上100个版本

git reflog //记录每次commit记录
git reset --hard 1094a //版本号从reflog获得

git checkout -- readme.txt //把readme.txt文件在工作区的修改全部撤销,git checkout -- file命令中的--很重要,没有--,就变成了“切换到另一个分支”的命令,我们在后面的分支管理中会再次遇到git checkout命令。

git reset HEAD <file>可以把暂存区的修改撤销掉(unstage),重新放回工作区

//删除文件
git rm test.txt
git commit -m "rm test.txt"


Read more »
<i class="fa fa-angle-left"></i>123<i class="fa fa-angle-right"></i>

28 posts
8 categories
10 tags
GitHub E-Mail
© 2023 Kevin Zhou
Powered by Hexo
Theme - NexT.Pisces