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

编写docker-compose.yml文件

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进行管理

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

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 配置

#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 配置

#[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 配置 

[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

 

相关推荐

  1. 深入理解Dockerfile ——

    2024-03-16 20:56:06       55 阅读
  2. ffmpeg静态编译 ——

    2024-03-16 20:56:06       71 阅读
  3. LVM逻辑卷管理快照 ——

    2024-03-16 20:56:06       29 阅读
  4. ansible crontab任务管理 ——

    2024-03-16 20:56:06       36 阅读
  5. linux 常用脚本搜集(nginx) ——

    2024-03-16 20:56:06       59 阅读
  6. kafka处理大量消息积压tips ——

    2024-03-16 20:56:06       61 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-16 20:56:06       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-16 20:56:06       106 阅读
  3. 在Django里面运行非项目文件

    2024-03-16 20:56:06       87 阅读
  4. Python语言-面向对象

    2024-03-16 20:56:06       96 阅读

热门阅读

  1. xxl-job

    xxl-job

    2024-03-16 20:56:06      39 阅读
  2. 小程序配置服务器域名

    2024-03-16 20:56:06       38 阅读
  3. 简单了解跨域问题如何解决

    2024-03-16 20:56:06       46 阅读
  4. Qt内存管理与对象树:正确管理控件内存的关键

    2024-03-16 20:56:06       43 阅读
  5. Linux运维_Bash脚本_编译安装Glibc-2.38

    2024-03-16 20:56:06       35 阅读
  6. GlusterFS分布式文件系统群集

    2024-03-16 20:56:06       41 阅读
  7. 机器人学习书籍

    2024-03-16 20:56:06       43 阅读
  8. 大语言模型(LLM)过拟合问题

    2024-03-16 20:56:06       39 阅读
  9. 两台 CentOS 之间传数据:SCP 方式

    2024-03-16 20:56:06       42 阅读