From f893f1967a2a10b2ee8f9a3010acb1b8699f159a Mon Sep 17 00:00:00 2001
From: Job79 <job@plabble.org>
Date: Fri, 21 Jul 2023 16:46:55 +0200
Subject: [PATCH 1/2] build: use docker for building instead of the host

---
 Dockerfile | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index be8cd7c..0c0cbd3 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,8 +1,21 @@
+FROM rust:alpine3.18 AS builder
+WORKDIR /build
+
+RUN apk add --no-cache musl-dev
+COPY . ./
+RUN apk --print-arch
+RUN case "$(apk --print-arch)" in \
+	x86_64) cargo build --target x86_64-unknown-linux-musl --release; \
+               mv ./target/x86_64-unknown-linux-musl /release ;; \
+	aarch64) cargo build --target aarch64-unknown-linux-musl --release; \
+	       mv ./target/aarch64-unknown-linux-musl /release ;; \
+	esac
+
 FROM alpine:edge
 WORKDIR /app
 
-COPY ./target/x86_64-unknown-linux-musl/release/ /app
+COPY --from=builder /release/* /app
 COPY ./about.html /app/about.html
 
 EXPOSE 8080
-CMD [ "./pastabble" ]
\ No newline at end of file
+CMD [ "./pastabble" ]

From de4ec24d83ebefd9e2c1aadeab2a4fa9f769ac34 Mon Sep 17 00:00:00 2001
From: Job79 <job@plabble.org>
Date: Fri, 21 Jul 2023 16:50:53 +0200
Subject: [PATCH 2/2] docs: add documentation for building container

---
 build.sh | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/build.sh b/build.sh
index ee38509..44b002d 100755
--- a/build.sh
+++ b/build.sh
@@ -1,7 +1,10 @@
 #!/bin/sh
 cargo build --target x86_64-unknown-linux-musl --release
 podman build -t pastabble:latest .
-podman save --format oci-archive -o pastabble.tar pastabble
 
-# load with podman load -i pastabble.tar
-# run with podman run -p 8080:8080 --name pastabble-c -v pastabble-v:/data -it pastabble
\ No newline at end of file
+# publish
+# podman build --arch=arm64 . -t git.plabble.org/{user}/pastabble
+# podman push git.plabble.org/{user}/pastabble
+
+# run
+# podman run -p 8080:8080 --name pastabble-c -v pastabble-v:/data -it pastabble