diff --git a/.dockerignore b/.dockerignore index 3729ff0..7947759 100644 --- a/.dockerignore +++ b/.dockerignore @@ -22,4 +22,6 @@ **/secrets.dev.yaml **/values.dev.yaml LICENSE -README.md \ No newline at end of file +README.md +docker-compose.yml +Dockerfile diff --git a/Risk.Server/Dockerfile b/Risk.Server/Dockerfile index 15f39e3..5604001 100644 --- a/Risk.Server/Dockerfile +++ b/Risk.Server/Dockerfile @@ -1,11 +1,11 @@ #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. -FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base +FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base RUN apt-get update && apt-get install -y curl WORKDIR /app EXPOSE 80 -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build WORKDIR /src COPY ["Risk.Server/Risk.Server.csproj", "Risk.Server/"] COPY ["Risk.Shared/Risk.Shared.csproj", "Risk.Shared/"] diff --git a/Risk.Signalr.CS1400Client/Dockerfile b/Risk.Signalr.CS1400Client/Dockerfile new file mode 100644 index 0000000..d7d0ca0 --- /dev/null +++ b/Risk.Signalr.CS1400Client/Dockerfile @@ -0,0 +1,24 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base +RUN apt-get update && apt-get install -y curl +WORKDIR /app +EXPOSE 80 + +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build +WORKDIR /src +COPY ["Risk.Signalr.CS1400Client/Risk.Signalr.CS1400Client.csproj", "Risk.Signalr.CS1400Client/"] +COPY ["Risk.Shared/Risk.Shared.csproj", "Risk.Shared/"] +COPY ["Risk.Akka/Risk.Akka.csproj", "Risk.Akka/"] +RUN dotnet restore "Risk.Signalr.CS1400Client/Risk.Signalr.CS1400Client.csproj" +COPY . . +WORKDIR "/src/Risk.Signalr.CS1400Client" +RUN dotnet build "Risk.Signalr.CS1400Client.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "Risk.Signalr.CS1400Client.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Risk.Signalr.CS1400Client.dll"] \ No newline at end of file diff --git a/Risk.Signalr.CS1400Client/Program.cs b/Risk.Signalr.CS1400Client/Program.cs index e3abfee..cc4308e 100644 --- a/Risk.Signalr.CS1400Client/Program.cs +++ b/Risk.Signalr.CS1400Client/Program.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Collections.Generic; using System.Threading.Tasks; +using System.Threading; namespace Risk.Signalr.CS1400Client { @@ -78,7 +79,12 @@ static async Task Main(string[] args) Console.WriteLine("My connection id is " + hubConnection.ConnectionId); await SignupAsync(playerName); // just wait .... + while(true) + { + Thread.Sleep(1000); + } Console.ReadLine(); + } static async Task SignupAsync(string playerName) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e979712 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,77 @@ +version: "3.9" + +services: + risk-server: + build: + context: . + dockerfile: ./Risk.Server/Dockerfile + container_name: risk-server + ports: + - "5000:5000" + environment: + SECRET_CODE: "${SECRET_CODE:-banana55}" # default: banana55 + SERVER_PORT: "${SERVER_PORT:-5000}" # default: 5000 + command: [ + "--StartGameCode", + "${SECRET_CODE:-banana55}", + "--urls", + "http://0.0.0.0:5000" + ] + healthcheck: + test: ["CMD", "curl", "-f", "http://risk-server:5000/css/bootstrap/bootstrap.min.css"] + interval: 5s + retries: 3 + timeout: 10s + start_period: 4s + + + cs1400-client: + build: + context: . + dockerfile: ./Risk.Signalr.CS1400Client/Dockerfile + container_name: cs1400-client + depends_on: + risk-server: + condition: service_healthy + environment: + SERVER_ADDRESS: "http://risk-server:5000" + PLAYER_NAME: "CS1400 Client" + command: [ + "http://risk-server:5000", + "CS1400 Client" + ] + + # console-client: + # build: + # context: . + # dockerfile: ./Risk.Signalr.ConsoleClient/Dockerfile + # container_name: console-client + # depends_on: + # - risk-server + # environment: + # SERVER_ADDRESS: "http://risk-server:5000" + # PLAYER_NAME: "Console Client" + # command: [ + # "dotnet", + # "Risk.Signalr.ConsoleClient.dll", + # "--serverAddress", + # "http://risk-server:5000", + # "--playerName", + # "Console Client" + # ] + + # python-client: + # build: + # context: . + # dockerfile: ./Risk.Signalr.PythonClient/Dockerfile + # container_name: python-client + # depends_on: + # - risk-server + # environment: + # SERVER_ADDRESS: "risk-server" + # SERVER_PORT: "5000" + # PLAYER_NAME: "Python Client" + # command: [ + # "python", + # "SampleRiskClient.py" + # ]