Skip to content

Commit ef23899

Browse files
committed
Added Dockerfile and setup build
The Dockerfile is now setup and wired into the Travis deploy process.
1 parent e9f45b2 commit ef23899

File tree

5 files changed

+72
-18
lines changed

5 files changed

+72
-18
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
.vscode
22
*.deb
3+
bin/
4+
debug*
5+
go-*
6+
config.json

Dockerfile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM alpine:latest
2+
LABEL version="0.1.0"
3+
LABEL description="Docker image for running go-cddns application"
4+
LABEL maintainer="Nick Robison [email protected]"
5+
6+
# Setup the necessary SSL certs
7+
RUN apk update \
8+
&& apk upgrade \
9+
&& apk add --no-cache \
10+
ca-certificates \
11+
&& update-ca-certificates 2>/dev/null || true
12+
13+
# Add the go binary and config files
14+
COPY bin/go-cddns*_amd64 /app/go-cddns
15+
WORKDIR /app
16+
CMD ["./go-cddns", "--config=/etc/config.json"]

Makefile

+20-18
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ VERSION := 0.1.0
22
PKGNAME := go-cddns
33
LICENSE := MIT
44
URL := https://github.com/nickrobison/go-cddns
5-
RELEASE := 1
5+
RELEASE := 2
66
USER := cddns
77
DESC := Dynamic DNS client for Cloudflare
88
MAINTAINER := Nick Robison <[email protected]>
@@ -33,42 +33,44 @@ test:
3333
all: $(PLATFORMS)
3434

3535
$(PLATFORMS):
36-
GOOS=$(os) GOARCH=$(arch) go build -o 'bin/go-cddns_0.1.0_$(arch)' .
37-
36+
GOOS=$(os) GOARCH=$(arch) go build -o 'bin/go-cddns_${VERSION}_$(arch)' .
3837

3938
clean:
4039
-rm -rf bin/
4140
-rm go-cddns
4241
-rm *.deb
4342
-rm packaging/debian/usr/bin/go-cddns
4443

45-
release: clean
44+
bintray:
4645
docker pull alanfranz/fpm-within-docker:debian-jessie
47-
# Build
48-
GOOS=linux GOARCH=amd64 go build -o packaging/debian/usr/bin/go-cddns .
49-
# Package
46+
# Copy the amd64 binary
47+
cp /bin/go-cddns-${VERSION}_amd64 packaging/debian/usr/bin/go-cddns
48+
# Package amd64
5049
docker run --rm -it -v "${PWD}:${DOCKER_WDIR}" -w ${DOCKER_WDIR} --entrypoint fpm alanfranz/fpm-within-docker:debian-jessie ${DEB_OPTS} \
5150
--iteration ${RELEASE} \
5251
--architecture amd64 \
5352
--deb-systemd go-cddns.service \
5453
-C packaging/debian \
55-
${FPM_OPTS} \
56-
# Remove it
57-
rm packaging/debian/usr/bin/go-cddns
54+
${FPM_OPTS}
5855
# Upload it
5956
./upload.sh ${VERSION} ${RELEASE} amd64
60-
# Build
61-
GOOS=linux GOARCH=arm go build -o packaging/debian/usr/bin/go-cddns .
62-
# Package
57+
# Copy the arm binary
58+
cp /bin/go-cddns-${VERSION}_arm packaging/debian/usr/bin/go-cddns
59+
# Package arm
6360
docker run --rm -it -v "${PWD}:${DOCKER_WDIR}" -w ${DOCKER_WDIR} --entrypoint fpm alanfranz/fpm-within-docker:debian-jessie ${DEB_OPTS} \
6461
--iteration ${RELEASE} \
6562
--architecture armhf \
6663
--deb-systemd go-cddns.service \
6764
-C packaging/debian \
68-
${FPM_OPTS} \
69-
# Remove it
70-
rm packaging/debian/usr/bin/go-cddns
65+
${FPM_OPTS}
7166
# Upload everything
72-
./upload.sh ${VERSION} ${RELEASE} armhf
67+
./upload.sh ${VERSION} ${RELEASE} armhf
68+
69+
docker:
70+
docker build . -t nickrobison/go-cddns
71+
./docker_push.sh
72+
73+
release: clean all bintray docker
74+
7375

74-
.PHONY: all $(PLATFORMS) release clean test
76+
.PHONY: all $(PLATFORMS) release clean test bintray docker

README.md

+29
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
22
[![Build Status](https://travis-ci.org/nickrobison/go-cddns.svg?branch=master)](https://travis-ci.org/nickrobison/go-cddns)
33
[ ![Download](https://api.bintray.com/packages/nickrobison/debian/go-cddns/images/download.svg) ](https://bintray.com/nickrobison/debian/go-cddns/_latestVersion)
4+
45
# go-cddns
6+
57
Golang client for dynamically updating cloudflare DNS records on a specified interval. Useful if you're using Cloudflare to point to a device with a dynamic IP Address
68

79
## Installation
810

911
### Go package
12+
1013
```bash
1114
go get -u github.com/nickrobison/go-cddns
1215
```
1316

1417
### Debian repository
18+
1519
We also now have a debian (and Ubuntu) repository with builds for both amd64 and arm architectures.
1620
Since we require systemd, the builds only support debian jessie and newer, and ubuntu xenial (16.04) and later.
1721

@@ -47,6 +51,31 @@ Run the application, optionally specifying the path to the config file.
4751
go-cddns -config=/path/to/file
4852
```
4953

54+
## Docker Image
55+
56+
go-cddns is also provided as a Docker image.
57+
The application automatically starts when the container boots, but it lacks a functioning config file.
58+
You'll need to add the path to the desired config as a volume.
59+
60+
```bash
61+
docker run -v /{path/to/config}/config.json:/etc/config.json nickrobison/go-cddns
62+
63+
The container can be controlled by systemd via a custom unit file, such as this:
64+
65+
```ini
66+
[Unit]
67+
Description=Go-cddns container
68+
After=docker.service
69+
70+
[Service]
71+
Restart=always
72+
ExecStart=/usr/bin/docker start -a -v /etc/config.json:/etc/config.json nickrobison/go-cddns
73+
ExecStop=/usr/bin/docker stop -t 2 nickrobison/go-cddns
74+
75+
[Install]
76+
WantedBy=local.target
77+
```
78+
5079
## Notes
5180

5281
* The update interval must be more than 5 minutes, per the WhatIsMyIP API [rules](http://whatismyipaddress.com/api).

docker_push.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
3+
docker push nickrobison/go-cddns

0 commit comments

Comments
 (0)