Skip to content

Commit

Permalink
feat: add ntpd-rs (#1024)
Browse files Browse the repository at this point in the history
  • Loading branch information
onedr0p authored May 15, 2024
1 parent a1e30b0 commit cebe2e8
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 0 deletions.
37 changes: 37 additions & 0 deletions apps/ntpd-rs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM docker.io/library/rust:1.78.0-alpine as cargo
ARG VERSION
WORKDIR /tmp
RUN \
apk add --no-cache \
autoconf \
automake \
build-base \
curl \
linux-headers \
musl-dev \
&& \
curl -fsSL "https://github.com/pendulum-project/ntpd-rs/archive/refs/tags/v${VERSION}.tar.gz" \
| tar xzf - -C /tmp --strip-components 1 \
&& cargo build --release

FROM docker.io/library/alpine:3.19

#hadolint ignore=DL3018,DL3059
RUN apk add --no-cache bash ca-certificates catatonit tzdata

COPY --from=cargo /tmp/target/release/ntp-daemon /usr/local/bin/ntp-daemon
COPY --from=cargo /tmp/target/release/ntp-ctl /usr/local/bin/ntp-ctl
COPY --from=cargo /tmp/target/release/ntp-metrics-exporter /usr/local/bin/ntp-metrics-exporter
RUN /usr/local/bin/ntp-daemon --help
RUN /usr/local/bin/ntp-ctl --help
RUN /usr/local/bin/ntp-metrics-exporter --help

COPY ./apps/ntpd-rs/ntp.toml /etc/ntp.toml
COPY ./apps/ntpd-rs/entrypoint.sh /entrypoint.sh

USER nobody:nogroup
WORKDIR /config
VOLUME ["/config"]

ENTRYPOINT ["/usr/bin/catatonit", "--"]
CMD ["/entrypoint.sh"]
11 changes: 11 additions & 0 deletions apps/ntpd-rs/ci/goss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/goss-org/goss/master/docs/schema.yaml
file:
/usr/local/bin/ntp-daemon:
exists: true
/usr/local/bin/ntp-ctl:
exists: true
/usr/local/bin/ntp-metrics-exporter:
exists: true
/etc/ntp.toml:
exists: true
5 changes: 5 additions & 0 deletions apps/ntpd-rs/ci/latest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
version=$(curl -sX GET "https://api.github.com/repos/pendulum-project/ntpd-rs/releases/latest" | jq --raw-output '.tag_name' 2>/dev/null)
version="${version#*v}"
version="${version#*release-}"
printf "%s" "${version}"
11 changes: 11 additions & 0 deletions apps/ntpd-rs/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

if [[ ! -f "/config/ntp.toml" ]]; then
printf "Copying over default configuration ...\n"
cp /etc/ntp.toml /config/ntp.toml
fi

#shellcheck disable=SC2086
exec \
/usr/local/bin/ntp-daemon \
--config /config/ntp.toml
9 changes: 9 additions & 0 deletions apps/ntpd-rs/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
app: ntpd-rs
channels:
- name: stable
platforms: ["linux/amd64", "linux/arm64"]
stable: true
tests:
enabled: true
type: cli
2 changes: 2 additions & 0 deletions apps/ntpd-rs/ntp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[[server]]
listen = "0.0.0.0:123"

0 comments on commit cebe2e8

Please sign in to comment.