Docker remember once deployed Asp.Net Core stepped pit process 3.0

  Recently the company intends to reconstruct the current system to a direct declaration micro letter applet, the current system can only use the PC above, the past two years been engaged App end, but due to the movement of persons and corporate structure adjustment and finally let the matter rest, leaving only under a pile of half-written interface. Previous interface is still using Asp.Net Framework implementation, and .Net situation is also very embarrassed, many .Neter also want to turn Java or Pythod embrace of his own, learn Java, but as a work for six years. Neter, it is also to give up some unwilling .Net, java or in the process of transfer of the uncertainty in the future to make himself hesitated for a long time, until the development of .Net Core 3.0, I was sharing in .Net Core sector this time of reconstruction of the interface also fell on my hands, so nothing wrong, I suggest using .Net Core to implement and build from architecture to achieve, I will try to do it.

  Friday, when the architecture take 7788 to achieve a login function, when I deploy it to a development server, I'm from the official website ( https://dotnet.microsoft.com/download/dotnet- Core / 3.0 ) have downloaded the operating environment, you install the IIS packing running package on the server, and then deploy the project to the IIS, the normal operation of the project, over the operation and maintenance of other colleagues will inform the original .Net FrameWork site application pool Full stop, as long as a visit automatically stop after the restart, can not access, then he that is uninstalled I just installed the operating environment, the original site can be visited, and now I have yet to find out what causes in is totally on my own computer problems, I do not know what circumstances led to this problem, as aware of the situation at the time you read this, please inform one or two, thank you.

  Well, I will not toss issues on the IIS, decided to deploy it to Docker better.

  Thus began the history of the stepped pit.

  First, I add in the project the Docker support, VS2019 folder is automatically created under the Dockerfile file in the project file, as follows

FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
WORKDIR /src
COPY ["src/H.Cms.Web.Api/H.Cms.Web.Api.csproj", "src/H.Cms.Web.Api/"]
COPY ["src/H.Cms.Infrastructure/H.Cms.Infrastructure.csproj", "src/H.Cms.Infrastructure/"]
COPY ["src/H.Cms.Core/H.Cms.Core.csproj", "src/H.Cms.Core/"]
COPY ["src/H.Cms.Application/H.Cms.Application.csproj", "src/H.Cms.Application/"]
COPY ["src/H.Cms.Web.Core/H.Cms.Web.Core.csproj", "src/H.Cms.Web.Core/"]
RUN dotnet restore "src/H.Cms.Web.Api/H.Cms.Web.Api.csproj"
COPY . .
WORKDIR "/src/src/H.Cms.Web.Api"
RUN dotnet build "H.Cms.Web.Api.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "H.Cms.Web.Api.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "H.Cms.Web.Api.dll"]

  Next time I will upload the entire project to a virtual machine on my centos 7, pscp started using the following command, to the pit, folder names can not have spaces.

pscp -r F:/aspnet core/hcms root@192.168.143.122:/usr/soft

  Well, reluctantly replaced by Secure Shell Client to upload, after completion, I use putty to log my virtual machine centos7, enter the / root / source / HCms project into H.Cms.Web.Api directory, use a docker build building when you mirror, suggesting a mistake

docker build -t docker build -t jesen/hcms:1.0 .

  View the next Dockerfile file, well, Dockerfile src file from the beginning, I copy it to the same src directory, run docker build again, this is really under normal operation, and began docker 3.0 environment does not exist .netcore, need first download and install, but the process is very slow, so I went to bed a nap, wake up and really just great, but to dotnet restore command when the visit could not have been reported api.nuget.org, days chatter, from my view the direct access is no problem ah. This question took me a long time, and finally I want to say that I'm not restore a docker in, and I publish it in the publication in the docker in direct Okay, so I chose the VS linux-x64 platform release, Hey, the question is, is reported api.nuget.org unable to visit, but this time there is the ip 23.101.10.141 , in  https://site.ip138.com query for a moment, the Hong Kong ip, I think, the recent violence in Hong Kong very serious incident, not influence it, try holding the attitude, I modify the host file, add a point to the Singapore IP, DNS resolution refresh

104.215.155.1 api.nuget.org
ipconfig /flushdns

  Re-released in VS, the day the chatter, really successfully posted, okay, then I put the virtual machine's / etc / hosts file can also add this IP to resolve it, sure enough, when I run docker build again, though So for a while, finally successful, really successful.

  After docker build build good image, the next step is to run a mirror, to see if that in the normal operation of the docker, run docker run

docker run -d -p 8002:80 -v ~/docker/aspnetcore/hcms/conf/appsettings.json:/app/appsettings.json -name hcms jesen/hcms:v1.0

  I began to mount appsettings.json document written in the files, error, and did not notice a problem, then use docker exec command to view the docker container of hcms, no problem found

docker exec -it hcms sh

  Come back to finish know that this is file does not exist, well, the ~ / docker / aspnetcore / hcms / conf / appsettings.json / directory deletion, New appsettings.json file, configuration information is also copied to the file, modify the database link IP address, use the IP address of the virtual machine on the host computer to access the page from loading properly.

 

   But when I visited an API, an error, and I think it should be less than IP access a database link, then saw a host firewall, open, well, plus inbound rules, open port 1433, another visit ,normal now.

 

 

  These are the Asp.Net Core 3.0 is deployed to process the docker, although it took some time, but finally the perfect run up, it makes me brave in the next project of promoting the use of .Net Core to develop increased confidence , come on!

 

 

 

Guess you like

Origin www.cnblogs.com/jesen1315/p/11925434.html