diff --git a/labs/docker-lan/.env.example b/labs/docker-lan/.env.example new file mode 100644 index 00000000..44644d37 --- /dev/null +++ b/labs/docker-lan/.env.example @@ -0,0 +1,18 @@ +TZ=Asia/Shanghai +IP=172.20.32.1 +PORT=9080 +#windows:DOCKER_SOCK=//var/run/docker.sock +#linux:DOCKER_SOCK=/var/run/docker.sock +DOCKER_SOCK=//var/run/docker.sock + +#gitea +GITEA_HTTP_PORT=3000 +GITEA_SSH_PORT=3022 + +#drone +DRONE_SERVER_HTTP_PORT=9080 +DRONE_SERVER_HTTPS_PORT=9443 +DRONE_GITEA_CLIENT_ID=d3348ec2-ec0d-4a76-a80c-c668b7a5b998 +DRONE_GITEA_CLIENT_SECRET=Tuh4cP1qaDjBb9fVES6fgQb7VXhKzoYttuPvKnqfl-k= +DRONE_RPC_SECRET=bea26a2221fd8090ea38720fc445eca6 +DRONE_SERVER_PROTO=http \ No newline at end of file diff --git a/labs/docker-lan/.gitignore b/labs/docker-lan/.gitignore new file mode 100644 index 00000000..6ae33d1e --- /dev/null +++ b/labs/docker-lan/.gitignore @@ -0,0 +1,4 @@ +.vscode +.env +log +data \ No newline at end of file diff --git a/labs/docker-lan/README.md b/labs/docker-lan/README.md new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/labs/docker-lan/README.md @@ -0,0 +1 @@ + diff --git a/labs/docker-lan/conf/dnsmasq/dnsmasq.conf b/labs/docker-lan/conf/dnsmasq/dnsmasq.conf new file mode 100644 index 00000000..dfadd0ec --- /dev/null +++ b/labs/docker-lan/conf/dnsmasq/dnsmasq.conf @@ -0,0 +1,16 @@ +#dnsmasq config, for a complete example, see: +# http://oss.segetech.com/intra/srv/dnsmasq.conf +#log all dns queries +log-queries +#dont use hosts nameservers +no-resolv +#use cloudflare as default nameservers, prefer 1^4 +server=114.114.114.114 +server=8.8.8.8 +strict-order +#serve all .company queries using a specific nameserver +server=/lan/10.10.14.176 +#explicitly define host-ip mappings +address=/portainer.lan/10.10.14.176 +address=/netdata.lan/10.10.14.176 +address=/gitlab.lan/10.10.14.176 \ No newline at end of file diff --git a/labs/docker-lan/conf/drone/.drone.yml b/labs/docker-lan/conf/drone/.drone.yml new file mode 100644 index 00000000..7af44ff4 --- /dev/null +++ b/labs/docker-lan/conf/drone/.drone.yml @@ -0,0 +1,19 @@ +name: default + +kind: pipeline +type: docker + +steps: +- name: build + image: golang + commands: + - go get + - go build + +- name: publish + image: plugins/docker + settings: + repo: octocat/hello-world + tags: [ 1, 1.1, latest ] + registry: 172.20.32.1:5000 + insecure: true diff --git a/labs/docker-lan/conf/drone/Dockerfile b/labs/docker-lan/conf/drone/Dockerfile new file mode 100644 index 00000000..412b43dd --- /dev/null +++ b/labs/docker-lan/conf/drone/Dockerfile @@ -0,0 +1 @@ +image: golang:alpine \ No newline at end of file diff --git a/labs/docker-lan/conf/drone/app.go b/labs/docker-lan/conf/drone/app.go new file mode 100644 index 00000000..ab12a00b --- /dev/null +++ b/labs/docker-lan/conf/drone/app.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main(){ + fmt.Printf("Hello World!"); +} \ No newline at end of file diff --git a/labs/docker-lan/conf/drone/go.mod b/labs/docker-lan/conf/drone/go.mod new file mode 100644 index 00000000..ebe89e0e --- /dev/null +++ b/labs/docker-lan/conf/drone/go.mod @@ -0,0 +1,3 @@ +module example + +go 1.14 \ No newline at end of file diff --git a/labs/docker-lan/conf/nginx/conf.d/gitlab.conf b/labs/docker-lan/conf/nginx/conf.d/gitlab.conf new file mode 100644 index 00000000..c53897f5 --- /dev/null +++ b/labs/docker-lan/conf/nginx/conf.d/gitlab.conf @@ -0,0 +1,8 @@ +server { + listen 80; + server_name gitlab.lan; + + location / { + proxy_pass http://gitlab:9080; + } +} \ No newline at end of file diff --git a/labs/docker-lan/conf/nginx/conf.d/netdata.conf b/labs/docker-lan/conf/nginx/conf.d/netdata.conf new file mode 100644 index 00000000..f89aa391 --- /dev/null +++ b/labs/docker-lan/conf/nginx/conf.d/netdata.conf @@ -0,0 +1,8 @@ +server { + listen 80; + server_name netdata.lan; + + location / { + proxy_pass http://netdata:19999; + } +} \ No newline at end of file diff --git a/labs/docker-lan/conf/nginx/conf.d/portainer.conf b/labs/docker-lan/conf/nginx/conf.d/portainer.conf new file mode 100644 index 00000000..ed9c2e3c --- /dev/null +++ b/labs/docker-lan/conf/nginx/conf.d/portainer.conf @@ -0,0 +1,8 @@ +server { + listen 80; + server_name portainer.lan; + + location / { + proxy_pass http://portainer:9000; + } +} \ No newline at end of file diff --git a/labs/docker-lan/conf/nginx/nginx.conf b/labs/docker-lan/conf/nginx/nginx.conf new file mode 100644 index 00000000..ec17822e --- /dev/null +++ b/labs/docker-lan/conf/nginx/nginx.conf @@ -0,0 +1,30 @@ +user root; +worker_processes 4; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + + server { + listen 80; + server_name default; + absolute_redirect off; + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } + include conf.d/*.conf; +} \ No newline at end of file diff --git a/labs/docker-lan/docker-compose.yml b/labs/docker-lan/docker-compose.yml new file mode 100644 index 00000000..b03dab7c --- /dev/null +++ b/labs/docker-lan/docker-compose.yml @@ -0,0 +1,109 @@ +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.0 + 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 + ports: + - 5000:5000 #http://localhost:5000/v2/_catalog + volumes: + - ./data/registry:/var/lib/registry + gitea: # init with ip:port https://docs.gitea.io/en-us/install-with-docker + image: gitea/gitea:1.14.2 + restart: always + networks: + - default + environment: + - USER_UID=1000 + - USER_GID=1000 + ports: + - ${GITEA_HTTP_PORT}:3000 + - ${GITEA_SSH_PORT}:22 + volumes: + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + - ./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 + - ${DRONE_SERVER_HTTPS_PORT}: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} + volumes: + - ./data/drone:/data + depends_on: + - gitea + 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=${IP}:${DRONE_SERVER_HTTP_PORT} + - 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 + # 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 diff --git a/labs/docker-lan/start.sh b/labs/docker-lan/start.sh new file mode 100644 index 00000000..89a79643 --- /dev/null +++ b/labs/docker-lan/start.sh @@ -0,0 +1 @@ +docker-compose up --remove-orphans -d \ No newline at end of file diff --git a/labs/docker-lan/stop.sh b/labs/docker-lan/stop.sh new file mode 100644 index 00000000..356959e4 --- /dev/null +++ b/labs/docker-lan/stop.sh @@ -0,0 +1 @@ +docker-compose down --remove-orphans \ No newline at end of file