Skip to content

Commit 3ec3905

Browse files
committed
docker/unbound: unbound with modified unbound_exporter
1 parent 5aefc0a commit 3ec3905

File tree

6 files changed

+157
-47
lines changed

6 files changed

+157
-47
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Convention:
2+
// Workflow definition: .github/workflow/docker-#{name}.yml
3+
// Docker manifest docker/#{name}/Dockerfile
4+
// ECR repository: #{name}
5+
6+
function(name) {
7+
name: std.format('docker-%s', name),
8+
on: {
9+
push: {
10+
branches: ['master', 'test'],
11+
paths: [
12+
std.format('docker/%s/**', name),
13+
std.format('.github/workflows/docker-%s.yml', name),
14+
],
15+
},
16+
},
17+
jobs: {
18+
build: {
19+
name: 'build',
20+
'runs-on': 'ubuntu-latest',
21+
permissions: { 'id-token': 'write', contents: 'read' },
22+
steps: [
23+
{ uses: 'docker/setup-qemu-action@v2' },
24+
{ uses: 'docker/setup-buildx-action@v2' },
25+
{
26+
uses: 'aws-actions/configure-aws-credentials@v1',
27+
with: {
28+
'aws-region': 'ap-northeast-1',
29+
'role-to-assume': 'arn:aws:iam::005216166247:role/GhaDockerPush',
30+
'role-skip-session-tagging': true,
31+
},
32+
},
33+
{
34+
uses: 'aws-actions/amazon-ecr-login@v1',
35+
id: 'login-ecr',
36+
},
37+
{
38+
uses: 'docker/build-push-action@v3',
39+
with: {
40+
context: std.format('{{defaultContext}}:docker/%s', name),
41+
platforms: std.join(',', ['linux/arm64']),
42+
tags: std.join(',', [
43+
std.format('${{ steps.login-ecr.outputs.registry }}/%s:${{ github.sha }}', name),
44+
std.format('${{ steps.login-ecr.outputs.registry }}/%s:latest', name),
45+
]),
46+
push: true,
47+
},
48+
},
49+
],
50+
},
51+
},
52+
}
Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1 @@
1-
{
2-
name: 'docker-fluentd',
3-
on: {
4-
push: {
5-
branches: ['master', 'test'],
6-
paths: [
7-
'docker/fluentd/**',
8-
'.github/workflows/docker-fluentd.jsonnet',
9-
],
10-
},
11-
},
12-
jobs: {
13-
build: {
14-
name: 'build',
15-
'runs-on': 'ubuntu-latest',
16-
permissions: { 'id-token': 'write', contents: 'read' },
17-
steps: [
18-
{ uses: 'docker/setup-qemu-action@v2' },
19-
{ uses: 'docker/setup-buildx-action@v2' },
20-
{
21-
uses: 'aws-actions/configure-aws-credentials@v1',
22-
with: {
23-
'aws-region': 'ap-northeast-1',
24-
'role-to-assume': 'arn:aws:iam::005216166247:role/GhaDockerPush',
25-
'role-skip-session-tagging': true,
26-
},
27-
},
28-
{
29-
uses: 'aws-actions/amazon-ecr-login@v1',
30-
id: 'login-ecr',
31-
},
32-
{
33-
uses: 'docker/build-push-action@v3',
34-
with: {
35-
context: '{{defaultContext}}:docker/fluentd',
36-
platforms: std.join(',', ['linux/arm64']),
37-
tags: std.join(',', [
38-
'${{ steps.login-ecr.outputs.registry }}/fluentd:${{ github.sha }}',
39-
'${{ steps.login-ecr.outputs.registry }}/fluentd:latest',
40-
]),
41-
push: true,
42-
},
43-
},
44-
],
45-
},
46-
},
47-
}
1+
(import './docker-build-simple.libsonnet')('fluentd')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(import './docker-build-simple.libsonnet')('unbound')

.github/workflows/docker-unbound.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"jobs": {
3+
"build": {
4+
"name": "build",
5+
"permissions": {
6+
"contents": "read",
7+
"id-token": "write"
8+
},
9+
"runs-on": "ubuntu-latest",
10+
"steps": [
11+
{
12+
"uses": "docker/setup-qemu-action@v2"
13+
},
14+
{
15+
"uses": "docker/setup-buildx-action@v2"
16+
},
17+
{
18+
"uses": "aws-actions/configure-aws-credentials@v1",
19+
"with": {
20+
"aws-region": "ap-northeast-1",
21+
"role-skip-session-tagging": true,
22+
"role-to-assume": "arn:aws:iam::005216166247:role/GhaDockerPush"
23+
}
24+
},
25+
{
26+
"id": "login-ecr",
27+
"uses": "aws-actions/amazon-ecr-login@v1"
28+
},
29+
{
30+
"uses": "docker/build-push-action@v3",
31+
"with": {
32+
"context": "{{defaultContext}}:docker/unbound",
33+
"platforms": "linux/arm64",
34+
"push": true,
35+
"tags": "${{ steps.login-ecr.outputs.registry }}/unbound:${{ github.sha }},${{ steps.login-ecr.outputs.registry }}/unbound:latest"
36+
}
37+
}
38+
]
39+
}
40+
},
41+
"name": "docker-unbound",
42+
"on": {
43+
"push": {
44+
"branches": [
45+
"master",
46+
"test"
47+
],
48+
"paths": [
49+
"docker/unbound/**",
50+
".github/workflows/docker-unbound.jsonnet"
51+
]
52+
}
53+
}
54+
}

unbound/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM public.ecr.aws/docker/library/golang:1.19-bullseye as build
2+
3+
RUN go install github.com/hanazuki/unbound_exporter@f275b66dd1eff4b7f225455c22cfae31fc9c95fc
4+
5+
###
6+
7+
FROM public.ecr.aws/debian/debian:bullseye-slim
8+
9+
RUN apt-get update -qq && \
10+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends unbound dns-root-data dumb-init
11+
12+
COPY --from=build /go/bin/unbound_exporter /usr/local/bin/
13+
14+
RUN /usr/lib/unbound/package-helper root_trust_anchor_update
15+
RUN rm /etc/unbound/unbound_*.key /etc/unbound/unbound_*.pem
16+
17+
COPY entrypoint.sh /
18+
RUN chmod +x entrypoint.sh
19+
20+
ENTRYPOINT ["dumb-init", "/entrypoint.sh"]

unbound/entrypoint.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
set -eu -o pipefail
3+
4+
if [[ ${1:-} = /* ]]; then
5+
exec "$@"
6+
fi
7+
8+
conffile=/etc/unbound/unbound.conf
9+
for i in $(seq 1 $(( $# - 1 ))); do
10+
if [[ ${!i} = -c ]]; then
11+
: $(( ++i ))
12+
conffile="${!i}"
13+
break
14+
fi
15+
done
16+
17+
echo "conffile: $conffile"
18+
echo ====
19+
cat "$conffile"
20+
echo ====
21+
22+
sock=$(unbound-checkconf -o control-interface "$conffile")
23+
if [[ $sock != /* ]]; then
24+
echo "control-interface is expected to be an absolute path: $sock" >&2
25+
exit 1
26+
fi
27+
28+
/usr/local/bin/unbound_exporter --unbound.host "unix://$sock" &
29+
/usr/sbin/unbound "$@"

0 commit comments

Comments
 (0)