From 1573d7bb5380a06a3d5386972b17f1007e5c9a90 Mon Sep 17 00:00:00 2001
From: Wolfgang Hottgenroth <w.hottgenroth@krohne.com>
Date: Tue, 26 Oct 2021 14:00:24 +0200
Subject: [PATCH] self build with nghttp2

---
 .gitignore     |  5 +++++
 .gitlab-ci.yml | 17 +++++++++++++++++
 Dockerfile     | 33 +++++++++++++++++++++++++++++----
 3 files changed, 51 insertions(+), 4 deletions(-)
 create mode 100644 .gitignore

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0e381bb
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+*~
+.*~
+*.swp
+.*.swp
+tmp/
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 58ea1fd..12af884 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,5 +1,22 @@
+stages:
+    - prepare
+    - check
+    - build
+
 include:
     - project: dockerized/commons
       ref: master
       file: gitlab-ci-template.yml
 
+prepare:
+    image: registry.hottis.de/dockerized/base-build-env:latest
+    stage: prepare
+    tags:
+        - hottis
+        - linux
+        - docker
+    script:
+        - mkdir tmp
+        - cd tmp
+        - git clone https://github.com/NLnetLabs/unbound.git
+
diff --git a/Dockerfile b/Dockerfile
index 2fccb72..1513437 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,14 +1,39 @@
+FROM alpine:3.13 AS builder
+
+COPY tmp/unbound/ tmp/unbound
+RUN \
+  apk update && \
+  apk add alpine-sdk && \
+  apk add nghttp2-libs && \
+  apk add nghttp2-dev && \
+  apk add openssl-dev && \
+  apk add expat-dev && \
+  apk add libevent-dev && \
+  cd tmp/unbound && \
+  ./configure --with-libnghttp2 --with-libevent --prefix /opt/unbound && \
+  make && \
+  make install
+
+
+
 FROM alpine:3.13
+COPY --from=builder /opt/unbound/ /opt/unbound
 
 RUN \
-  apk add --no-cache unbound && \
-  mv /etc/unbound/unbound.conf /etc/unbound/unbound.conf-dist
+  apk add --no-cache openssl && \
+  apk add --no-cache nghttp2-libs && \
+  apk add --no-cache expat && \
+  apk add --no-cache libevent && \
+  mv /opt/unbound/etc/unbound/unbound.conf /opt/unbound/etc/unbound/unbound.conf-dist && \
+  ln -s /opt/unbound/etc/unbound /etc/unbound
 
-COPY unbound.conf /etc/unbound/unbound.conf
+ COPY unbound.conf /opt/unbound/etc/unbound/unbound.conf
 
 EXPOSE 53/udp
+EXPOSE 53/tcp
+EXPOSE 853/tcp
 
-VOLUME /etc/unbound
+VOLUME /opt/unbound/etc/unbound
 
 CMD [ "/usr/sbin/unbound" ]