Rename binary, 1.0.0 release, docker images

pull/1/head 1.0.0
Kaan Barmore-Genç 1 year ago
parent 517c77ee05
commit 7eca3fbe5f

1
.gitignore vendored

@ -1,2 +1,3 @@
/target
gandi.toml
*.tar*

4
Cargo.lock generated

@ -225,8 +225,8 @@ dependencies = [
]
[[package]]
name = "gandi-rust-dns-updater"
version = "0.1.0"
name = "gandi-live-dns"
version = "1.0.0"
dependencies = [
"anyhow",
"die-exit",

@ -1,8 +1,12 @@
[package]
name = "gandi-rust-dns-updater"
version = "0.1.0"
name = "gandi-live-dns"
version = "1.0.0"
edition = "2021"
[profile.release]
strip = true
lto = true
[dependencies]
reqwest = { version = "0.11.7", default-features= false, features = ["json", "rustls-tls"] }
@ -15,4 +19,4 @@ tokio = { version = "1.14.0", features = ["full"] }
futures = "0.3.17"
anyhow = "1.0"
# TODO: Relies on a yet-unreleased interface. Switch to an actual crate release once available
die-exit = { git = "https://github.com/Xavientois/die.git", rev = "31d3801f4e21654b0b28430987b1e21fc7728676" }
die-exit = { git = "https://github.com/Xavientois/die.git", rev = "31d3801f4e21654b0b28430987b1e21fc7728676" }

1
Docker/.gitignore vendored

@ -0,0 +1 @@
binaries

@ -0,0 +1,8 @@
FROM scratch
ARG TARGETPLATFORM
ADD binaries/$TARGETPLATFORM/gandi-live-dns /
WORKDIR /
ENTRYPOINT ["/gandi-live-dns"]

@ -1,24 +1,76 @@
## gandi-live-dns-rust
A program that can set the IP addresses for configured DNS entries in [Gandi](https://gandi.net)'s domain configuration.
Thanks to Gandi's [LiveDNS API](https://api.gandi.net/docs/livedns/), this creates a dynamic DNS system.
A program that can set the IP addresses for configured DNS entries in
[Gandi](https://gandi.net)'s domain configuration. Thanks to Gandi's
[LiveDNS API](https://api.gandi.net/docs/livedns/),
this creates a dynamic DNS system.
Inspired by [cavebeat's similar tool](https://github.com/cavebeat/gandi-live-dns),
which seems to be unmaintained at the time I'm writing this. I decided to rewrite it in Rust as a learning project.
If you want to host web services but you don't have a static IP address, this
tool will allow you to keep your domains pointed at the right IP address. This
program can update both IPv4 and IPv6 addresses for one or more domains and
subdomains. It's a one-shot tool that's meant to be managed with a systemd timer
or cron.
This tool can update both IPv4 and IPv6 addresses for one or more domains and subdomains.
It's a "one-shot" tool that's then orchestrated with a systemd timer or cron.
Inspired by [cavebeat's similar tool](https://github.com/cavebeat/gandi-live-dns),
which seems to be unmaintained at the time I'm writing this. I decided to rewrite
it in Rust as a learning project.
## Usage
> Warning!
>
> This tool does not rate limit itself, or otherwise do anything that limits how
> often it sends changes to Gandi's servers. It's up to you to use the tool
> properly and avoid abusing Gandi's servers. The tool is one-shot, so all you
> have to do is to avoid running it too often.
### Prebuilt binaries
`gandi-live-dns-rust` provides pre-built binaries with the releases. See the
[releases page](https://github.com/SeriousBug/gandi-live-dns-rust/releases) to
get the latest version. These binaries are statically linked, and provided for
both Linux and Windows, including ARM architectures for the Linux version.
Download the latest version from the releases page, extract it from the archive, and place it somewhere in your `$PATH` to use it.
- Create a file `gandi.toml`, then copy and paste the contents of [`example.toml`](https://raw.githubusercontent.com/SeriousBug/gandi-live-dns-rust/master/example.toml)
- Follow the instructions in the example config to get your API key and put it in the config
- Follow the examples in the config to set up the entries you want to update
- Download and extract the correct binary from the [releases page](https://github.com/SeriousBug/gandi-live-dns-rust/releases) and place it in your `PATH`, or just the current directory
- Run `gandi-rust-dns-updater` to update your DNS entries
- Run `gandi-live-dns` inside the directory with the configration to update your DNS entries
> Warning!
>
> This tool does not rate limit itself, or otherwise do anything that limits how often it sends changes to Gandi's servers.
> It's up to you to use the tool properly and avoid abusing Gandi's servers. The tool is one-shot, so all you have to do is
> to avoid running it too often.
### With docker
`gandi-live-dns-rust` has Docker images available for x86_64, arm64, armv6, and armv7 platforms.
Follow the steps below to use these images.
- Create a file `gandi.toml`, then copy and paste the contents of [`example.toml`](https://raw.githubusercontent.com/SeriousBug/gandi-live-dns-rust/master/example.toml)
- Follow the instructions in the example config to get your API key and put it in the config
- Follow the examples in the config to set up the entries you want to update
- Run `docker run --rm -it -v $(pwd)/gandi.toml:/gandi.toml:ro seriousbug/gandi-live-dns-rust:latest`
> Docker doesn't [support IPv6](https://docs.docker.com/config/daemon/ipv6/) out
> of the box. Check the linked page to enable it, or use the native option.
> If you get [errors](https://stackoverflow.com/questions/42248198/how-to-mount-a-single-file-in-a-volume) about not finding the config file, make sure your command
> has a full path to the config file (`$(pwd)/gandi.toml` part). Otherwise
> Docker will create a directory.
## Development
### Local builds
`cargo build` and `cargo build --release` are sufficient for development and release builds.
No special instructions are needed.
### Making a release
To make a release, first set up `cross` and `docker`. Make sure you log into
Docker with `docker login`. Then follow these steps:
- bump up the version in `Cargo.toml` according to [semver](https://semver.org/)
- run `./make-release.sh`
> This will build binaries, then package them into archives, as well as
> build and upload docker images.
- Create a release on Github
- Make sure to create a tag for the release version on `master`
- Upload the binary archives to the Github release

@ -0,0 +1,70 @@
#!/bin/bash
#
# Make sure `cross` is installed.
# You'll also need `sed`, and a relatively recent version of `tar`.
#
# This script runs does `sudo docker` to build and push the release to docker.
# If you have rootless docker set up, remove sudo from this variable.
DOCKER="sudo docker"
#
# Trap errors and interrupts
set -Eeuo pipefail
shopt -s extglob
function handle_sigint() {
echo "SIGINT, exiting..."
exit 1
}
trap handle_sigint SIGINT
function handle_err() {
echo "Error in run.sh!" 1>&2
echo "$(caller): ${BASH_COMMAND}" 1>&2
echo "Exiting..."
exit 2
}
trap handle_err ERR
# Go to the root of the project
SCRIPT=$(realpath "${0}")
SCRIPTPATH=$(dirname "${SCRIPT}")
cd "${SCRIPTPATH}" || exit 12
declare -A TARGETS=(
['x86_64-unknown-linux-musl']='linux-x86_64'
['x86_64-pc-windows-gnu']='windows-x86_64'
['aarch64-unknown-linux-musl']='linux-arm64'
['armv7-unknown-linux-musleabihf']='linux-armv7'
['arm-unknown-linux-musleabihf']='linux-armv6'
)
declare -A DOCKER_TARGETS=(
['x86_64-unknown-linux-musl']='linux/amd64'
['aarch64-unknown-linux-musl']='linux/arm64'
['armv7-unknown-linux-musleabihf']='linux/arm/v7'
['arm-unknown-linux-musleabihf']='linux/arm/v6'
)
# Get the version number
VERSION=$(sed -nr 's/^version *= *"([0-9.]+)"/\1/p' Cargo.toml)
# Make the builds
for target in "${!TARGETS[@]}"; do
echo Building "${target}"
cross build -j $(($(nproc) / 2)) --release --target "${target}"
tar -acf "gandi-live-dns.${VERSION}.${TARGETS[${target}]}.tar.xz" target/"${target}"/release/gandi-live-dns?(|.exe)
done
# Copy files into place so Docker can get them easily
cd Docker
echo Building Docker images
mkdir -p binaries
for target in "${!DOCKER_TARGETS[@]}"; do
mkdir -p "binaries/${DOCKER_TARGETS[${target}]}"
cp ../target/"${target}"/release/gandi-live-dns?(|.exe) "binaries/${DOCKER_TARGETS[${target}]}/gandi-live-dns"
done
${DOCKER} buildx build . \
--platform=linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 \
--file "Dockerfile" \
--tag "seriousbug/gandi-live-dns-rust:latest" \
--tag "seriousbug/gandi-live-dns-rust:${VERSION}" \
--push

@ -0,0 +1,2 @@
[toolchain]
channel = "nightly"
Loading…
Cancel
Save