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

编写docker-compose.yml文件

bash 复制代码
version: "3"
services: 
  redis:
      image: docker.dragonflydb.io/dragonflydb/dragonfly:latest
      # command: --requirepass=dalong
      ports:
      - 6379:6379
      - 11211:11211
  joke: 
     image: dalongrong/godns:joke
     build: 
      context: ./
      dockerfile: ./Dockerfile-joke
     ports: 
     - "1223:1223"
  godns: 
     image: dalongrong/godns
     build: 
      context: ./
      dockerfile: ./Dockerfile-godns
     ports: 
     - "53:53/udp"
     - "53:53/tcp"

相关Dockerfile文件

1. godns dockerfile

基于golang的supervisord进行管理

bash 复制代码
FROM golang:1.13-alpine AS build-env
WORKDIR /go/src/app
RUN  /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories
​
ENV  GO111MODULE=on
ENV  GOPROXY=https://goproxy.cn
COPY code/godns/ .
RUN apk update && apk add git \
    && go build
​
FROM alpine:latest
WORKDIR /app
RUN  /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
COPY --from=ochinchina/supervisord:latest /usr/local/bin/supervisord /usr/local/bin/supervisord
COPY --from=build-env /go/src/app/godns /app/godns
COPY supervisor-godns.conf /etc/supervisord.conf
COPY godns.conf /etc/godns.conf
​
EXPOSE 53/udp 53 9001
CMD ["/usr/local/bin/supervisord"]

2. joke dockerfile

bash 复制代码
FROM golang:1.13-alpine AS build-env
WORKDIR /go/src/app
RUN  /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories
ENV  GO111MODULE=on
ENV  GOPROXY=https://goproxy.cn
COPY code/joke/ .
RUN apk update && apk add git \
    && go build
​
FROM alpine:latest
WORKDIR /app
RUN  /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
COPY --from=ochinchina/supervisord:latest /usr/local/bin/supervisord /usr/local/bin/supervisord
COPY --from=build-env /go/src/app/joke /app/joke
COPY --from=build-env /go/src/app/static /app/static
COPY --from=build-env /go/src/app/views /app/views
COPY supervisor-joke.conf /etc/supervisord.conf
COPY joke.conf /etc/joke.conf
EXPOSE 1223 9001
CMD ["/usr/local/bin/supervisord"]

3. godns 配置

bash 复制代码
#Toml config file
​
​
Title = "GODNS"
Version = "0.1.2"
Author = "kenshin"
​
Debug = false
​
[server]
host = "0.0.0.0"
port = 53
​
[resolv]
# Domain-specific nameservers configuration, formatting keep compatible with Dnsmasq
# Semicolon separate multiple files.
#server-list-file = "./etc/apple.china.conf;./etc/google.china.conf"
resolv-file = "/etc/resolv.conf"
timeout = 5  # 5 seconds
# The concurrency interval request upstream recursive server
# Match the PR15, https://github.com/kenshinx/godns/pull/15
interval = 200 # 200 milliseconds
​
setedns0 = false #Support for larger UDP DNS responses
​
[redis]
enable = true
host = "redis"
port = 6379
db = 0
password =""
​
[memcache]
servers = ["127.0.0.1:11211"]
​
[log]
stdout = true
level = "INFO"  #DEBUG | INFO |NOTICE | WARN | ERROR  
​
​
​
[cache]
# backend option [memory|memcache|redis]  
backend = "redis"  
expire = 600  # 10 minutes
maxcount = 0 #If set zero. The Sum of cache itmes will be unlimit.
​
[hosts]
#If set false, will not query hosts file and redis hosts record
enable = true
host-file = "/etc/hosts"
redis-enable = true
redis-key = "godns:hosts"
ttl = 600
refresh-interval = 5 # 5 seconds

4. joke 配置

bash 复制代码
#[beego]
appname = Joke
httpaddr = "0.0.0.0"
httpport = 1223
runmode = "dev"
autorender = true
autorecover = true
viewspath = "views"
​
​
#[auth]
#username:password.
#basic_auth = "joke:hello"
​
​
#[redis]
redisaddr = "redis:6379"
redisdb = 0
redispassword = ""
bindkey = "godns:hosts"
​
​
​
#[log]
stdout = true
logfile = "logs/joke.log"
logrorate = true

5. supervidord 配置

bash 复制代码
[program:godns]
command =/app/godns -c /etc/godns.conf
​
[inet_http_server]
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

相关推荐
枫叶丹46 分钟前
【在Linux世界中追寻伟大的One Piece】多线程(一)
java·linux·运维
残念ing7 分钟前
【Linux】—简单实现一个shell(myshell)
linux·运维·服务器
明月心95215 分钟前
linux mount nfs开机自动挂载远程目录
linux·运维·服务器
Ray550521 分钟前
bridge-multicast-igmpsnooping
linux·服务器·网络
库库的里昂1 小时前
Linux系统Docker部署开源在线协作笔记Trilium Notes与远程访问详细教程
linux·运维·docker·开源
在下不上天1 小时前
flume-将日志采集到hdfs
大数据·linux·运维·hadoop·hdfs·flume
mit6.8242 小时前
[Redis#3] 通用命令 | 数据类型 | 内部编码 | 单线程 | 快的原因
linux·redis·分布式
^Lim2 小时前
esp32 JTAG 串口 bootload升级
java·linux·网络
小林熬夜学编程2 小时前
【Linux系统编程】第五十弹---构建高效单例模式线程池、详解线程安全与可重入性、解析死锁与避免策略,以及STL与智能指针的线程安全性探究
linux·运维·服务器·c语言·c++·安全·单例模式
玖玖玖 柒染2 小时前
windows下sqlplus连接到linux oracle不成功
linux·windows·oracle