This commit is contained in:
2025-08-23 05:46:18 -07:00
parent 476f319acc
commit 73c0de1f67
8 changed files with 11 additions and 181 deletions

39
scripts/netdebug Executable file
View File

@@ -0,0 +1,39 @@
#!/bin/bash
set -e
# First, ensure netdebug pod is installed
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_DIR="$(dirname "$SCRIPT_DIR")"
# Source environment variables
if [ -f "$REPO_DIR/load-env.sh" ]; then
source "$REPO_DIR/load-env.sh"
fi
# Check if netdebug is installed, if not deploy it
if ! kubectl get namespace debug >/dev/null 2>&1; then
echo "Setting up netdebug pod..."
kubectl apply -f "$REPO_DIR/infrastructure_setup/utils/netdebug.yaml"
echo "Waiting for netdebug pod to be ready..."
sleep 5
fi
# Get the netdebug pod name
NETDEBUG_POD=$(kubectl get pods -n debug -l app=netdebug -o jsonpath='{.items[0].metadata.name}' 2>/dev/null)
if [ -z "$NETDEBUG_POD" ]; then
echo "Waiting for netdebug pod to start..."
kubectl get pods -n debug
exit 1
fi
# If arguments provided, run them as a command on the container
if [ $# -gt 0 ]; then
kubectl exec -it -n debug "$NETDEBUG_POD" -- "$@"
else
# Otherwise attach to the container with a shell
echo "Attaching to netdebug pod ($NETDEBUG_POD)..."
echo "Type 'exit' to detach"
echo ""
kubectl exec -it -n debug "$NETDEBUG_POD" -- /bin/bash
fi

62
scripts/push-container Executable file
View File

@@ -0,0 +1,62 @@
#!/bin/bash
set -e
# Load environment variables
source "$(dirname "$0")/../load-env.sh" 2>/dev/null || true
# Display usage information
usage() {
echo "Usage: $(basename "$0") <container-name> [version]"
echo
echo "Build and push a container image to the local registry from Dockerfile in containers/<container-name>"
echo
echo "Arguments:"
echo " container-name The name of the container (must exist in containers/ directory)"
echo " version Version tag for the image (default: latest)"
echo
echo "Example:"
echo " $(basename "$0") nextcloud"
echo " $(basename "$0") nextcloud 25.0.4-custom"
exit 1
}
# Check if required arguments are provided
if [ $# -lt 1 ]; then
usage
fi
CONTAINER_NAME="$1"
VERSION="${2:-latest}"
REGISTRY=$DOCKER_REGISTRY_HOST
CONTAINER_DIR="/data/repos/wild-cloud/containers/${CONTAINER_NAME}"
IMAGE_NAME="${REGISTRY}/${CONTAINER_NAME}:${VERSION}"
# Check if container directory exists
if [ ! -d "$CONTAINER_DIR" ]; then
echo "Error: Container directory not found: $CONTAINER_DIR"
echo "Available containers:"
ls -1 /data/repos/wild-cloud/containers/
exit 1
fi
# Check if Dockerfile exists
if [ ! -f "${CONTAINER_DIR}/Dockerfile" ]; then
echo "Error: Dockerfile not found in ${CONTAINER_DIR}"
exit 1
fi
echo "Building container: ${CONTAINER_NAME}"
echo "Dockerfile path: ${CONTAINER_DIR}/Dockerfile"
echo "Target image: ${IMAGE_NAME}"
echo
# Build the Docker image
echo "Building image..."
docker build -t "${IMAGE_NAME}" -f "${CONTAINER_DIR}/Dockerfile" "${CONTAINER_DIR}"
# Push the image to the registry
echo "Pushing image to registry: ${REGISTRY}..."
docker push "${IMAGE_NAME}"
echo
echo "Successfully built and pushed: ${IMAGE_NAME}"

View File

@@ -1,9 +1,4 @@
#!/bin/bash
set -e
SCRIPT_PATH="$(realpath "${BASH_SOURCE[0]}")"
SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
cd "$SCRIPT_DIR"
# Install gomplate
if command -v gomplate &> /dev/null; then
@@ -35,3 +30,12 @@ else
rm yq.1
echo "yq installed successfully."
fi
## Install restic
if command -v restic &> /dev/null; then
echo "restic is already installed."
else
sudo apt-get update
sudo apt-get install -y restic
echo "restic installed successfully."
fi