lythx / trakman

Trackmania Forever server controller written in TypeScript
https://trakman.ptrk.eu
MIT License
24 stars 4 forks source link

no docker container available #220

Closed reaby closed 8 months ago

reaby commented 8 months ago

Would be super neat to have docker container for this!

Skorlok commented 8 months ago

I had the same request, so I did it myself to get a solution faster I posted a docker image to docker hub, and this is a example conf, be sure to get a postgres container linked to postgres-network I update the image when there is a new release on the master branch

version: '3.8'

services:
    trakman:
        image: skorlok/trakman:latest
        restart: unless-stopped
        container_name: trakman_tmnf
        depends_on:
            dedicated:
                condition: service_started
                restart: true
        # I didn't found a better way to handle config than create a volume to the built config file
        # I also didn't found a way to convert docker env vars to the .env file
        volumes:
            - ./Server/.env:/app/controller/.env
            - ./Server/Tracks/:/app/dedicated/GameData/Tracks/
            - ../TrakmanConfig/config/Config.js:/app/controller/built/config/Config.js
            - ../TrakmanConfig/plugins/info_messages/Config.js:/app/controller/built/plugins/info_messages/Config.js
            - ../TrakmanConfig/plugins/ui/config/Mod.js:/app/controller/built/plugins/ui/config/Mod.js
            - ../TrakmanConfig/plugins/ui/config/RaceUi.js:/app/controller/built/plugins/ui/config/RaceUi.js
            - ../TrakmanConfig/plugins/webservices/Config.js:/app/controller/built/plugins/webservices/Config.js
        networks:
            - xmlrpc-network
            - postgres-network

    dedicated:
        image: skorlok/forever_server:latest
        restart: unless-stopped
        container_name: dedicated_tmnf
        # The environment var ar optional, if not set, these values are used: "MatchSettings/tracklist.txt", "dedicated_cfg.txt"
        environment:
            GAME_SETTINGS: "MatchSettings/tracklist.txt"
            DEDICATED_CFG: "dedicated_cfg.txt"
        ports:
            - "2350:2350/tcp"
            - "2350:2350/udp"
            - "3450:3450/tcp"
            - "3450:3450/udp"
        volumes:
            - ./Server/Config/:/app/dedicated/GameData/Config/
            - ./Server/Tracks/:/app/dedicated/GameData/Tracks/
        networks:
            - xmlrpc-network

networks:
    xmlrpc-network:
        name: xmlrpc-network
        driver: bridge
        external: true
    postgres-network:
        name: postgres-network
        driver: bridge
        external: true
reaby commented 8 months ago

They use dotenv, so it should be just that you don't provide .env file and then just set the docker environment variables :)

wsrvn commented 8 months ago

seems like a reasonable request.

@Skorlok, would be great if you could make a PR with this, otherwise I'm sure @felacek could get it done too (he's unfortunately god knows where for the time being though).

Skorlok commented 8 months ago
version: '3.8'

services:
    trakman:
        image: skorlok/trakman:latest
        restart: unless-stopped
        container_name: trakman
        depends_on:
            dedicated:
                condition: service_started
                restart: true
        environment:
            # Dedicated server config
            SERVER_IP: "dedicated"
            SERVER_PORT: 5000
            SUPER_ADMIN_NAME: "SuperAdmin"
            SUPER_ADMIN_PASSWORD: ""

            # Database config
            DB_USER: "trakman"
            DB_PASSWORD: "trakman"
            DB_NAME: "trakman"
            DB_IP: "postgres"
            DB_PORT: 5432

            # Controller config
            OWNER_LOGIN: ""

            # Dedimania
            # This is either server password or playerpage community code
            DEDIMANIA_PASSWORD: ""

            # Freezone
            # Received on 'freezone:servers' manialink in-game
            FREEZONE_PASSWORD: ""

            # Webservices
            WEBSERVICES_LOGIN: ""
            WEBSERVICES_PASSWORD: ""

            # Logging
            LOG_LEVEL: 3
            DISCORD_LOG_ENABLED: "YES"
            DISCORD_LOG_LEVEL: 2
            DISCORD_WEBHOOK_URL: ""
            DISCORD_EMBED_IMAGES: ""
            DISCORD_TAGGED_USERS: ""
        volumes:
            - ./Server/Tracks/:/app/dedicated/GameData/Tracks/
        networks:
            - xmlrpc-network
            - postgres-network

    dedicated:
        image: skorlok/forever_server:latest
        restart: unless-stopped
        container_name: dedicated
        # The environment var ar optional, if not set, these values are used: "MatchSettings/tracklist.txt", "dedicated_cfg.txt"
        environment:
            GAME_SETTINGS: "MatchSettings/tracklist.txt"
            DEDICATED_CFG: "dedicated_cfg.txt"
        ports:
            - "2350:2350/tcp"
            - "2350:2350/udp"
            - "3450:3450/tcp"
            - "3450:3450/udp"
        volumes:
            - ./Server/Config/:/app/dedicated/GameData/Config/
            - ./Server/Tracks/:/app/dedicated/GameData/Tracks/
        networks:
            - xmlrpc-network

    postgres:
        image: postgres:alpine
        restart: unless-stopped
        container_name: database
        environment:
            POSTGRES_USER: "trakman"
            POSTGRES_PASSWORD: "trakman"
            POSTGRES_DB: "trakman"
        volumes:
            - ./postgresql:/var/lib/postgresql/data
        networks:
            - postgres-network

networks:
    xmlrpc-network:
        name: xmlrpc-network
        driver: bridge
        external: false
    postgres-network:
        name: postgres-network
        driver: bridge
        external: false
Skorlok commented 8 months ago

version with docker env vars instead of volume to .env (thanks Reaby) I added a postgres service

I can't try it now, i'm not a home you need to bring a dedicated_cfg and some maps with a maplist to make it work

reaby commented 8 months ago

yep thanks, also you don't need to define the networks nessecerily, them all in internal network, they see eachother anyway, it'll be simplier for that regard, also i got it running with this docker image you provided! Many thanks.

felacek commented 8 months ago

If it's not much of an ask, could you try out the container in #222 @reaby? It works on my machine but I'd like to know if it does on other ones... (also if I haven't made any stupid oversights) It's a bit more integrated as trakman and the tmf server share a container and hopefully a bit cleaner

reaby commented 8 months ago

Ooh, I got it working already with skorlok's example docker-compose file, also i see you closed the issue already, so i guess it works :)

wsrvn commented 8 months ago

skorlok helped us test it on his windows machine earlier (much thanks)..

aand both the readme and the wiki will be updated after #226 is merged (approx tomorrow) to have the new installation guide (using docker)