From 71fce1242e901658f4194b09cbc387ab2b56e850 Mon Sep 17 00:00:00 2001
From: Nico Schottelius <nico@nico-notebook.schottelius.org>
Date: Sun, 5 Dec 2021 10:07:14 +0100
Subject: [PATCH 1/5] Add initial Dockerfile

---
 Dockerfile | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 Dockerfile

diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..dcac071
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,19 @@
+FROM python:3.10.0-alpine3.15
+
+WORKDIR /usr/src/app
+
+COPY requirements.txt ./
+# OS requirements for building wheel and for operating uncloud
+RUN apk update && apk add \
+    openldap-dev \
+    postgresql-dev \
+    libxml2-dev \
+    libxslt-dev \
+    gcc \
+    git \
+    python3-dev \
+    musl-dev \
+    wireguard-tools-wg
+RUN pip install --no-cache-dir -r requirements.txt
+
+COPY . .

From df7b36c623fd9a54dda5d8f2c32d1ae18f4ef394 Mon Sep 17 00:00:00 2001
From: Nico Schottelius <nico@nico-notebook.schottelius.org>
Date: Sun, 5 Dec 2021 10:09:30 +0100
Subject: [PATCH 2/5] Update requirements.txt for newer python versions

---
 requirements.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/requirements.txt b/requirements.txt
index 237ff77..8cb3640 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -38,4 +38,4 @@ jinja2
 python-gitlab
 dnspython
 
-git+https://github.com/ungleich/python-oca.git#egg=python-oca
+git+https://github.com/ungleich/python-oca.git#egg=oca

From 174479f6d7d2f25df8a8ea8b138e6d4d5e42fe37 Mon Sep 17 00:00:00 2001
From: Nico Schottelius <nico@nico-notebook.schottelius.org>
Date: Sun, 5 Dec 2021 11:11:34 +0100
Subject: [PATCH 3/5] Add 2nd dockerfile for debian based systems

To move forward while ldap doesn't build
---
 Dockerfile              | 15 ++++++---------
 Dockerfile.alpine-linux | 26 ++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 9 deletions(-)
 create mode 100644 Dockerfile.alpine-linux

diff --git a/Dockerfile b/Dockerfile
index dcac071..68268e1 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,19 +1,16 @@
-FROM python:3.10.0-alpine3.15
+FROM python:3.10.0
 
 WORKDIR /usr/src/app
 
 COPY requirements.txt ./
 # OS requirements for building wheel and for operating uncloud
-RUN apk update && apk add \
-    openldap-dev \
-    postgresql-dev \
+RUN apt-get update && apt-get install -y --no-install-recommends  \
+    git \
+    libldap-dev \
     libxml2-dev \
     libxslt-dev \
-    gcc \
-    git \
-    python3-dev \
-    musl-dev \
-    wireguard-tools-wg
+    libpq-dev \
+    wireguard-tools
 RUN pip install --no-cache-dir -r requirements.txt
 
 COPY . .
diff --git a/Dockerfile.alpine-linux b/Dockerfile.alpine-linux
new file mode 100644
index 0000000..eefc9ef
--- /dev/null
+++ b/Dockerfile.alpine-linux
@@ -0,0 +1,26 @@
+# Currently not working due do ldap:
+#
+#   /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lldap_r
+#
+# While trying to install python-ldap
+
+FROM python:3.10.0-alpine3.15
+
+WORKDIR /usr/src/app
+
+COPY requirements.txt ./
+# OS requirements for building wheel and for operating uncloud
+RUN apk update && apk add \
+    gcc \
+    git \
+    libxml2-dev \
+    libxslt-dev \
+    libffi-dev \
+    openldap-dev \
+    postgresql-dev \
+    python3-dev \
+    musl-dev \
+    wireguard-tools-wg
+RUN pip install --no-cache-dir -r requirements.txt
+
+COPY . .

From 6ef3c0d01660c1ff78fdc2a5b7e0d5192ef213c3 Mon Sep 17 00:00:00 2001
From: Nico Schottelius <nico@nico-notebook.schottelius.org>
Date: Sun, 5 Dec 2021 11:13:21 +0100
Subject: [PATCH 4/5] Fix Debian Dockerfile: required libsasl2-dev

---
 Dockerfile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Dockerfile b/Dockerfile
index 68268e1..ae34ac1 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -10,6 +10,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends  \
     libxml2-dev \
     libxslt-dev \
     libpq-dev \
+    libsasl2-dev \
     wireguard-tools
 RUN pip install --no-cache-dir -r requirements.txt
 

From 07d7f5e4aebe29a0df19c6721e3c4bb24d356ef4 Mon Sep 17 00:00:00 2001
From: Nico Schottelius <nico@nico-notebook.schottelius.org>
Date: Sun, 5 Dec 2021 11:20:01 +0100
Subject: [PATCH 5/5] Add build script

---
 build.sh | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100755 build.sh

diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..2c51820
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+set -x
+
+name=uncloud:$(git describe)
+docker build -t ${name} .
+
+# check for args
+if [ $# -ge 1 ]; then
+    target=$1; shift
+else
+    target=""
+fi
+
+case "$target" in
+    dev)
+        docker tag $name harbor.default.svc.c2.k8s.ooo/ungleich-public/${name}
+        docker push harbor.default.svc.c2.k8s.ooo/ungleich-public/${name}
+        ;;
+    "")
+        echo "Not pushing anywhere"
+        ;;
+    *)
+        echo "Unknown argument $target, ignoring"
+        exit 1
+        ;;
+esac