Skip to content

Commit

Permalink
refactor: publish to ghcr.io
Browse files Browse the repository at this point in the history
  • Loading branch information
wastrachan committed Mar 21, 2024
1 parent 39e8da9 commit c483044
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 47 deletions.
29 changes: 17 additions & 12 deletions .circleci/config.yml
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
config/
*.img
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ FROM python:3.12-alpine

LABEL org.opencontainers.image.title="Gandi DDNS"
LABEL org.opencontainers.image.description="Dynamic DNS Update Client for Gandi's LiveDNS"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.authors="Winston Astrachan"
LABEL org.opencontainers.image.source="https://github.com/wastrachan/docker-gandi-ddns/"
LABEL org.opencontainers.image.licenses="MIT"

COPY app/ /
RUN pip install -r /requirements.txt
RUN set -eux; \
pip install -r /requirements.txt

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["crond", "-f", "-c", "/etc/crontabs/"]
52 changes: 26 additions & 26 deletions Makefile
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 +
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ Pull the latest image from Docker Hub:
docker pull wastrachan/gandi-ddns
```

#### Manually
#### Github Container Registry

Or, pull from the GitHub Container Registry:

```shell
docker pull ghcr.io/wastrachan/gandi-ddns
```

#### Build From Source

Clone this repository, and run `make build` to build an image:

Expand All @@ -25,8 +33,6 @@ cd gandi-ddns
make build
```

If you need to rebuild the image, run `make clean build`.

## Run

#### Docker
Expand All @@ -35,9 +41,9 @@ Run this image with the `make run` shortcut, or manually with `docker run`. You'

```shell
docker run --name gandi-ddns \
--rm \
-e GANDI_KEY="12343123abcd" \
-e GANDI_DOMAIN="mydomain.net" \
--restart unless-stopped \
wastrachan/gandi-ddns:latest
```

Expand Down
11 changes: 9 additions & 2 deletions app/docker-entrypoint.sh
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 "$@"

0 comments on commit c483044

Please sign in to comment.