Compare commits
8 Commits
v2.0.2
...
ChausseBen
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8203405eba | ||
|
|
fa82a09f03 | ||
|
|
db2a6d765f | ||
|
|
91c1fc362a | ||
|
|
6ee9d3f8fd | ||
|
|
ce8e3e3a90 | ||
|
|
aaeab750b6 | ||
|
|
f83ca10008 |
20
Dockerfile
20
Dockerfile
@@ -1,12 +1,18 @@
|
|||||||
FROM golang:1.22
|
FROM golang:1.23 AS compile
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
|
|
||||||
# COPY go.mod go.sum ./
|
|
||||||
# RUN go mod download && go mod verify
|
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN go build -v -o /usr/local/bin/app ./...
|
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /app ./...
|
||||||
|
|
||||||
CMD ["app"]
|
FROM alpine:latest AS compressor
|
||||||
|
RUN apk add --no-cache upx
|
||||||
|
COPY --from=compile /app /app
|
||||||
|
RUN upx --best /app
|
||||||
|
|
||||||
|
FROM scratch AS service
|
||||||
|
|
||||||
|
COPY --from=compile /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
|
COPY --from=compressor /app .
|
||||||
|
|
||||||
|
ENTRYPOINT ["/app"]
|
||||||
|
|||||||
29
README.md
29
README.md
@@ -1,6 +1,13 @@
|
|||||||
# Dynamic DNS Updates with Cloudflare
|
# Dynamic DNS Updates with Cloudflare
|
||||||
|
|
||||||

|
> [!NOTE]
|
||||||
|
> This program was originally written by [mxmlndml]. This fork merely
|
||||||
|
> optimizes the docker image with better (more optimized) compiles flags
|
||||||
|
> and strips out the entire Go runtime from the final image (making the final
|
||||||
|
> image <3MB instead of ~900MB). Go thank him for his work developing this, not
|
||||||
|
> me ;)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
This Docker container offers a straightforward and efficient solution for
|
This Docker container offers a straightforward and efficient solution for
|
||||||
automating dynamic DNS updates using the Cloudflare DNS service. It empowers you
|
automating dynamic DNS updates using the Cloudflare DNS service. It empowers you
|
||||||
@@ -24,11 +31,11 @@ pulling the pre-built Docker container and running it with the necessary
|
|||||||
environment variables
|
environment variables
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker run -d -e API_KEY=123 -e ZONE_ID=023e105f4ecef8ad9ca31a8372d0c353 -e DOMAIN_NAMES=dyndns.example.com,example.com --restart=always mxmlndml/cloudflare-dynamic-dns
|
docker run -d -e API_KEY=123 -e ZONE_ID=023e105f4ecef8ad9ca31a8372d0c353 -e DOMAIN_NAMES=example.com,*.example.com chaussebenjamin/cloudflare-dynamic-dns
|
||||||
```
|
```
|
||||||
|
|
||||||
Alternatively you can copy the `docker-compose.yml` from this repository into an
|
Alternatively you can copy the `docker-compose.yml` and `.env.template` from this repository into an
|
||||||
empty directory of your machine, edit the environment variables and start the
|
empty directory of your machine, rename the `.env.template` to `.env`, edit the environment variables in both files and start the
|
||||||
container with `docker compose`
|
container with `docker compose`
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -52,9 +59,17 @@ breakdown of the available configuration variables:
|
|||||||
\
|
\
|
||||||
List of DNS A records that should store your public IP address delimited by a
|
List of DNS A records that should store your public IP address delimited by a
|
||||||
comma (and only a comma)
|
comma (and only a comma)
|
||||||
|
- **`RECORD_TYPES`** _defaults to `A`_
|
||||||
|
\
|
||||||
|
Whether A and/or AAAA records should be updated
|
||||||
|
\
|
||||||
|
`A`: updates only A records
|
||||||
|
\
|
||||||
|
`AAAA`: updates only AAAA records
|
||||||
|
\
|
||||||
|
`*`: updates both A and AAAA records
|
||||||
- **`INTERVAL`** _defaults to `5`_
|
- **`INTERVAL`** _defaults to `5`_
|
||||||
\
|
\
|
||||||
Time interval in minutes between DNS updates
|
Time interval in minutes between DNS updates
|
||||||
- **`LOG_LEVEL`** _defaults to `INFO`_
|
|
||||||
\
|
[1]: github.com/mxmlndml/cloudflare-dynamic-dns
|
||||||
Logging level for the container, either `DEBUG`, `INFO`, `WARN` or `ERROR`
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
|
---
|
||||||
services:
|
services:
|
||||||
cloudflare-dynamic-dns:
|
cloudflare-dynamic-dns:
|
||||||
image: mxmlndml/cloudflare-dynamic-dns:latest
|
image: chaussebenjamin/cloudflare-dynamic-dns:latest
|
||||||
environment:
|
environment:
|
||||||
- "API_KEY=${API_KEY}"
|
- API_KEY=${API_KEY}
|
||||||
- "ZONE_ID=${ZONE_ID}"
|
- ZONE_ID=${ZONE_ID}
|
||||||
- "DOMAIN_NAMES=example.com,dyndns.example.com"
|
- DOMAIN_NAMES=example.com,dyndns.example.com
|
||||||
# - "RECORD_TYPES=A"
|
# - "RECORD_TYPES=A"
|
||||||
# - "INTERVAL=5"
|
# - "INTERVAL=5"
|
||||||
|
|||||||
10
main.go
10
main.go
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -8,6 +9,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:embed title.txt
|
||||||
|
var appNameASCII string
|
||||||
|
|
||||||
type publicIP struct {
|
type publicIP struct {
|
||||||
v4 string
|
v4 string
|
||||||
v6 string
|
v6 string
|
||||||
@@ -60,11 +64,7 @@ func getDNSRecords() []DNSRecords {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func initialize() {
|
func initialize() {
|
||||||
fmt.Println(" _______ _______ ___ _ ___ _ ______")
|
fmt.Print(appNameASCII)
|
||||||
fmt.Println(" / ___/ /__ __ _____/ / _/ /__ ________ / _ \\__ _____ ___ ___ _ (_)___ / _ \\/ |/ / __/")
|
|
||||||
fmt.Println("/ /__/ / _ \\/ // / _ / _/ / _ `/ __/ -_) / // / // / _ \\/ _ `/ ' \\/ / __/ / // / /\\ \\ ")
|
|
||||||
fmt.Println("\\___/_/\\___/\\_,_/\\_,_/_//_/\\_,_/_/ \\__/ /____/\\_, /_//_/\\_,_/_/_/_/_/\\__/ /____/_/|_/___/ ")
|
|
||||||
fmt.Println(" /___/ ")
|
|
||||||
|
|
||||||
var recordType string
|
var recordType string
|
||||||
if UseIPv4() && UseIPv6() {
|
if UseIPv4() && UseIPv6() {
|
||||||
|
|||||||
5
title.txt
Normal file
5
title.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
_______ _______ ___ _ ___ _ ______
|
||||||
|
/ ___/ /__ __ _____/ / _/ /__ ________ / _ \__ _____ ___ ___ _ (_)___ / _ \/ |/ / __/
|
||||||
|
/ /__/ / _ \/ // / _ / _/ / _ `/ __/ -_) / // / // / _ \/ _ `/ ' \/ / __/ / // / /\ \
|
||||||
|
\___/_/\___/\_,_/\_,_/_//_/\_,_/_/ \__/ /____/\_, /_//_/\_,_/_/_/_/_/\__/ /____/_/|_/___/
|
||||||
|
/___/
|
||||||
Reference in New Issue
Block a user