-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Use ENV for configuration of what to do with clouddns-sync. - Use an entrypoint.sh to properly run things. - Explicit release naming in dockerfile.
- Loading branch information
1 parent
2c5ca0a
commit 6c8c854
Showing
2 changed files
with
61 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
FROM golang:1.21 | ||
RUN go install github.com/gerrowadat/clouddns-sync@0.0.6 | ||
|
||
WORKDIR /app | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
COPY *.go ./ | ||
COPY entrypoint.sh / | ||
RUN chmod +x /entrypoint.sh | ||
|
||
# Build | ||
RUN CGO_ENABLED=0 GOOS=linux go build -o /clouddns-sync | ||
USER root | ||
|
||
# Interval between runs. | ||
ENV GCLOUD_DNS_INTERVAL_SECS=86400 | ||
|
||
# gcloud specifiers | ||
ENV GCLOUD_VERB "dynrecord" | ||
ENV GCLOUD_DNS_ZONE "" | ||
ENV GCLOUD_DYN_RECORD_NAME "" | ||
|
||
# nomad specifiers | ||
ENV NOMAD_SERVER_URI "" | ||
ENV NOMAD_TOKEN_FILE "" | ||
|
||
# json credentials file location | ||
ENV JSON_KEYFILE "" | ||
|
||
# zonefile location | ||
ENV ZONEFILENAME "" | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] | ||
CMD ["/entrypoint.sh"] | ||
|
||
# Run | ||
ENTRYPOINT ["/clouddns-sync"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/bash | ||
|
||
set -e | ||
|
||
while true | ||
do | ||
echo "Doing $GCLOUD_VERB for zone $GCLOUD_DNS_ZONE" | ||
|
||
case $GCLOUD_VERB in | ||
nomad_sync) | ||
clouddns-sync \ | ||
--cloud-dns-zone=$GCLOUD_DNS_ZONE \ | ||
--json-keyfile=$JSON_KEYFILE \ | ||
--nomad-server-uri=$NOMAD_SERVER_URI \ | ||
--nomad-token_file=$NOMAD_TOKEN_FILE \ | ||
$GCLOUD_VERB | ||
;; | ||
getzonefile | putzonefile) | ||
clouddns-sync \ | ||
--cloud-dns-zone=$GCLOUD_DNS_ZONE \ | ||
--json-keyfile=$JSON_KEYFILE \ | ||
-zonefilename=$ZONEFILENAME \ | ||
$GCLOUD_VERB | ||
;; | ||
dynrecord) | ||
clouddns-sync \ | ||
--cloud-dns-zone=$GCLOUD_DNS_ZONE \ | ||
--cloud-dns-dyn-record-name=$GCLOUD_DYN_RECORD_NAME \ | ||
--json-keyfile=$JSON_KEYFILE \ | ||
$GCLOUD_VERB | ||
;; | ||
esac | ||
|
||
echo "Sleeping for $GCLOUD_DNS_INTERVAL_SECS seconds..." | ||
sleep $GCLOUD_DNS_INTERVAL_SECS | ||
done |