-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39e8da9
commit c483044
Showing
6 changed files
with
66 additions
and
47 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,37 +1,42 @@ | ||
version: 2.1 | ||
|
||
version: 2 | ||
jobs: | ||
build: | ||
environment: | ||
IMAGE_NAME: wastrachan/gandi-ddns | ||
IMAGE_VERSION: "1.2" | ||
TAG: "1.2" | ||
|
||
docker: | ||
- image: cimg/base:current | ||
resource_class: large | ||
steps: | ||
- checkout | ||
|
||
- setup_remote_docker: | ||
docker_layer_caching: true | ||
|
||
- run: | ||
name: Build image | ||
command: | | ||
docker build -t $IMAGE_NAME . | ||
docker tag $IMAGE_NAME $IMAGE_NAME:latest | ||
docker tag $IMAGE_NAME $IMAGE_NAME:$IMAGE_VERSION | ||
make build | ||
docker tag wastrachan/gandi-ddns:latest wastrachan/gandi-ddns:$TAG | ||
docker tag wastrachan/gandi-ddns:latest ghcr.io/wastrachan/gandi-ddns:latest | ||
docker tag wastrachan/gandi-ddns:latest ghcr.io/wastrachan/gandi-ddns:$TAG | ||
- run: | ||
name: Publish image | ||
command: | | ||
if [ "${CIRCLE_BRANCH}" == "master" ]; then | ||
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin | ||
docker push $IMAGE_NAME:latest | ||
docker push $IMAGE_NAME:$IMAGE_VERSION | ||
fi | ||
echo "$DOCKERHUB_PASS" | docker login --username $DOCKERHUB_USERNAME --password-stdin | ||
echo "$GITHUB_PAT" | docker login ghcr.io -u $GITHUB_USERNAME --password-stdin | ||
docker push wastrachan/gandi-ddns:latest | ||
docker push wastrachan/gandi-ddns:$TAG | ||
docker push ghcr.io/wastrachan/gandi-ddns:latest | ||
docker push ghcr.io/wastrachan/gandi-ddns:$TAG | ||
workflows: | ||
version: 2 | ||
commit: | ||
jobs: | ||
- build: | ||
context: Docker | ||
filters: | ||
branches: | ||
only: master |
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,2 +1 @@ | ||
config/ | ||
*.img |
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
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,46 +1,46 @@ | ||
# Gandi DDNS Docker Image | ||
|
||
.PHONY: help | ||
help: | ||
@echo "" | ||
@echo "Usage: make COMMAND" | ||
@echo "" | ||
@echo "Gandi Dynamic DNS Makefile" | ||
@echo "Docker gandi-ddns image makefile" | ||
@echo "" | ||
@echo "Commands:" | ||
@echo " build Build and tag image" | ||
@echo " push Push tagged image to registry" | ||
@echo " run Start container in the background with locally mounted volume" | ||
@echo " tail Tail logs from running docker container" | ||
@echo " stop Stop and remove container running in the background" | ||
@echo " clean Mark image for rebuild" | ||
@echo " delete Delete image and mark for rebuild" | ||
@echo " delete Delete all built image versions" | ||
@echo "" | ||
|
||
build: .gandi-ddns.img | ||
IMAGE=wastrachan/gandi-ddns | ||
TAG=latest | ||
REGISTRY=docker.io | ||
|
||
.PHONY: build | ||
build: | ||
@docker build -t ${REGISTRY}/${IMAGE}:${TAG} . | ||
|
||
.gandi-ddns.img: | ||
docker build -t wastrachan/gandi-ddns:latest . | ||
@touch $@ | ||
.PHONY: push | ||
push: | ||
@docker push ${REGISTRY}/${IMAGE}:${TAG} | ||
|
||
.PHONY: run | ||
run: build | ||
docker run \ | ||
--name gandi-ddns \ | ||
-d --restart unless-stopped \ | ||
-e GANDI_KEY="12343123abcd" \ | ||
-e GANDI_DOMAIN="mydomain.net" \ | ||
wastrachan/gandi-ddns:latest | ||
|
||
.PHONY: tail | ||
tail: | ||
docker logs -f gandi-ddns | ||
docker run -v "$(CURDIR)/config:/config" \ | ||
--name gandi-ddns \ | ||
--rm \ | ||
-e GANDI_KEY="12343123abcd" \ | ||
-e GANDI_DOMAIN="mydomain.net" \ | ||
-d \ | ||
${REGISTRY}/${IMAGE}:${TAG} | ||
|
||
.PHONY: stop | ||
stop: | ||
docker stop gandi-ddns | ||
docker rm gandi-ddns | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f .gandi-ddns.img | ||
@docker stop gandi-ddns | ||
|
||
.PHONY: delete | ||
delete: clean | ||
docker rmi -f wastrachan/gandi-ddns | ||
delete: | ||
@docker image ls | grep ${IMAGE} | awk '{print $$3}' | xargs -I + docker rmi + |
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
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,8 +1,15 @@ | ||
#!/usr/bin/env sh | ||
set -e | ||
|
||
# Generate CRON entry | ||
echo "" | ||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | ||
echo " Starting gandi-ddns..." | ||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | ||
echo "" | ||
|
||
echo " [+] Creating CRON entry..." | ||
echo "${UPDATE_SCHEDULE:-"*/5 * * * *"} python /gandi-ddns.py" > /etc/crontabs/root | ||
|
||
# Exec CMD | ||
echo " [+] Running..." | ||
echo "" | ||
exec "$@" |