日本免费全黄少妇一区二区三区-高清无码一区二区三区四区-欧美中文字幕日韩在线观看-国产福利诱惑在线网站-国产中文字幕一区在线-亚洲欧美精品日韩一区-久久国产精品国产精品国产-国产精久久久久久一区二区三区-欧美亚洲国产精品久久久久

通過CI ci設(shè)計案例


即使是最小的側(cè)項目也值得它的CI/CD管道

通過CI ci設(shè)計案例


前言
使用當(dāng)今的工具 , 建立一個簡單的CI/CD管道并不困難 。即使是做一個小項目 , 這樣做也是學(xué)習(xí)很多東西的好方法 。Docker、GitLab和Portainer是用于此設(shè)置的一些很棒的組件 。
一個Demo小項目這里我們以https://sophia.events/為案例 , 我們保證頁面的event為最新的 。頁面的events在這里[1]
免責(zé)聲明:這是一個簡單的項目 , 但是項目的復(fù)雜性在這里并不重要 。我們將詳細(xì)介紹的CI/CD管道的組件可以以幾乎相同的方式用于更復(fù)雜的項目 。不過 , 它們非常適合微服務(wù) 。
廢話不說 , 直接上代碼
{"events": [{"title": "All Day DevOps 2018","desc": "We're back with 100, 30-minute practitioner-led sessions and live Q&A on Slack. Our 5 tracks include CI/CD, Cloud-Native Infrastructure, DevSecOps, Cultural Transformations, and Site Reliability Engineering. 24 hours. 112 speakers. Free online.","date": "17 octobre 2018, online event","ts": "20181017T000000","link": "https://www.alldaydevops.com/","sponsors": [{"name": "all-day-devops"}]},{"title": "Création d'une Blockchain d'entreprise (lab) & introduction aux smart contracts","desc": "Venez avec votre laptop ! Nous vous proposons de nous rejoindre pour réaliser la création d'un premier prototype d'une Blockchain d'entreprise (Lab) et avoir une introduction aux smart contracts.","ts": "20181004T181500","date": "4 octobre à 18h15 au CEEI","link": "https://www.meetup.com/fr-FR/IBM-Cloud-Cote-d-Azur-Meetup/events/254472667/","sponsors": [{"name": "ibm"}]},…]}
將mustache[2]模板應(yīng)用于此文件 , 以生成最終的web頁面 。
基于Docker的多層構(gòu)建生成web 頁面之后 , 將它們復(fù)制到nginx image中——部署在目標(biāo)機器上的image 。
然后構(gòu)建完成了兩個部分 , 由于多階段構(gòu)建:
· 資產(chǎn)的生成
· 創(chuàng)建包含資產(chǎn)的最終映像
這是Dockerfile用于構(gòu)建:
# Generate the assetsFROM node:8.12.0-alpine AS buildCOPY . /buildWORKDIR /buildRUN npm iRUN node clean.jsRUN ./node_modules/mustache/bin/mustache events.json index.mustache > index.html# Build the final image used to serve them FROM nginx:1.14.0COPY --from=build /build/*.html /usr/share/nginx/html/COPY events.json /usr/share/nginx/html/COPY css /usr/share/nginx/html/cssCOPY js /usr/share/nginx/html/jsCOPY img /usr/share/nginx/html/img
本地測試測試目的:只需要clone repo 然后在運行test.sh 。test.sh 會創(chuàng)建一個image然后運行 。
$ git clone :lucj/sophia.events.git$ cd sophia.events$ ./test.shSending build context to Docker daemon 2.588MBStep 1/12 : FROM node:8.12.0-alpine AS build ---> df48b68da02aStep 2/12 : COPY . /build ---> f4005274aadfStep 3/12 : WORKDIR /build ---> Running in 5222c3b6cf12Removing intermediate container 5222c3b6cf12 ---> 81947306e4afStep 4/12 : RUN npm i ---> Running in de4e6182036bnpm notice created a lockfile as package-lock.json. You should commit this file.npm WARN www@1.0.0 No repository field.added 2 packages from 3 contributors and audited 2 packages in 1.675sfound 0 vulnerabilitiesRemoving intermediate container de4e6182036b ---> d0eb4627e01fStep 5/12 : RUN node clean.js ---> Running in f4d3c4745901Removing intermediate container f4d3c4745901 ---> 602987ce7162Step 6/12 : RUN ./node_modules/mustache/bin/mustache events.json index.mustache > index.html ---> Running in 05b5ebd73b89Removing intermediate container 05b5ebd73b89 ---> d982ff9cc61cStep 7/12 : FROM nginx:1.14.0 ---> 86898218889aStep 8/12 : COPY --from=build /build/*.html /usr/share/nginx/html/ ---> Using cache ---> e0c25127223fStep 9/12 : COPY events.json /usr/share/nginx/html/ ---> Using cache ---> 64e8a1c5e79dStep 10/12 : COPY css /usr/share/nginx/html/css ---> Using cache ---> e524c31b64c2Step 11/12 : COPY js /usr/share/nginx/html/js ---> Using cache ---> 1ef9dece9bb4Step 12/12 : COPY img /usr/share/nginx/html/img ---> e50bf7836d2fSuccessfully built e50bf7836d2fSuccessfully tagged registry.gitlab.com/lucj/sophia.events:latest=> web site available on http://localhost:32768

推薦閱讀