回到目录html
首先要清楚本文是讲dotnetcore项目在生产和测试环境部署的,这在过去的frameworks项目里,咱们能够经过设置web.config的环境变量,而后再发布时指定具体的变量,去实现生产环境和测试环境的发布,发布以后,每一个环境有本身的配置文件,frameworks会更新环境把web.config进行合并,而在dotnetcore项目里,这种方法不适用了,因此须要在这里再总结一下了。web
#!/bin/sh set -xe cd ${WORKSPACE}/deploy/ /bin/bash publish.sh /bin/bash build.sh "Production"
#!/bin/sh set -ex export IMAGE_NAME=svt/sms export Registry_Url="ciregistry.i-counting.cn:8443" #输入参数source,目前支持Development外测和Production生产环境两个值 docker build --no-cache --pull -t $IMAGE_NAME --build-arg source=$1 ./ docker tag $IMAGE_NAME $Registry_Url/$IMAGE_NAME docker push $Registry_Url/$IMAGE_NAME
FROM microsoft/aspnetcore:2.0 ARG source run echo $source COPY sources.list /etc/apt/sources.list RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone RUN apt-get update && apt-get -y install libgdiplus && apt-get clean ENV ASPNETCORE_ENVIRONMENT=$source WORKDIR /app EXPOSE 80 COPY obj/Docker/publish . ENTRYPOINT ["dotnet", "Validate.dll"]
config = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile(file, optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .Build();
好了,今天我们主要实现的是比较实用的按环境去部署项目的方法!docker
但愿本文章对各位有所帮助!json
回到目录api