#version: '3'

# start h2 db with lanserver tcp
# with --add-host

# lanserver startet in embedded mode 
# jgsoftwares/oraclelinux_openjdk_lanservertcp:host

# the h2 console is available over port 8082
# on host mode close wan port over your provider to disable connect
# ore 

# 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

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

services:
      
    oraclelinux_openjdk_lanservertcp:
        network_mode: host
        hostname: demogitjava.ddns.net
        stdin_open: true
        tty: true
        #ports:
        #    - 0.0.0.0:8443:8443
        ports:
        - target: 8443
          host_ip: 127.0.0.1
          published: 8443
          protocol: tcp
          mode: host
        #extra_hosts:
        #    - demolanserver.ddns.net:217.160.255.254
        extra_hosts:
            - "host.docker.internal:host-gateway"
        environment:
            - VLAN=20
            - TZ=CET-1
            - NTP_SERVER=2.rhel.pool.ntp.org
            - NETWORK_IF=virbr0
            - QEMU_PORTS='8443'
            - QEMU_CPU=8
            - QEMU_RAM=16384
            #- QEMU_ARCH=${Sun-UltraSparc-IIIi-plus}
            - QEMU_ARCH=${QEMU_ARCH:-SPARC32PLUS}
        # default
        runtime: io.containerd.runc.v2
       
        #backend
        #runtime: containerd-shim-runc-v2
        isolation: default
        #blkio_config:
        #    weight: 100
        platform: linux/amd64
        #networks:
        #    172.17.0.0:
        #        ipv4_address: 172.17.0.104
        container_name: oraclelinuxlanservertcp
        volumes:
             - /var/run/docker.sock:/var/run/docker.sock:X
            #- /etc/resolv.conf:/etc/resolv.conf
        restart: unless-stopped
        devices:
            - /dev/kvm
            - /dev/net/tun
            - e1000,mac=02:01:0e:dc:9c:00,netdev=virbr0,net=217.160.255.254/32
            # network
            - netdev user,id=virbr0,hostfwd=tcp::8443-:8443 -device e1000,netdev=virbr0
            
            # sata
            #- ide-hd,netdev=wan,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
           
            
            # bios path must set
            #- bios http://demogitjava.ddns.net:8000/qemu/bios/openbios-sparc32
            - bios /root/openbios-sparc32.bin
            
             # optional vga
            - vga qxl 
            
            # network card
            - display gtk 
            - g 1024x768x8 -net nic,model=lance
            
            # 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 
            
            - virtualization=on
            
            # Accelerator
            - accel kvm
            - net nic,vlan=lanserver
         
            - enable-kvm 
            - kernel 'bzImage' 
      
        cap_add:
            - NET_ADMIN
            - SYS_ADMIN
            - SYS_TIME
        dns: 
            - 95.85.95.85
            - 2.56.220.2
        privileged: true
        image: jgsoftwares/oraclelinux_openjdk_lanservertcp:hostopenwrtext4
        security_opt:
            #- apparmor=docker-default
            - no-new-privileges=true
            - apparmor:unconfined
            
            - label=type:container_runtime_t
        #depends_on:
        #   - openwrt23docker
        deploy:
            mode: global
            resources:
                limits:
                  cpus: '2'
                  memory: 16384M
                reservations:
                  cpus: '2'
                  memory: 16384M
        command: /bin/bash /root/LanServer.sh



networks:
  # backend
  #vlan30: 
      
  vlan20:
    name: wan
    driver: ipvlan
    #driver: macvlan
    driver_opts:
      parent: lanserver
      ipvlan_mode: l3
    ipam:
      config:
        - subnet: 217.160.255.254/32
          gateway: 217.160.255.254
        
# host
#networks:
#   eth0:
#      driver: macvlan
#      driver_opts:
#          parent: eth0
#      ipam:
#          driver: default    

# optional bridge network
#networks:
#    172.17.0.0:
#        external: true
#        name: 172.17.0.0