6、docker 安装.net core 3.1持续构建环境

1、拉取.net core 3.1 镜像

    docker pull mcr.microsoft.com/dotnet/core/aspnet:3.1

    docker pull mcr.microsoft.com/dotnet/core/sdk:3.1

2、.NETcore dockerfile   默认文件,给需要进行docker打包的项目增加

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base

WORKDIR /app

EXPOSE 80

EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build

WORKDIR /src

COPY ["CIDITest.csproj", ""]

RUN dotnet restore "./CIDITest.csproj"

COPY . .

WORKDIR "/src/."

RUN dotnet build "CIDITest.csproj" -c Release -o /app/build

FROM build AS publish

RUN dotnet publish "CIDITest.csproj" -c Release -o /app/publish

FROM base AS final

WORKDIR /app

COPY --from=publish /app/publish .

ENTRYPOINT ["dotnet", "CIDITest.dll"]

3、Jenkins 配置git地址,用户名和密码

4、构建触发器选择SCM,H/2 * * * *  每2分钟构建一次

5、构建选择shell,并输入

#!/bin/bash

# 获取短版本号

GITHASH=`git rev-parse --short HEAD`

docker stop ciditest

docker rm ciditest

echo ---------------Building Docker Image...------------------

docker build -t ciditest$GITHASH .

docker tag ciditest$GITHASH ciditest:latest

echo ---------------打包完成开始docker run.------------------

docker run --name ciditest -d -p 8005:80 ciditest:latest


6、更新为北京时间

System.setProperty('org.apache.commons.jelly.tags.fmt.timeZone', 'Asia/Shanghai')

你可能感兴趣的:(6、docker 安装.net core 3.1持续构建环境)