Trying to upload a docker image with dotnet core webapi project.
A requirement of cloud run is that it is listening on port 8080.
I believe I am doing that but when I create a cloud-run service after pushing to container registry GCP comes back with:
"Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information."
Locally I have kestrel listening on 8080. Also have had the container listing on 8080. But when I pushed either one I get the failure to start message...? Any suggestions or attempts at doing this?
@wlhee Here is the LOG from cloud run:
2019-04-13T05:24:53.462592ZHosting environment: Production
2019-04-13T05:24:53.462657ZContent root path: /app
2019-04-13T05:24:53.462678ZNow listening on: http://[::]:80
2019-04-13T05:24:53.462697ZApplication started. Press Ctrl+C to shut down.
2019-04-13T05:28:48.973934834ZContainer terminated by the container manager on signal 9.
"Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information."
~ DOCKER FILE
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS base
WORKDIR /app
ENV ASPNETCORE_URLS=http://+:8080
EXPOSE 8080
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
WORKDIR /src
COPY ["simplecore.csproj", "simplecore/"]
RUN dotnet restore "simplecore/simplecore.csproj"
COPY . .
WORKDIR "/src/simplecore"
RUN dotnet build "simplecore.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "simplecore.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "simplecore.dll"]
~ HERE IS MY MAIN FROM CORE APP
public static void Main(string[] args)
{
//CreateWebHostBuilder(args).Build().Run();
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
//.UseIISIntegration()
.UseStartup<Startup>()
.UseUrls("http://0.0.0.0:8080/")
.Build();
host.Run();
}
2019-04-13T05:24:53.462592ZHosting environment: Production 2019-04-13T05:24:53.462657ZContent root path: /app 2019-04-13T05:24:53.462678ZNow listening on: http://[::]:80 2019-04-13T05:24:53.462697ZApplication started. Press Ctrl+C to shut down. 2019-04-13T05:28:48.973934834ZContainer terminated by the container manager on signal 9.
sorry about the formatting – user3693978