当前位置:   article > 正文

DragonflyDB 作为GoDNS存储 —— 筑梦之路

DragonflyDB 作为GoDNS存储 —— 筑梦之路

编写docker-compose.yml文件

  1. version: "3"
  2. services:
  3. redis:
  4. image: docker.dragonflydb.io/dragonflydb/dragonfly:latest
  5. # command: --requirepass=dalong
  6. ports:
  7. - 6379:6379
  8. - 11211:11211
  9. joke:
  10. image: dalongrong/godns:joke
  11. build:
  12. context: ./
  13. dockerfile: ./Dockerfile-joke
  14. ports:
  15. - "1223:1223"
  16. godns:
  17. image: dalongrong/godns
  18. build:
  19. context: ./
  20. dockerfile: ./Dockerfile-godns
  21. ports:
  22. - "53:53/udp"
  23. - "53:53/tcp"

相关Dockerfile文件

 1. godns dockerfile 

基于golang的supervisord进行管理

  1. FROM golang:1.13-alpine AS build-env
  2. WORKDIR /go/src/app
  3. RUN /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories
  4. ENV GO111MODULE=on
  5. ENV GOPROXY=https://goproxy.cn
  6. COPY code/godns/ .
  7. RUN apk update && apk add git \
  8. && go build
  9. FROM alpine:latest
  10. WORKDIR /app
  11. RUN /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories
  12. RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
  13. COPY --from=ochinchina/supervisord:latest /usr/local/bin/supervisord /usr/local/bin/supervisord
  14. COPY --from=build-env /go/src/app/godns /app/godns
  15. COPY supervisor-godns.conf /etc/supervisord.conf
  16. COPY godns.conf /etc/godns.conf
  17. EXPOSE 53/udp 53 9001
  18. CMD ["/usr/local/bin/supervisord"]

2. joke dockerfile

  1. FROM golang:1.13-alpine AS build-env
  2. WORKDIR /go/src/app
  3. RUN /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories
  4. ENV GO111MODULE=on
  5. ENV GOPROXY=https://goproxy.cn
  6. COPY code/joke/ .
  7. RUN apk update && apk add git \
  8. && go build
  9. FROM alpine:latest
  10. WORKDIR /app
  11. RUN /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories
  12. RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
  13. COPY --from=ochinchina/supervisord:latest /usr/local/bin/supervisord /usr/local/bin/supervisord
  14. COPY --from=build-env /go/src/app/joke /app/joke
  15. COPY --from=build-env /go/src/app/static /app/static
  16. COPY --from=build-env /go/src/app/views /app/views
  17. COPY supervisor-joke.conf /etc/supervisord.conf
  18. COPY joke.conf /etc/joke.conf
  19. EXPOSE 1223 9001
  20. CMD ["/usr/local/bin/supervisord"]

3. godns 配置

  1. #Toml config file
  2. Title = "GODNS"
  3. Version = "0.1.2"
  4. Author = "kenshin"
  5. Debug = false
  6. [server]
  7. host = "0.0.0.0"
  8. port = 53
  9. [resolv]
  10. # Domain-specific nameservers configuration, formatting keep compatible with Dnsmasq
  11. # Semicolon separate multiple files.
  12. #server-list-file = "./etc/apple.china.conf;./etc/google.china.conf"
  13. resolv-file = "/etc/resolv.conf"
  14. timeout = 5 # 5 seconds
  15. # The concurrency interval request upstream recursive server
  16. # Match the PR15, https://github.com/kenshinx/godns/pull/15
  17. interval = 200 # 200 milliseconds
  18. setedns0 = false #Support for larger UDP DNS responses
  19. [redis]
  20. enable = true
  21. host = "redis"
  22. port = 6379
  23. db = 0
  24. password =""
  25. [memcache]
  26. servers = ["127.0.0.1:11211"]
  27. [log]
  28. stdout = true
  29. level = "INFO" #DEBUG | INFO |NOTICE | WARN | ERROR
  30. [cache]
  31. # backend option [memory|memcache|redis]
  32. backend = "redis"
  33. expire = 600 # 10 minutes
  34. maxcount = 0 #If set zero. The Sum of cache itmes will be unlimit.
  35. [hosts]
  36. #If set false, will not query hosts file and redis hosts record
  37. enable = true
  38. host-file = "/etc/hosts"
  39. redis-enable = true
  40. redis-key = "godns:hosts"
  41. ttl = 600
  42. refresh-interval = 5 # 5 seconds

4. joke 配置

  1. #[beego]
  2. appname = Joke
  3. httpaddr = "0.0.0.0"
  4. httpport = 1223
  5. runmode = "dev"
  6. autorender = true
  7. autorecover = true
  8. viewspath = "views"
  9. #[auth]
  10. #username:password.
  11. #basic_auth = "joke:hello"
  12. #[redis]
  13. redisaddr = "redis:6379"
  14. redisdb = 0
  15. redispassword = ""
  16. bindkey = "godns:hosts"
  17. #[log]
  18. stdout = true
  19. logfile = "logs/joke.log"
  20. logrorate = true

5. supervidord 配置 

  1. [program:godns]
  2. command =/app/godns -c /etc/godns.conf
  3. [inet_http_server]
  4. port = :9001

参考资料:

GitHub - rongfengliang/godns-joke-learning: godns-joke-learning 
GitHub - kenshinx/godns: A fast dns cache server written by go 
https://github.com/kenshinx/joke 
https://www.cnblogs.com/rongfengliang/p/11498598.html 
GitHub - coredns/coredns: CoreDNS is a DNS server that chains plugins

https://www.cnblogs.com/rongfengliang/p/13200197.html

https://www.cnblogs.com/rongfengliang/p/16974556.html

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/247816
推荐阅读
相关标签
  

闽ICP备14008679号