From 8d009abdbebd592806ab837dc7ebefea95bb8a38 Mon Sep 17 00:00:00 2001
From: Sheogorath <sheogorath@shivering-isles.com>
Date: Sun, 29 Oct 2023 02:04:04 +0100
Subject: [PATCH] refactor(synadm): Rework synadm to use Earthly native

---
 images/synadm/Dockerfile | 12 ------------
 images/synadm/Earthfile  | 17 +++++++++++++++--
 images/synadm/Makefile   | 13 -------------
 images/synadm/README.md  |  2 +-
 4 files changed, 16 insertions(+), 28 deletions(-)
 delete mode 100644 images/synadm/Dockerfile
 delete mode 100644 images/synadm/Makefile

diff --git a/images/synadm/Dockerfile b/images/synadm/Dockerfile
deleted file mode 100644
index 0a200d700..000000000
--- a/images/synadm/Dockerfile
+++ /dev/null
@@ -1,12 +0,0 @@
-FROM docker.io/library/python:3
-
-COPY requirements.txt .
-
-RUN true \
-  && pip3 install -r requirements.txt \
-  && mkdir -p /workspace \
-  && true
-
-
-WORKDIR /workspace
-ENTRYPOINT ["/usr/local/bin/synadm"]
diff --git a/images/synadm/Earthfile b/images/synadm/Earthfile
index 381b0bb05..9d9d8eb33 100644
--- a/images/synadm/Earthfile
+++ b/images/synadm/Earthfile
@@ -1,15 +1,28 @@
 VERSION 0.7
 
+container-interal:
+    FROM docker.io/library/python:3
+    COPY requirements.txt .
+    RUN pip3 install -r requirements.txt
+    RUN mkdir -p /workspace
+    WORKDIR /workspace
+    ENTRYPOINT ["/usr/local/bin/synadm"]
+
 container:
     FROM ../mirror+alpine
     ARG registry=quay.io/shivering-isles/synadm
     COPY .release ./
     ARG tag=$(awk -F'=' '$1 == "release" {print $2}' .release)
     ARG latest=false
-    FROM DOCKERFILE --platform=linux/amd64 -f "./Dockerfile" "./"
+    FROM +container-interal
     IF [ $latest = "true" ]
         SAVE IMAGE --push ${registry}:latest
     ELSE
         LABEL "quay.expires-after"="12w"
     END
-    SAVE IMAGE --push ${registry}:${tag}
\ No newline at end of file
+    SAVE IMAGE --push ${registry}:${tag}
+
+install:
+    BUILD +container
+    LOCALLY
+	RUN install -m 755 ./synadm ~/bin/synadm
\ No newline at end of file
diff --git a/images/synadm/Makefile b/images/synadm/Makefile
deleted file mode 100644
index 9020ce9a5..000000000
--- a/images/synadm/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-.DEFAULT_GOAL := help
-
-include ../.utils/container-build.mk
-include ../../utils/help.mk
-
-.PHONY: preflight
-preflight:
-	# Check for required tools
-	command -v podman > /dev/null
-
-.PHONY: install
-install: preflight build ## Install koolbox, the Kubernetes Toolbox for SI-Infrastructure
-	install -m 755 ./synadm ~/bin/synadm
diff --git a/images/synadm/README.md b/images/synadm/README.md
index 9dd1697bc..abe974dcb 100644
--- a/images/synadm/README.md
+++ b/images/synadm/README.md
@@ -14,6 +14,6 @@ Installation
 In order to install it, you just build the container yourself and get a neat little shell script installed in `~/bin/`
 
 ```
-make install REGISTRY_HOST=quay.io USERNAME=shivering-isles
+earthly +install
 synadm --help
 ```
-- 
GitLab