mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
feat: Atomic update mcp image
This commit is contained in:
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env sh
|
||||
set -e
|
||||
|
||||
APP_DIR=${APP_DIR:-/app}
|
||||
BIN_NAME=${BIN_NAME:-mcp}
|
||||
STOP_SIGNAL=${STOP_SIGNAL:-TERM}
|
||||
CONTAINER_NAME=${CONTAINER_NAME:-}
|
||||
TARGET_OS=${TARGET_OS:-linux}
|
||||
TARGET_ARCH=${TARGET_ARCH:-}
|
||||
|
||||
if [ -z "$TARGET_ARCH" ]; then
|
||||
case "$(uname -m)" in
|
||||
arm64|aarch64)
|
||||
TARGET_ARCH=arm64
|
||||
;;
|
||||
x86_64|amd64)
|
||||
TARGET_ARCH=amd64
|
||||
;;
|
||||
*)
|
||||
TARGET_ARCH=amd64
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
mkdir -p "$APP_DIR"
|
||||
|
||||
GOOS="$TARGET_OS" GOARCH="$TARGET_ARCH" go build -trimpath -ldflags "-s -w" -o "${APP_DIR}/${BIN_NAME}.new" ./cmd/mcp
|
||||
mv -f "${APP_DIR}/${BIN_NAME}.new" "${APP_DIR}/${BIN_NAME}"
|
||||
|
||||
if [ -n "$CONTAINER_NAME" ]; then
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
limactl shell default -- nerdctl kill -s "$STOP_SIGNAL" "$CONTAINER_NAME"
|
||||
else
|
||||
nerdctl kill -s "$STOP_SIGNAL" "$CONTAINER_NAME"
|
||||
fi
|
||||
else
|
||||
echo "CONTAINER_NAME is empty; skip sending stop signal."
|
||||
fi
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env sh
|
||||
set -e
|
||||
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
limactl start default
|
||||
limactl shell default -- sudo containerd --version
|
||||
exit $?
|
||||
fi
|
||||
|
||||
if command -v containerd >/dev/null 2>&1 && command -v nerdctl >/dev/null 2>&1; then
|
||||
containerd --version
|
||||
nerdctl --version
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y containerd nerdctl
|
||||
elif command -v dnf >/dev/null 2>&1; then
|
||||
sudo dnf install -y containerd nerdctl
|
||||
elif command -v yum >/dev/null 2>&1; then
|
||||
sudo yum install -y containerd nerdctl
|
||||
elif command -v apk >/dev/null 2>&1; then
|
||||
sudo apk add --no-cache containerd nerdctl
|
||||
else
|
||||
echo "No supported package manager found. Install containerd manually."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
containerd --version
|
||||
nerdctl --version
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env sh
|
||||
set -e
|
||||
|
||||
IMAGE="memoh-mcp:dev"
|
||||
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
limactl shell default -- nerdctl rmi -f "$IMAGE"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
if ! command -v nerdctl >/dev/null 2>&1; then
|
||||
echo "nerdctl not found. Install nerdctl to remove images."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
nerdctl rmi -f "$IMAGE"
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env sh
|
||||
set -e
|
||||
|
||||
IMAGE="memoh-mcp:dev"
|
||||
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
limactl shell default -- nerdctl build -f cmd/mcp/Dockerfile -t "$IMAGE" .
|
||||
exit $?
|
||||
fi
|
||||
|
||||
if ! command -v nerdctl >/dev/null 2>&1; then
|
||||
echo "nerdctl not found. Install nerdctl to build images."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
nerdctl build -f cmd/mcp/Dockerfile -t "$IMAGE" .
|
||||
Reference in New Issue
Block a user