From 496970984f492d640eeb5a399155aa9a5d2e1351 Mon Sep 17 00:00:00 2001 From: anjoy8 <3143422472@qq.com> Date: Tue, 24 Aug 2021 15:21:25 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9Achange=20port=20from=208081=20->=20?= =?UTF-8?q?9291?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Blog.Core.Api/Dockerfile | 2 +- Blog.Core.Api/Program.cs | 2 +- Blog.Core.Api/Properties/launchSettings.json | 2 +- Blog.Core.Api/appsettings.json | 6 +++--- Blog.Core.Api/wwwroot/CorsPost.html | 6 +++--- Blog.Core.Api/wwwroot/index.html | 4 ++-- Blog.Core.Build.bat | 2 +- Blog.Core.Gateway/ocelot.Development.json | 2 +- Blog.Core.Gateway/ocelot.json | 2 +- Blog.Core.Publish.Docker.Jenkins.sh | 2 +- Blog.Core.Publish.Docker.sh | 2 +- Blog.Core.Tests/appsettings.json | 2 +- Blog.Core.sln | 4 +++- DockerBuild.bat | 18 ++++++++++++++++++ Dockerfile | 4 ++-- 15 files changed, 40 insertions(+), 20 deletions(-) create mode 100644 DockerBuild.bat diff --git a/Blog.Core.Api/Dockerfile b/Blog.Core.Api/Dockerfile index 2e25ef5..4361807 100644 --- a/Blog.Core.Api/Dockerfile +++ b/Blog.Core.Api/Dockerfile @@ -37,5 +37,5 @@ RUN echo 'Asia/Shanghai' >/etc/timezone #&& supervisord -c /etc/supervisord.conf WORKDIR /app COPY . . -EXPOSE 8081 +EXPOSE 9291 ENTRYPOINT ["dotnet", "Blog.Core.Api.dll","-b","0.0.0.0"] \ No newline at end of file diff --git a/Blog.Core.Api/Program.cs b/Blog.Core.Api/Program.cs index d405b82..9e41629 100644 --- a/Blog.Core.Api/Program.cs +++ b/Blog.Core.Api/Program.cs @@ -29,7 +29,7 @@ namespace Blog.Core //接入Apollo配置中心 config.AddConfigurationApollo("appsettings.apollo.json"); }) - .UseUrls("http://*:8081") + .UseUrls("http://*:9291") .ConfigureLogging((hostingContext, builder) => { // 1.过滤掉系统默认的一些日志 diff --git a/Blog.Core.Api/Properties/launchSettings.json b/Blog.Core.Api/Properties/launchSettings.json index 891d625..9b02dcc 100644 --- a/Blog.Core.Api/Properties/launchSettings.json +++ b/Blog.Core.Api/Properties/launchSettings.json @@ -15,7 +15,7 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "" }, - "applicationUrl": "http://localhost:8081" + "applicationUrl": "http://localhost:9291" }, "IIS Express": { "commandName": "IISExpress", diff --git a/Blog.Core.Api/appsettings.json b/Blog.Core.Api/appsettings.json index 39c865d..c31755d 100644 --- a/Blog.Core.Api/appsettings.json +++ b/Blog.Core.Api/appsettings.json @@ -1,5 +1,5 @@ { - "urls": "http://*:8081", //web服务端口,如果用IIS部署,把这个去掉 + "urls": "http://*:9291", //web服务端口,如果用IIS部署,把这个去掉 "Logging": { "LogLevel": { "Default": "Information", //加入Default否则log4net本地写入不了日志 @@ -252,7 +252,7 @@ "ConsulSetting": { "ServiceName": "BlogCoreService", "ServiceIP": "localhost", - "ServicePort": "8081", + "ServicePort": "9291", "ServiceHealthCheck": "/healthcheck", "ConsulAddress": "http://localhost:8500" }, @@ -271,7 +271,7 @@ "Namespace": "public", // 命名空间 "ListenInterval": 10000, // 监听的频率 "ServiceName": "blog.Core.Api", // 服务名 - "Port": "8081", // 服务端口号 + "Port": "9291", // 服务端口号 "RegisterEnabled": true // 是否直接注册nacos }, "LogFiedOutPutConfigs": { diff --git a/Blog.Core.Api/wwwroot/CorsPost.html b/Blog.Core.Api/wwwroot/CorsPost.html index cf160d5..8ebbf01 100644 --- a/Blog.Core.Api/wwwroot/CorsPost.html +++ b/Blog.Core.Api/wwwroot/CorsPost.html @@ -15,13 +15,13 @@ $(document).ready(function () { $("#jsonp").click(function () { - $.getJSON("http://localhost:8081/api/Login/jsonp?callBack=?", function (data) { + $.getJSON("http://localhost:9291/api/Login/jsonp?callBack=?", function (data) { $("#data-jsonp").html("数据: " + data.value); }); }); $("#cors").click(function () { - $.get("http://localhost:8081/api/Login/Token", function (data, status) { + $.get("http://localhost:9291/api/Login/Token", function (data, status) { console.log(data); $("#status-cors").html("状态: " + status); $("#data-cors").html("数据: " + data? data.token:"失败"); @@ -43,7 +43,7 @@ }; $.ajax({ type: 'post', - url: 'http://localhost:8081/api/Values', + url: 'http://localhost:9291/api/Values', contentType: 'application/json', data: JSON.stringify(postdata), success: function (data, status) { diff --git a/Blog.Core.Api/wwwroot/index.html b/Blog.Core.Api/wwwroot/index.html index cf47942..2e1be63 100644 --- a/Blog.Core.Api/wwwroot/index.html +++ b/Blog.Core.Api/wwwroot/index.html @@ -18,7 +18,7 @@ "bRemark": "string" }; $.ajax({ - url: "http://localhost:8081/api/Values", + url: "http://localhost:9291/api/Values", type: "POST", contentType: "application/json; charset=utf-8", data: JSON.stringify(postdata), @@ -34,7 +34,7 @@
-
+
diff --git a/Blog.Core.Build.bat b/Blog.Core.Build.bat index c6163e9..632e841 100644 --- a/Blog.Core.Build.bat +++ b/Blog.Core.Build.bat @@ -2,7 +2,7 @@ git pull @echo off -for /f "tokens=5" %%i in ('netstat -aon ^| findstr ":8081"') do ( +for /f "tokens=5" %%i in ('netstat -aon ^| findstr ":9291"') do ( set n=%%i ) taskkill /f /pid %n% diff --git a/Blog.Core.Gateway/ocelot.Development.json b/Blog.Core.Gateway/ocelot.Development.json index 3889dfb..88475e2 100644 --- a/Blog.Core.Gateway/ocelot.Development.json +++ b/Blog.Core.Gateway/ocelot.Development.json @@ -16,7 +16,7 @@ "DownstreamHostAndPorts": [ { "Host": "localhost", - "Port": 8081 + "Port": 9291 } ] }, diff --git a/Blog.Core.Gateway/ocelot.json b/Blog.Core.Gateway/ocelot.json index 362529e..c9612a6 100644 --- a/Blog.Core.Gateway/ocelot.json +++ b/Blog.Core.Gateway/ocelot.json @@ -16,7 +16,7 @@ "DownstreamHostAndPorts": [ { "Host": "localhost", - "Port": 8081 + "Port": 9291 } ] }, diff --git a/Blog.Core.Publish.Docker.Jenkins.sh b/Blog.Core.Publish.Docker.Jenkins.sh index cc95310..42f074a 100644 --- a/Blog.Core.Publish.Docker.Jenkins.sh +++ b/Blog.Core.Publish.Docker.Jenkins.sh @@ -17,4 +17,4 @@ chmod 777 StopContainerImg.sh ./StopContainerImg.sh apkcontainer laozhangisphi/apkimg docker build -t laozhangisphi/apkimg . -docker run --name=apkcontainer -d -v /data/blogcore/appsettings.json:/app/appsettings.json -v /data/blogcore/Log/:/app/Log -v /etc/localtime:/etc/localtime -it -p 8081:8081 laozhangisphi/apkimg \ No newline at end of file +docker run --name=apkcontainer -d -v /data/blogcore/appsettings.json:/app/appsettings.json -v /data/blogcore/Log/:/app/Log -v /etc/localtime:/etc/localtime -it -p 9291:9291 laozhangisphi/apkimg \ No newline at end of file diff --git a/Blog.Core.Publish.Docker.sh b/Blog.Core.Publish.Docker.sh index d4ae624..eadc23c 100644 --- a/Blog.Core.Publish.Docker.sh +++ b/Blog.Core.Publish.Docker.sh @@ -13,6 +13,6 @@ cd /home/Blog.Core/.PublishFiles # 编译镜像 docker build -t laozhangisphi/apkimg . # 生成容器 -docker run --name=apkcontainer -d -v /etc/localtime:/etc/localtime -it -p 8081:8081 laozhangisphi/apkimg +docker run --name=apkcontainer -d -v /etc/localtime:/etc/localtime -it -p 9291:9291 laozhangisphi/apkimg # 启动容器 docker start apkcontainer diff --git a/Blog.Core.Tests/appsettings.json b/Blog.Core.Tests/appsettings.json index a1edb35..95a95f1 100644 --- a/Blog.Core.Tests/appsettings.json +++ b/Blog.Core.Tests/appsettings.json @@ -197,7 +197,7 @@ "ConsulSetting": { "ServiceName": "BlogCoreService", "ServiceIP": "localhost", - "ServicePort": "8081", + "ServicePort": "9291", "ServiceHealthCheck": "/healthcheck", "ConsulAddress": "http://localhost:8500" } diff --git a/Blog.Core.sln b/Blog.Core.sln index 1e86d30..e587dda 100644 --- a/Blog.Core.sln +++ b/Blog.Core.sln @@ -31,6 +31,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionIt Blog.Core.Publish.Linux.sh = Blog.Core.Publish.Linux.sh codecov.yml = codecov.yml CreateYourProject.bat = CreateYourProject.bat + DockerBuild.bat = DockerBuild.bat + Dockerfile = Dockerfile nuget.config = nuget.config README.md = README.md EndProjectSection @@ -53,7 +55,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blog.Core.ConsoleApp", "Blo EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blog.Core.Gateway", "Blog.Core.Gateway\Blog.Core.Gateway.csproj", "{A11C0DF2-1E13-4EED-BA49-44A57136B189}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blog.Core.Serilog.Es", "Blog.Core.Serilog.Es\Blog.Core.Serilog.Es.csproj", "{52AFAB53-D1CA-4014-8B63-3550FDCDA6E1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blog.Core.Serilog.Es", "Blog.Core.Serilog.Es\Blog.Core.Serilog.Es.csproj", "{52AFAB53-D1CA-4014-8B63-3550FDCDA6E1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/DockerBuild.bat b/DockerBuild.bat new file mode 100644 index 0000000..7617488 --- /dev/null +++ b/DockerBuild.bat @@ -0,0 +1,18 @@ +echo off +echo "Press B to build images, P to push to registry, any other key to cancel" +set /p op= : +if "%op%"=="B" goto build +if "%op%"=="P" goto push +exit + +:build +docker rmi laozhangisphi/apkimg +docker build -f "Dockerfile" --force-rm -t laozhangisphi/apkimg . +goto end + +:push +docker push laozhangisphi/apkimg +goto end + +:end +pause \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index e6719f2..7445e60 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. #这种模式是直接在构建镜像的内部编译发布dotnet项目。 -#注意下容器内输出端口是8081 +#注意下容器内输出端口是9291 #如果你想先手动dotnet build成可执行的二进制文件,然后再构建镜像,请看.Api层下的dockerfile。 @@ -31,5 +31,5 @@ RUN dotnet publish "Blog.Core.Api.csproj" -c Release -o /app/publish FROM base AS final WORKDIR /app COPY --from=publish /app/publish . -EXPOSE 8081 +EXPOSE 9291 ENTRYPOINT ["dotnet", "Blog.Core.Api.dll"] \ No newline at end of file