Merge ~barryprice/charm-k8s-bind/+git/charm-k8s-bind:image-builder into charm-k8s-bind:master

Proposed by Barry Price
Status: Merged
Approved by: Tom Haddon
Approved revision: 55f728221f7857cd037d987b73eca4dec1a36bb1
Merged at revision: af1d0d984eb1a91518747540bbddab2ce012fcfe
Proposed branch: ~barryprice/charm-k8s-bind/+git/charm-k8s-bind:image-builder
Merge into: charm-k8s-bind:master
Diff against target: 133 lines (+96/-1)
5 files modified
.jujuignore (+7/-0)
Makefile (+23/-1)
dockerfile (+33/-0)
image-scripts/dns-check.sh (+10/-0)
image-scripts/docker-entrypoint.sh (+23/-0)
Reviewer Review Type Date Requested Status
Tom Haddon Approve
Canonical IS Reviewers Pending
Review via email: mp+388449@code.launchpad.net

Commit message

Migrate the image builder here from its own branch, use .jujuignore to ensure charmcraft doesn't include those parts in our built charm

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Tom Haddon (mthaddon) wrote :

LGTM, thx

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision af1d0d984eb1a91518747540bbddab2ce012fcfe

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/.jujuignore b/.jujuignore
0new file mode 1006440new file mode 100644
index 0000000..d968a07
--- /dev/null
+++ b/.jujuignore
@@ -0,0 +1,7 @@
1*~
2.coverage
3__pycache__
4/dockerfile
5/image-scripts/
6/tests/
7/Makefile
diff --git a/Makefile b/Makefile
index d403fd0..66fc8ed 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,6 @@
1DIST_RELEASE ?= focal
2DOCKER_DEPS = bind9 bind9-dnsutils git
3
1blacken:4blacken:
2 @echo "Normalising python layout with black."5 @echo "Normalising python layout with black."
3 @tox -e black6 @tox -e black
@@ -21,4 +24,23 @@ clean:
21bind.charm: src/*.py requirements.txt24bind.charm: src/*.py requirements.txt
22 charmcraft build25 charmcraft build
2326
24.PHONY: blacken lint unittest test clean27image-deps:
28 @echo "Checking shellcheck is present."
29 @command -v shellcheck >/dev/null || { echo "Please install shellcheck to continue ('sudo snap install shellcheck')" && false; }
30
31image-lint: image-deps
32 @echo "Running shellcheck."
33 @shellcheck files/docker-entrypoint.sh
34 @shellcheck files/dns-check.sh
35
36image-build: image-lint
37 @echo "Building the image."
38 @docker build \
39 --no-cache=true \
40 --build-arg BUILD_DATE=$$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
41 --build-arg PKGS_TO_INSTALL='$(DOCKER_DEPS)' \
42 --build-arg DIST_RELEASE=$(DIST_RELEASE) \
43 -t bind:$(DIST_RELEASE)-latest \
44 .
45
46.PHONY: blacken lint unittest test clean image-deps image-lint image-build
diff --git a/dockerfile b/dockerfile
25new file mode 10064447new file mode 100644
index 0000000..2e580d4
--- /dev/null
+++ b/dockerfile
@@ -0,0 +1,33 @@
1ARG DIST_RELEASE
2
3FROM ubuntu:${DIST_RELEASE}
4
5LABEL maintainer="bind-charmers@lists.launchpad.net"
6
7ARG BUILD_DATE
8ARG PKGS_TO_INSTALL
9
10LABEL org.label-schema.build-date=${BUILD_DATE}
11
12ENV BIND_CONFDIR=/etc/bind
13
14# Avoid interactive prompts
15RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
16
17# Update all packages, remove cruft, install required packages
18RUN apt-get update && apt-get -y dist-upgrade \
19 && apt-get --purge autoremove -y \
20 && apt-get install -y ${PKGS_TO_INSTALL}
21
22# entrypoint script will configure Bind based on env variables
23# dns-check script will provide a readinessProbe
24COPY ./files/docker-entrypoint.sh /usr/local/bin/
25COPY ./files/dns-check.sh /usr/local/bin/
26RUN chmod 0755 /usr/local/bin/docker-entrypoint.sh
27RUN chmod 0755 /usr/local/bin/dns-check.sh
28
29EXPOSE 53/udp
30EXPOSE 53/tcp
31
32ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
33CMD /usr/sbin/named -g -u bind -c /etc/bind/named.conf
diff --git a/image-scripts/dns-check.sh b/image-scripts/dns-check.sh
0new file mode 10064434new file mode 100644
index 0000000..ca4a5a0
--- /dev/null
+++ b/image-scripts/dns-check.sh
@@ -0,0 +1,10 @@
1#!/bin/bash
2set -eu
3
4TEST_DOMAIN="ddebs.ubuntu.com."
5NSLOOKUP_PATH="/usr/bin/nslookup"
6OUR_ADDRESS="127.0.0.1"
7
8command -v "${NSLOOKUP_PATH}" >/dev/null || { echo "Cannot find the 'nslookup' command" && exit 1; }
9
10exec "${NSLOOKUP_PATH}" "${TEST_DOMAIN}" "${OUR_ADDRESS}" >/dev/null
diff --git a/image-scripts/docker-entrypoint.sh b/image-scripts/docker-entrypoint.sh
0new file mode 10064411new file mode 100644
index 0000000..2ed0857
--- /dev/null
+++ b/image-scripts/docker-entrypoint.sh
@@ -0,0 +1,23 @@
1#!/bin/bash
2set -eu
3
4if [ -z "${BIND_CONFDIR-}" ]; then
5 # If BIND_CONFDIR wasn't set, use the package default
6 BIND_CONFDIR="/etc/bind";
7fi
8
9if [ -z "${CUSTOM_CONFIG_REPO-}" ]; then
10 echo "No custom repo set, will fall back to package default config";
11else
12 echo "Pulling config from $CUSTOM_CONFIG_REPO";
13 if [ -d "${BIND_CONFDIR}" ]; then
14 mv "${BIND_CONFDIR}" "${BIND_CONFDIR}_$(date +"%Y-%m-%d_%H-%M-%S")";
15 fi
16 git clone "$CUSTOM_CONFIG_REPO" "$BIND_CONFDIR";
17fi
18
19if [ -d "${BIND_CONFDIR}" ]; then
20 exec "$@"
21else
22 echo "Something went wrong, ${BIND_CONFDIR} does not exist, not starting";
23fi

Subscribers

People subscribed via source and target branches

to all changes: