commit c1fa73e66959429fe706f34d301c4c8d2f7662ab
parent 1c17df07a098c812d21d5449e5a637b5258872a5
Author: Andreas Gruhler <andreas.gruhler@adfinis.com>
Date: Sat, 12 Oct 2024 21:57:38 +0200
feat: add minio-lxc
Diffstat:
M | README.md | | | 13 | +++++++++++++ |
A | minio-lxc.pkr.hcl | | | 80 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | scripts/minio.sh | | | 66 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
3 files changed, 159 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md
@@ -111,6 +111,19 @@ $ ./deploy-output.sh
echo "show stat" | socat stdio /run/haproxy/admin.sock
```
+## Build armv7l Minio
+On amd64, cross compile for arm:
+```
+git clone --depth=1 https://github.com/minio/minio.git minio.git
+cd minio.git
+# https://github.com/golang/go/issues/65568
+sed -i 's/go 1.22/go 1.22.0/' go.mod
+
+GOARCH=arm CGO_ENABLED=0 go build -o minio github.com/minio/minio
+```
+
+Copy this binary to the arm host.
+
## Isssues
### Issue: Missing LXC Library Dir
diff --git a/minio-lxc.pkr.hcl b/minio-lxc.pkr.hcl
@@ -0,0 +1,80 @@
+variable "manifest" {
+ type = string
+ default = "manifest.json"
+}
+
+variable "minio_binary" {
+ type = string
+ default = "./minio"
+}
+
+variable "minio_volumes" {
+ type = string
+ default = "/mnt/data"
+}
+
+variable "minio_opts" {
+ type = string
+ default = "--console-address :9001"
+}
+
+variable "minio_service_user" {
+ type = string
+ default = "minio-user"
+}
+
+variable "minio_service_group" {
+ type = string
+ default = "minio-user"
+}
+
+variable "minio_root_user" {
+ type = string
+ default = "root"
+}
+
+variable "minio_root_password" {
+ type = string
+ sensitive = true
+}
+
+source "lxc" "minio" {
+ config_file = "config/lxc-config"
+ template_name = "download"
+ template_parameters = ["--dist", "Debian_by_maurer", "--release", "Bookworm", "--arch", "armv7l"]
+}
+
+build {
+ sources = ["source.lxc.minio"]
+
+ provisioner "shell" {
+ script = "scripts/timezone.sh"
+ }
+
+ provisioner "file" {
+ source = "${var.minio_binary}"
+ destination = "/usr/local/bin/minio"
+ }
+
+ provisioner "shell" {
+ environment_vars = [
+ "MINIO_ROOT_USER=${var.minio_root_user}",
+ "MINIO_ROOT_PASSWORD=${var.minio_root_password}",
+ "MINIO_VOLUMES=${var.minio_volumes}",
+ "MINIO_OPTS=${var.minio_opts}",
+ "MINIO_SERVICE_USER=${var.minio_service_user}",
+ "MINIO_SERVICE_GROUP=${var.minio_service_group}"
+ ]
+ script = "scripts/minio.sh"
+ }
+
+}
+
+packer {
+ required_plugins {
+ lxc = {
+ version = ">= 1.0.2"
+ source = "github.com/hashicorp/lxc"
+ }
+ }
+}
diff --git a/scripts/minio.sh b/scripts/minio.sh
@@ -0,0 +1,66 @@
+#!/usr/bin/env bash
+
+set -o errexit
+set -o nounset
+set -o xtrace
+
+# Install minio server
+# https://min.io/docs/minio/linux/operations/install-deploy-manage/deploy-minio-single-node-single-drive.html
+
+# Prepare data dir and binary
+mkdir -p $MINIO_VOLUMES
+chmod +x /usr/local/bin/minio
+
+# Configure minio user
+groupadd -r $MINIO_SERVICE_USER
+useradd -M -r -g $MINIO_SERVICE_GROUP $MINIO_SERVICE_USER
+chown $MINIO_SERVICE_USER:$MINIO_SERVICE_GROUP $MINIO_VOLUMES
+
+# Configure minio server
+cat << EOF > /etc/default/minio
+# MINIO_ROOT_USER and MINIO_ROOT_PASSWORD sets the root account for the MinIO server.
+# This user has unrestricted permissions to perform S3 and administrative API operations on any resource in the deployment.
+# Omit to use the default values 'minioadmin:minioadmin'.
+# MinIO recommends setting non-default values as a best practice, regardless of environment
+
+MINIO_ROOT_USER=$MINIO_ROOT_USER
+MINIO_ROOT_PASSWORD=$MINIO_ROOT_PASSWORD
+
+# MINIO_VOLUMES sets the storage volume or path to use for the MinIO server.
+
+MINIO_VOLUMES=$MINIO_VOLUMES
+
+# MINIO_OPTS sets any additional commandline options to pass to the MinIO server.
+# For example, `--console-address :9001` sets the MinIO Console listen port
+MINIO_OPTS=$MINIO_OPTS
+EOF
+
+# Prepare minio systemd configuration
+cat <<EOF > /etc/systemd/system/minio.service
+[Unit]
+Description=MinIO
+Documentation=https://min.io/docs/minio/linux/index.html
+Wants=network-online.target
+After=network-online.target
+AssertFileIsExecutable=/usr/local/bin/minio
+
+[Service]
+WorkingDirectory=/usr/local
+User=$MINIO_SERVICE_USER
+Group=$MINIO_SERVICE_GROUP
+ProtectProc=invisible
+EnvironmentFile=-/etc/default/minio
+ExecStartPre=/bin/bash -c "if [ -z \"${MINIO_VOLUMES}\" ]; then echo \"Variable MINIO_VOLUMES not set in /etc/default/minio\"; exit 1; fi"
+ExecStart=/usr/local/bin/minio server $MINIO_OPTS $MINIO_VOLUMES
+Type=notify
+Restart=always
+LimitNOFILE=65536
+TasksMax=infinity
+TimeoutStopSec=infinity
+SendSIGKILL=no
+
+[Install]
+WantedBy=multi-user.target
+EOF
+
+systemctl enable minio.service