跳至主要內容
基于容器化Jenkins的cicd环境配置

基于容器化Jenkins的ci/cd环境配置

提示

开发环境: nixos 24.05 docker 24.0.5 Jenkins 2.479.1 nginx 1.27.2 gitea 1.22.3

部署环境: ubuntu 22.04 docker 24.0.5

初始化环境

创建目录

mkdir -p local-ci-cd/gitea
mkdir -p local-ci-cd/Jenkins
mkdir -p local-ci-cd/nginx
cd local-ci-cd

Mr.Lexon大约 3 分钟environmentci/cdJenkinsenv-configuration
基于bind9建立本地dns服务(docker)

基于bind9建立本地dns服务(docker)

重要

部署环境: ubuntu 20.04 docker 24.0.7 ubuntu/bind9 9.18.28

配置完之后如果出现错误请看”补充“可以更快得解决问题

## 初始化配置 ### 创建文件夹: ``` sh mkdir dns-server mkdir dns-server/config mkdir dns-server/data ``` ### 然后创建`docker-compose`文件 ``` bash touch docker-compose.yml ``` ### 编辑文件: ``` bash version: "3.3"

Mr.Lexon大约 4 分钟environmentdockerbind9dnsubuntuenv-configuration
dockerCompose 模板

dockerCompose 模板

version: '3.3'  
services:  
   example:  
     #image build二选一  
      image: mysql  
      build:  
       context: ./dir  
       dockerfile: Dockerfile-alternate  
       args:  
         buildno: 1  
  
      container_name: example  
         
      ports:  
          - "8000:80"  
          -  
      volumes:  
           - /software/mysql/logs:/var/log/mysql  
           -  
      environment:  
         EXMAPLE: 'example'  
          restart: always  
  
#以下为高级配置  
      command: example  
      depends_on: example  
      networks:  
           - local  
           - default  
  
      devices:  
        - "/dev/ttyUSB0:/dev/ttyUSB0"  
      dns: 8.8.8.8  
      env_file: .env  
        external_links:other_contain  
      healthcheck:  
        test: ["CMD", "curl", "-f", "http://localhost"]  
        interval: 1m30s  
        timeout: 10s  
        retries: 3  
        start_period: 40s  
  
networks:  
   db:  
      external:  
         name: local  
   default:  
      driver: bridge

Mr.Lexon小于 1 分钟environmentdockerenv-configuration
affine知识库环境搭建(docker)

affine知识库环境搭建(docker)

首先拉取对应镜像:

docker pull ghcr.io/toeverything/affine-self-hosted:pre-alpha

Mr.Lexon小于 1 分钟environment#dockeraffine
element矩阵通信环境搭建

element矩阵通信环境搭建

简介

element是一款点对点加密软件,用于加密通信,好处是通信过程完全由自己掌控,包括通信资产以及通信质量。支持网站,app,windows&mac os&ios客户端,完全跨平台,以下教程均在docker内完成。

架构

  1. vps一台(最小创建即可)
  2. 域名一个
  3. ssl证书一个
  4. synapse服务端软件
  5. element客户端软件

步骤

首先在vps安装docker(详情可在docker安装教程查看)。


Mr.Lexon大约 5 分钟environmentdockermatrix通信env-configuration
页面配置

nvim安装与配置

为什么要使用nvim

因为nvim相较于其他IDE,它有以下优点:

  1. 打开快速
  2. 高度自定义
  3. 对linux友好 我一般使用jetbrains全家桶,但是这个作为一个普通的脚本编辑器太过于臃肿了。所以以此为契机折腾一下nvim(vscode?它作为一个json编辑器挺好的)

安装

以下所有安装基于mint(debian)系统 首先去到nvim官网下载安装包,在这里我选择的是Linux,下载完成之后,解压到对应目录的文件夹,解压命令:


Mr.Lexon大约 3 分钟environmentnvimIDE
docker容器更新

docker容器更新

当镜像文件改变的时候,首先停止容器:

docker-compose down

然后删除对应镜像:


Mr.Lexon小于 1 分钟environmentdockerenv-configuration
apache2 (阿帕奇服务器切换站点)

apache2 (阿帕奇服务器切换站点)

需求:

站点文件夹:/home/uulol/sites/uulol

访问域名:uulol.tc.2ceo.cn

命令:

a2ensite 开启站点

a2dissite 关闭站点

a2enconf 开启配置

a2disconf 关闭配置

流程:

  1. 创建站点文件夹:/home/uulol/sites/uulol

  2. 在/etc/apache2/site-available创建对应站点名称的网站配置文件:uulol.conf

  3. 将000-default.conf(默认配置文件)复制到uulol.conf

  4. uulol.conf配置如下

    <VirtualHost *:80>
            # The ServerName directive sets the request scheme, hostname and port that
            # the server uses to identify itself. This is used when creating
            # redirection URLs. In the context of virtual hosts, the ServerName
            # specifies what hostname must appear in the request's Host: header to
            # match this virtual host. For the default virtual host (this file) this
            # value is not decisive as it is used as a last resort host regardless.
            # However, you must set it for any further virtual host explicitly.
            ServerName uulol.tc.2ceo.cn #访问域名(自定义)
    
            ServerAdmin webmaster@localhost #站点管理员
            DocumentRoot /home/uulol/sites/uulol #站点文件夹(自定义)
            #ServerName webreopen.tc.2ceo.cn
    
            # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
            # error, crit, alert, emerg.
            # It is also possible to configure the loglevel for particular
            # modules, e.g.
            #LogLevel info ssl:warn
    
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    
            # For most configuration files from conf-available/, which are
            # enabled or disabled at a global level, it is possible to
            # include a line for only one particular virtual host. For example the
            # following line enables the CGI configuration for this host only
            # after it has been globally disabled with "a2disconf".
            #Include conf-available/serve-cgi-bin.conf
    </VirtualHost>
    
  5. 配置完成之后保存并使用

    a2ensite uulol.conf #启用站点
    systemctl reload apache2 #重启服务器
    
  6. 完成


Mr.Lexon大约 1 分钟environmentapache2env-configuration
Composer安装

Composer安装

运行以下命令:(这里默认已经安装了php)

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'e21205b207c3ff031906575712edab6f13eb0b361f2085f1f1237b7126d785e826a450292b6cfd1d64d92e6563bbde02') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer

Mr.Lexon小于 1 分钟environmentphpComposerenv-configuration
docker常见命令

docker常见命令

  1. 查看镜像:
docker images
  1. 启动镜像:

Mr.Lexon小于 1 分钟environmentdockerenv-configuration