Docker compose with 2022.1.2

Hi Team,

I think ec-compose\docker-compose.yml needs an update for 2022.1.2, has anyone else managed to get things going with docker compose on this build?

Hi Japes,

Can you please DM me your log files that we can have a look at why you are experiencing this issue?

Hi @japes, I’ve posted my docker-compose setup to a repo here https://github.com/kobus-v-schoor/2022-ec-compose, it does a few things differently from the default one:

  1. Allows you to run the runner interactively so you don’t need to restart the docker container each time
  2. Mounts engine/runner/logger configs from outside of the repo so that you can make modifications and store it in source control
  3. Mounts and runs your bot in the same docker container you’re submitting

To use it, you need to place your bot code in the bot folder with its accompanying dockerfile (currently just the reference bot) and then run docker-compose up -d. Then exec into the bot and runner container in two terminals docker-compose exec runner bash and docker-compose exec bot sh. Start the runner then using BOT_COUNT=1 ./run.sh and start your bot however.

Thanks for sharing @kobus-v-schoor , will take a look.

Interesting to see someone else’s workflow.

@japes Hi, did you manage to get the docker-compose working on the newer engine? I am still lost :expressionless:

Hi @kr0 ,

Sorry for late reply, been a bit busy with RL the past few weeks…

I’ve got a docker-compose working, it’s hacky and probably breaks a lot of docker “best practice” rules , but here’s what I’m using:

version: "3.9"
services:
  runner:
    build:
      context: ../game-engine
      dockerfile: GameRunner/multi-stage.Dockerfile
    container_name: GameRunner
    networks:
      - network
    environment:
      BOT_COUNT: 2
    ports:
      - "5000:5000"
  engine:
    build:
      context: ../game-engine
      dockerfile: Engine/multi-stage.Dockerfile
    container_name: GameEngine
    networks:
      - network
    environment:
      RunnerIp: runner # Should be the Docker Compose service name used for the runner.
      LOG_LEVEL: info
      BOT_COUNT: 2
    depends_on:
      - "runner"
      - "logger"
  logger:
    build:
      context: ../game-engine
      dockerfile: Logger/multi-stage.Dockerfile
    container_name: GameLogger
    volumes:
      - ./logs/:/mnt/c/Users/path/to/a/folder/to/store/match/logs
    networks:
      - network
    environment:
      RUNNER_IPV4: runner
      MATCH_STATUS_FILE: matchState.log
      GAME_COMPLETE_FILE: gameComplete.log
    depends_on:
      - "runner"

#BOT_SECTION_BEGIN
  bot1:              
   build: #path to a bot folder...                    
   networks:                              
     - network                            
   environment:                           
     RUNNER_IPV4: runner                  
   depends_on:                            
     - "engine"                           

  bot2:              
   build: #path to a another bot folder...                     
   networks:                              
     - network                            
   environment:                           
     RUNNER_IPV4: runner                  
   depends_on:                            
     - "engine"                           

#BOT_SECTION_END


networks:
  network:

Main thing to fix was that the paths to the game engine/logger/runner changed, and the bot section also has to be slightly different to previous versions.

Then I also updated the multi-stage docker files for those 3 docker images as follows (I changed the COPY paths and the WORKSDIRs):

game-engine/Engine/multi-stage.Dockerfile:

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /app

COPY ./Engine/ ./Engine
COPY ../Domain/ ./Domain
WORKDIR /app/Engine
RUN dotnet restore
RUN dotnet publish --configuration Release --output ./publish/

FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine

WORKDIR /app/Engine
COPY --from=build /app/Engine/publish .

CMD ["dotnet", "Engine.dll"]

game-engine/Logger/multi-stage.Dockerfile:

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /app

COPY . ./
COPY ./Logger/ ./Logger
WORKDIR /app/Logger
RUN dotnet restore
RUN dotnet publish --configuration Release --output ./publish/

FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine

WORKDIR /app/Logger
COPY --from=build /app/Logger/publish .

CMD ["dotnet", "Logger.dll"]

game-engine/GameRunner/multi-stage.Dockerfile:

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /app

COPY ./GameRunner/ ./GameRunner
COPY ../Domain/ ./Domain
WORKDIR /app/GameRunner
RUN dotnet restore
RUN dotnet publish --configuration Release --output ./publish/

FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine

WORKDIR /app/GameRunner
COPY --from=build /app/GameRunner/publish .

EXPOSE 5000
CMD ["dotnet", "GameRunner.dll"]

YMMV, hope this helps…

1 Like