回到目錄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