#version: '3'
  # start derby db over network
  # create network with 
  # the network name is 172.17.0.0
  # docker network create --driver=bridge --subnet=172.17.0.0/24 --ip-range=172.17.0.0/24 --gateway=172.17.0.1 172.17.0.0
  
  # 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

# creeate 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 landingpagevlandocker 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:

  de_derby:  
    
    container_name: de_derby         
    platform: linux/amd64
    
    # default 
    runtime: io.containerd.runc.v2
  
    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
    #runtime: containerd-shim-runc-v2
    #ports:
    #  - "0.0.0.0:1527:1527"
    ports:
        - target: 1527
          host_ip: 127.0.0.1
          published: 1527
          protocol: tcp
          mode: host
    #networks:
    # 172.17.0.0:
    #    ipv4_address: 172.17.0.2
    environment:
      #- VLAN=20
      - TZ=CET-1
      - NTP_SERVERS=2.rhel.pool.ntp.org
      - NETWORK_IF=virbr0
      - QEMU_PORTS='1527'
      - QEMU_CPU=8
      - QEMU_RAM=2048
      #- QEMU_ARCH=${Sun-UltraSparc-IIIi-plus}
      - QEMU_ARCH=${QEMU_ARCH:-SPARC32PLUS}
      #- enable-kvm 
    #dns:
    #  - 95.85.95.85
    #  - 2.56.220.2
    #volumes:
    #  - /var/run/docker.sock:/var/run/docker.sock:X
    network_mode: host
    
    extra_hosts:
      - "host.docker.internal:host-gateway"
    hostname: demogitjava.ddns.net
    cap_add:
      - NET_ADMIN
      - SYS_ADMIN
      - SYS_TIME
    
    devices:
      - /dev/kvm
      - /dev/net/tun
      - sandbox on
      
      # network
      - netdev user,id=virbr0,hostfwd=tcp::1527-:1527 -device e1000,netdev=virbr0
      - e1000,mac=02:01:0e:dc:9c:00,netdev=virbr0net=217.160.255.1/32
      
      # sata
      #- ide-hd,netdev=virbr0,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 
      # bios path must set
      #- bios http://demogitjava.ddns.net:8000/qemu/bios/openbios-sparc32
      - bios /root/openbios-sparc32.bin
      - virtualization=on
      
      
      # 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
             
      # optional vga
      - vga qxl 
     
      - net nic,vlan=landingpagevlan
      
      - enable-kvm 
      - kernel 'bzImage' 
    privileged: true
    #isolation:  hyperv
    isolation: default
    
    tty: true
    stdin_open: true
  
    image: jgsoftwares/oraclelinux_openjdk_derbydb:openwrtext4 
    security_opt:
      #- apparmor=docker-default
      - no-new-privileges=true
      - apparmor:unconfined
      - label=type:container_runtime_t
    #depends_on:  
      # container must started
    #  - openwrt23docker
    deploy:
            mode: global
            resources:
                limits:
                  cpus: '2'
                  memory: 2048M
                reservations:
                  cpus: '2'
                  memory: 2048M
    # command: 
      
#networks:
#  172.17.0.0:
#   external: true


networks:
 # backend db
 vlan20:
    
    name: wan
    driver: ipvlan
    #driver: macvlan
    driver_opts:
      parent: eth0.20
      ipvlan_mode: l3
    ipam:
      config:
        - subnet: 217.160.255.1/32
          gateway: 217.160.255.1