#version: '3'

# volumes mounted from 
# rocky linux 8.6 

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




# compose container for 
#       docker_gwbridge

# run file with 
# docker compose -f docker-compose_docker_none.yml --compatibility up -d --build

services:
    openwrt23dockernone:
        stdin_open: true
        tty: true
        # x11 
        #ports:
        #    - 0.0.0.0:8443:8443
        ports:
        - target: 6010
          host_ip: 127.0.0.1
          published: 6010
          protocol: tcp
          mode: none
          
        # ssh
        - target: 22
          host_ip: 127.0.0.1
          published: 22
          protocol: tcp
          mode: none
        container_name: openwrt23none
        runtime: io.containerd.runc.v2
        isolation: default
        #isolation: hyperv
        environment:
            # router backend is set to 
            # 30
            - VLAN=30
            
            # Timzeone
            # Berlin
            - TZ=CET-1
            
           # - NETWORK_IF=virbr0
            - QEMU_CPU=4
            - QEMU_RAM=256
            #- QEMU_ARCH=${QEMU_ARCH:-cortex-a72}
            
            
            - QEMU_ARCH=${cortex-a7}
            - enable-kvm 
        blkio_config:
            weight: 1000
        #cpu_shares: 1024
        #cpu_quota: "1000"
        #cpu_period: "1000"
        #network_mode: host
        # in swarm mode
        # create docker network in swarm mode with 
        #
        # docker network create -d overlay landingpage
        #
        # in swarm mode
        network_mode: none
        hostname: demogitjava.ddns.net
        #extra_hosts:
        #    - demogitjava.ddns.net:217.160.255.254
        extra_hosts:
             - "host.docker.internal:host-gateway" 
      
        platform: linux/amd64
        restart: unless-stopped
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock:X
            - /opt/docker/:/var/lib/docker:X
            # - /etc/docker/daemon.json:/etc/docker/daemon.json:X
 
        devices:
            
           
            # Accelerator
            - accel kvm
           
            - M pc-q35-2.0 
            
            # 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
            - nographic
            # memory 
            - nvdimm,memdev=md1,id=nvdimm1
            #- m 2G,maxmem=8G,slots=4 -object memory-backend-ram
            - nvdimm -m 0.1024G,maxmem=0.4096G,slots=4 -object memory-backend-ram
            - object memory-backend-ram,size=0.1024G,id=ram0 
            - object memory-backend-ram,size=0.1024G,id=ram1 
            - object memory-backend-ram,size=0.1024G,id=ram2 
            - object memory-backend-ram,size=0.1024G,id=ram3 
           
            
            - net nic,vlan=landingpagevlan
            - net nic,vlan=devssh
            - net nic,vlan=lanserver
            - net nic,vlan=virbr0
        dns: 
            - 95.85.95.85
            - 2.56.220.2
        cap_add:
            - NET_ADMIN
        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
             
        pid: "host"
        privileged: true
        image: jgsoftwares/openwrt23.05:dockermwan3
        security_opt:
             #- apparmor=docker-default
             - no-new-privileges=true
             - apparmor:unconfined
             - label=type:container_runtime_t
       
        deploy:
            # optional 
            # for frontend and backend
            #replicas: 2
            mode: global
            resources:
                limits:
                  #cpus: '2'
                  memory: 2048M
                reservations:
                  #cpus: '0.25'
                  memory: 512M
                
        command: /bin/ash

networks:
    
  # frontend
  #vlan10:
      
  # backend
  #vlan20:
    
  # remote 
  #vlan30: 

  # web
  vlan10:
    driver: ipvlan
    #driver: macvlan
    driver_opts:
      # public 
      parent: landingpagevlan
      ipvlan_mode: l3
    ipam:
      config:
        - subnet: 217.160.255.254/32
          gateway: 217.160.255.254
          
          
  # dev ssh docker container
  vlan20:
    driver: ipvlan
    driver_opts:
      parent: devssh
      ipvlan_mode: l3
    ipam:
      config:
        - subnet: 217.160.255.254/32
          gateway: 217.160.255.254

  # lanserver
  vlan30: 
    driver: ipvlan
    driver_opts:
      parent: lanserver
      ipvlan_mode: l3
    ipam:
      config:
        - subnet: 217.160.255.254/32
          gateway: 217.160.255.254
   
  # vpn
  # virbr0
  vlan30: 
    driver: ipvlan
    driver_opts:
      parent: virbr0
      ipvlan_mode: l3
    ipam:
      config:
        - subnet: 217.160.255.254/32
          gateway: 217.160.255.254
    


        


        
