version: "3.8"
networks:
    default:
        name: mynetwork
        driver: bridge
        ipam:
            config:
                - subnet: 172.172.0.0/24
services:
    portainer:
        image: portainer/portainer-ce:2.5.1
        restart: always
        ports:
            - 8000:8000
            - 9000:9000
        volumes:
            - ${DOCKER_SOCK}:/var/run/docker.sock
            - ../data/portainer:/data
    netdata:
        image: netdata/netdata:v1.30.0
        restart: always
        ports:
            - 19999:19999
        cap_add:
            - SYS_PTRACE
        security_opt:
            - apparmor:unconfined
        volumes:
            - /etc/passwd:/host/etc/passwd:ro
            - /etc/group:/host/etc/group:ro
            - /proc:/host/proc:ro
            - /sys:/host/sys:ro
            - /etc/os-release:/host/etc/os-release:ro
    registry: #https://docs.docker.com/registry/deploying/
        image: registry:2.7.1
        restart: always
        environment:
            - REGISTRY_STORAGE_DELETE_ENABLED=true
        ports:
            - 5000:5000 #http://localhost:5000/v2/_catalog
        volumes:
            - ../data/registry:/var/lib/registry
    docker-registry-ui:
        image: joxit/docker-registry-ui:2.0
        restart: always
        ports:
            - 9580:80
        environment:
            - REGISTRY_TITLE=${IP}:5000
            - NGINX_PROXY_PASS_URL=http://registry:5000
            - DELETE_IMAGES=true
            - SINGLE_REGISTRY=true
        depends_on:
            - registry
    gitea: # init with ip:port https://docs.gitea.io/en-us/install-with-docker
        image: gitea/gitea:1.14.2
        restart: always
        environment:
            - USER_UID=1000
            - USER_GID=1000
        ports:
            - 3000:3000
            - ${IP}:222:22
        volumes:
            - /etc/timezone:/etc/timezone:ro
            - /etc/localtime:/etc/localtime:ro
            - ./conf/gitea/custom:/data/gitea/custom
            - ../data/gitea:/data
    drone: #https://docs.drone.io/server/provider/gitea/ https://github.com/drone/drone
        image: drone/drone:2.0.1
        restart: always
        ports:
            - ${DRONE_SERVER_HTTP_PORT}:80
            - 9443:443
        environment:
            - DRONE_GITEA_SERVER=http://${IP}:3000
            - DRONE_GITEA_CLIENT_ID=${DRONE_GITEA_CLIENT_ID}
            - DRONE_GITEA_CLIENT_SECRET=${DRONE_GITEA_CLIENT_SECRET}
            - DRONE_RPC_SECRET=${DRONE_RPC_SECRET}
            - DRONE_SERVER_HOST=${IP}:${DRONE_SERVER_HTTP_PORT}
            - DRONE_SERVER_PROTO=${DRONE_SERVER_PROTO}
            - DRONE_USER_CREATE=username:root,machine:false,admin:true,token:55f24eb3d61ef6ac5e83d550178638dc
        volumes:
            - ../data/drone:/data
        depends_on:
            - gitea
            - registry
    drone-runner-docker:
        image: drone/drone-runner-docker:1.6.3
        restart: always
        privileged: true
        ports:
            - 3001:3000
        environment:
            - DRONE_RPC_PROTO=${DRONE_SERVER_PROTO}
            - DRONE_RPC_HOST=drone
            - DRONE_RPC_SECRET=${DRONE_RPC_SECRET}
            - DRONE_RUNNER_CAPACITY=2
            - DRONE_RUNNER_NAME=Local-Runner
        volumes:
            - ${DOCKER_SOCK}:/var/run/docker.sock
        depends_on:
            - drone
            - registry
    # dnsmasq:
    #     image: jpillora/dnsmasq:1.1.0
    #     restart: always
    #     cap_add:
    #         - NET_ADMIN
    #     ports:
    #         - 53:53/udp
    #         - 10000:8080
    #     volumes:
    #         - ./conf/dnsmasq/dnsmasq.conf:/etc/dnsmasq.conf
    # nginx:
    #     image: nginx:1.20.0
    #     restart: always
    #     environment:
    #         TZ: "Asia/Shanghai"
    #     ports:
    #         - 80:80
    #         - 443:443
    #     volumes:
    #         - ./conf/nginx/conf.d:/etc/nginx/conf.d
    #         - ./log/nginx:/var/log/nginx
