Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
FROM golang:1.22
FROM golang:1.23 AS compile

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 . .
RUN go build -v -o /usr/local/bin/app ./...
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /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 .

CMD ["app"]
ENTRYPOINT ["/app"]
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# 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 ;)

![cloudflare-dynamic-dns](https://github.com/mxmlndml/cloudflare-dynamic-dns/assets/42516330/fc6e7c3e-eb96-4fdf-924e-cf86dab70b4b)

This Docker container offers a straightforward and efficient solution for
Expand All @@ -24,7 +31,7 @@ pulling the pre-built Docker container and running it with the necessary
environment variables

```sh
docker run -d -e API_KEY=123 -e ZONE_ID=023e105f4ecef8ad9ca31a8372d0c353 -e DOMAIN_NAMES=example.com,*.example.com 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` and `.env.template` from this repository into an
Expand Down Expand Up @@ -64,3 +71,5 @@ breakdown of the available configuration variables:
- **`INTERVAL`** _defaults to `5`_
\
Time interval in minutes between DNS updates

[1]: github.com/mxmlndml/cloudflare-dynamic-dns
9 changes: 5 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
services:
cloudflare-dynamic-dns:
image: mxmlndml/cloudflare-dynamic-dns:latest
image: chaussebenjamin/cloudflare-dynamic-dns:latest
environment:
- "API_KEY=${API_KEY}"
- "ZONE_ID=${ZONE_ID}"
- "DOMAIN_NAMES=example.com,dyndns.example.com"
- API_KEY=${API_KEY}
- ZONE_ID=${ZONE_ID}
- DOMAIN_NAMES=example.com,dyndns.example.com
# - "RECORD_TYPES=A"
# - "INTERVAL=5"
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package main

import (
_ "embed"
"fmt"
"log"
"strings"
"sync"
"time"
)

//go:embed title.txt
var appNameASCII string

type publicIP struct {
v4 string
v6 string
Expand Down Expand Up @@ -60,11 +64,7 @@ func getDNSRecords() []DNSRecords {
}

func initialize() {
fmt.Println(" _______ _______ ___ _ ___ _ ______")
fmt.Println(" / ___/ /__ __ _____/ / _/ /__ ________ / _ \\__ _____ ___ ___ _ (_)___ / _ \\/ |/ / __/")
fmt.Println("/ /__/ / _ \\/ // / _ / _/ / _ `/ __/ -_) / // / // / _ \\/ _ `/ ' \\/ / __/ / // / /\\ \\ ")
fmt.Println("\\___/_/\\___/\\_,_/\\_,_/_//_/\\_,_/_/ \\__/ /____/\\_, /_//_/\\_,_/_/_/_/_/\\__/ /____/_/|_/___/ ")
fmt.Println(" /___/ ")
fmt.Print(appNameASCII)

var recordType string
if UseIPv4() && UseIPv6() {
Expand Down
5 changes: 5 additions & 0 deletions title.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_______ _______ ___ _ ___ _ ______
/ ___/ /__ __ _____/ / _/ /__ ________ / _ \__ _____ ___ ___ _ (_)___ / _ \/ |/ / __/
/ /__/ / _ \/ // / _ / _/ / _ `/ __/ -_) / // / // / _ \/ _ `/ ' \/ / __/ / // / /\ \
\___/_/\___/\_,_/\_,_/_//_/\_,_/_/ \__/ /____/\_, /_//_/\_,_/_/_/_/_/\__/ /____/_/|_/___/
/___/