Skip to content

Commit

Permalink
use pinned caddy version, add cf dns
Browse files Browse the repository at this point in the history
  • Loading branch information
yapishu committed Nov 25, 2022
1 parent a763087 commit 131b7ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
2 changes: 0 additions & 2 deletions api/np_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ def rectify_svc_list(pubkey):
upstr = services[subd]
if caddy_api.check_upstream(subd,upstr) == False:
caddy_api.add_reverse_proxy(subd, host=f'{root_domain}',upstream=upstr)
sleep(3)

# Delete pubkeys that aren't registered
for peer in peerlist:
Expand All @@ -311,7 +310,6 @@ def rectify_svc_list(pubkey):
upstr = minios[subd]
if caddy_api.check_upstream(subd,upstr) == False:
caddy_api.add_minio(subd, host=f'{root_domain}',upstream=upstr)
sleep(3)

# Rectify port forwarding configurations
# Add a 'tcp' key for TCP services
Expand Down
24 changes: 7 additions & 17 deletions caddy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
# Build Caddy from master until 2.6 release
FROM golang:1.19.1-alpine3.16 as builder
WORKDIR /
RUN apk add --no-cache git
RUN git clone https://github.com/caddyserver/caddy.git
WORKDIR /caddy/cmd/caddy/
RUN go build

FROM caddy:2-alpine
WORKDIR /
RUN rm /usr/bin/caddy
COPY --from=builder /caddy/cmd/caddy/caddy /usr/bin/caddy
RUN chmod +x /usr/bin/caddy
RUN apk add --no-cache libcap curl
RUN setcap 'cap_net_bind_service=+ep' /usr/bin/caddy
FROM caddy:2.6.2-builder-alpine@sha256:735ad7b9a5ba5baf3df5f93034af5fa90c3554da9725d260df238d2511be6b23 AS builder
RUN xcaddy build \
--with github.com/caddy-dns/cloudflare@latest
FROM caddy:2.6-alpine@sha256:7992b931b7da3cf0840dd69ea74b2c67d423faf03408da8abdc31b7590a239a7
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
COPY ./default_config.json /etc/caddy/
COPY ./www/502.html /www/
RUN apk add curl
RUN echo "#!/bin/ash" > /init
RUN echo "ip route add 10.13.13.0/24 via 172.20.0.2" >> /init
RUN echo "exec caddy run --config /etc/caddy/default_config.json --resume" >> /init
RUN echo "exec /usr/bin/caddy run --config /etc/caddy/default_config.json --resume" >> /init
RUN chmod +x /init
EXPOSE 80
EXPOSE 443
Expand Down

0 comments on commit 131b7ea

Please sign in to comment.