Reputation:
I have done everything precisely as I think I should. My application works if I run it on the cloud.
The commands I run:
gcloud builds submit --tag gcr.io/****
gcloud run deploy *** --region us-central1 --platform managed --image gcr.io/t*** --allow-unauthenticated --port=26951
Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk
COPY . /app
WORKDIR /app
RUN dotnet publish -c Release -o out
ENTRYPOINT ["dotnet", "Test.dll"]
Program:
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
namespace Server
{
class Program
{
private static TcpListener tcpListener;
public static void Main(string[] args)
{
tcpListener = new TcpListener(IPAddress.Any, 26951);
tcpListener.Start();
tcpListener.BeginAcceptTcpClient(TCPConnectCallback, null);
}
private static void TCPConnectCallback(IAsyncResult _result)
{
TcpClient _client = tcpListener.EndAcceptTcpClient(_result);
}
}
}
CSProj:
<Project Sdk="***">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>
All of which are in the same location
Upvotes: 0
Views: 783
Reputation:
The solution is to alter the dockerfile like so:
FROM mcr.microsoft.com/dotnet/sdk:3.1 WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "run"]
Upvotes: 1