#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



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

# docker compose up -d --build
# docker compose --compatibility up -d --build

services: 
    
    oraclelinux_openjdk_landingpage_debug: 
        #stdin_open: true
        
        container_name: oraclelinuxlandingpagedebug
        platform: linux/amd64
        runtime: io.containerd.runc.v2
        #ports:
        #    - 0.0.0.0:80:80
        #    - 0.0.0.0:5005:5005
        ports:
        - target: 80
          host_ip: 127.0.0.1
          published: 80
          protocol: tcp
          mode: host
        environment:
            - VLAN=10
            - 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  
        #extra_hosts:
        #   - "host.docker.internal:host-gateway"
        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:X
        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
            - nvme,serial=deadbeef1,drive=nvm,nvme-subsys,id=nvme-subsys-0,nqn=subsys0,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 8.192G,maxmem=16.384G,slots=4 -object memory-backend-ram
            - object memory-backend-ram,size=4.096G,id=ram0 
            - object memory-backend-ram,size=4.096G,id=ram1 
            - object memory-backend-ram,size=4.096G,id=ram2 
            - object memory-backend-ram,size=4.096G,id=ram3 
            # 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
            
           
            - net nic,vlan=landingpagevlan
            # bios path must set
            #- bios http://demogitjava.ddns.net:8000/qemu/bios/openbios-sparc32
            - bios /root/openbios-sparc32.bin
            - virtualization=on
   
        dns:
            # no ip
           - "194.62.181.53" 
           - "194.62.180.53" 
           - "204.16.255.53" 
           - "204.16.254.53" 
            # google 
           - "8.8.8.8" 
           - "8.8.4.4" 
  
        dns_search: demogitjava.ddns.net
      
        privileged: true
        #cpu_quota: "2000"
        #cpu_period: "2000"
        #cpu_shares: 1024
        #isolation: default
        isolation: default
        tty: true
      
        image: jgsoftwares/oraclelinux_openjdk_landingpage:hostopenwrtext4
        security_opt:
            #- apparmor=docker-default
            - no-new-privileges=true
            - apparmor:unconfined
            - label=type:container_runtime_t
        #depends_on:
            # container must started      
        #    - openwrt2305dockernone
        deploy:
            #replicas: 2
            mode: global
            resources:
                limits:
                  cpus: '2'
                  memory: 16384M
                reservations:
                  cpus: '2'
                  memory: 16384M
        command: /bin/bash /root/runlandingpage.sh

networks:
  # frontend
  vlan10:
    name: wan
    driver: ipvlan
    # vlan name
    driver_opts:
      parent: eth0.10
      com.docker.network.bridge.gateway_mode_ipv4: isolated
      ipvlan_mode: l3
    ipam:
      config:
        - subnet: 217.160.255.254/32
          gateway: 217.160.255.254

