#version: '3'

# commands 
# docker compose build
# docker compose up

# debug image landingpage
#             derbydb

# run the docker containers over the wan ip
# depends_on:
#      - de_derby

#start container 
#   - landingpagedebug
#   - derbydb


# optional for debug is port 5005 - on line 20

# http://demogitjava.ddns.net:8000/serverconfig/rockylinux/docker-ce-edge-stable_rpm/docker-ce-cli-19.03.9-3.el7.x86_64.rpm
# alternative install dockercli to container with
# yum install http://demogitjava.ddns.net:8000/serverconfig/rockylinux/docker-ce-edge-stable_rpm/docker-ce-cli-19.03.9-3.el7.x86_64.rpm
#   volumes:
#    - /var/run/docker.sock:/var/run/docker.sock
  
# run container over podman
#podman compose up -d --build

#run container over docker
#docker compose up -d --build

# create docker vlan 
#docker network create -d ipvlan --subnet=217.160.255.254/32 --gateway=217.160.255.254 -o ipvlan_mode=l2 -o parent=ens6 landingpagevlan

# create a second vlan for qemu - virbr0
#docker network create -d ipvlan --subnet=217.160.255.254/32 --gateway=217.160.255.254 -o ipvlan_mode=l2 -o parent=ens6 virbr0

services: 
    
    oraclelinux_openjdk_landingpage_debug: 
        #stdin_open: true
        blkio_config:
            weight: 400
        container_name: oraclelinuxlandingpagedebug
        platform: linux/amd64
        runtime: io.containerd.runc.v2
        
        #ports:
        #    - 0.0.0.0:80:80
        #    - 0.0.0.0:5005:5005
        environment:
            - JAVA_DEBUG=true
            - TZ=CET-1
            #- DRINODE=/dev/dri/renderD128 
            - NTP_SERVER=2.rhel.pool.ntp.org
            - NETWORK_IF=virbr0
            #- QEMU_PORTS='80'
            #- QEMU_PORTS='5005'
            - QEMU_CPU=4
            - QEMU_RAM=2048
            #- QEMU_ARCH=${Sun-UltraSparc-IIIi-plus}
            - QEMU_ARCH=${QEMU_ARCH:-SPARC32PLUS}
        #blkio_config:
        #    weight: 100
        
            - enable-kvm 
            - kernel 'bzImage' 
        extra_hosts:
            - demogitjava.ddns.net:217.160.255.254  
        network_mode: host
        hostname: demogitjava.ddns.net
        volumes:
           # - /etc/resolv.conf:/etc/resolv.conf
           # - /root/git/landingpage/target/landingpage-0.0.1-SNAPSHOT.jar:/root/landingpage-0.0.1-SNAPSHOT.jar
             - /var/run/docker.sock:/var/run/docker.sock
        restart: unless-stopped
        cap_add:
            - NET_ADMIN
            - SYS_ADMIN
            - SYS_TIME
        devices:
            - /dev/kvm
            - /dev/net/tun
           
            # optional vga
            - vga qxl 
           
           
            
            # optional for debug port 5005 used
            - device e1000,netdev=virbr0
            
            # sata
            #- ide-hd,netdev=ens6,bus=sata.4,drive=SystemDisk,cpu host,machine SS-600MP=kvm:tcg
            
             # nvme
            - nvme,drive=nvme0,serial=deadbeaf1,num_queues=8
            #- machine sun4m=kvm:tcg
            
            # memory 
            - nvdimm,memdev=md1,id=nvdimm1
            #- m 2G,maxmem=8G,slots=4 -object memory-backend-ram
            - nvdimm -m 8G,maxmem=16G,slots=4 -object memory-backend-ram
            
            # network card
            - display gtk 
            - g 1024x768x8 -net nic,model=lance
            
             # qemu dns
            - nic user,dns=95.85.95.85
            - nic user,dns=2.56.220.2
            
            # Accelerator
            - accel kvm
            
            # bios path must set
            #- bios http://demogitjava.ddns.net:8000/qemu/bios/openbios-sparc32
            - bios /root/openbios-sparc32.bin
            - virtualization=on
        dns: 
            - 95.85.95.85
            - 2.56.220.2
        privileged: true
        #cpu_quota: "2000"
        #cpu_period: "2000"
        #cpu_shares: 1024
        isolation: default
        tty: true
      
        image: jgsoftwares/oraclelinux_openjdk_landingpage:host
        depends_on:
            - openwrt23docker
        deploy:
            replicas: 2
            mode: global
            resources:
                limits:
                  #cpus: '2'
                  memory: 1024M
                reservations:
                  #cpus: '0.25'
                  memory: 512M
        command: /bin/bash /root/runlandingpage.sh

networks:
  wan:
    name: wan
    driver: ipvlan
    # vlan name
    driver_opts:
      parent: landingpagevlan
    ipam:
      config:
        - subnet: 217.160.255.254/32
          gateway: 217.160.255.254


#networks:
#   eth0:
#      driver: macvlan
#      driver_opts:
#          parent: eth0
#      ipam:
#          driver: default

#networks:
#  host:
#    name: host
#    external: true
    
    




    