Add 16 files
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 8s

This commit is contained in:
j
2026-01-15 12:50:28 +13:00
parent 5ca696d215
commit 7c038bacc9
8 changed files with 107 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
# Caddy Static - Simple HTTP static file server
# https://caddyserver.com/
# Server Settings
SSH_USER="dropshell"
# Container name
CONTAINER_NAME=caddy-static
# Port to serve on
HTTP_PORT=8080
# Directory on host to serve (must exist)
STATIC_DIR=/path/to/static/files

21
caddy-static/install.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "CONTAINER_NAME" "HTTP_PORT" "STATIC_DIR"
# Verify static directory exists
[ -d "${STATIC_DIR}" ] || _die "Static directory does not exist: ${STATIC_DIR}"
# Pull the image
echo "Pulling Caddy image..."
docker pull caddy:alpine || _die "Failed to pull Caddy image"
# Stop existing container if running
bash "$(dirname "${BASH_SOURCE[0]}")/stop.sh" 2>/dev/null || true
# Start the service
bash "$(dirname "${BASH_SOURCE[0]}")/start.sh" || _die "Failed to start container"
echo "Installation complete for ${CONTAINER_NAME}."
echo "Static files served at http://localhost:${HTTP_PORT}"

7
caddy-static/logs.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "CONTAINER_NAME"
docker logs -f "$CONTAINER_NAME"

23
caddy-static/start.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "CONTAINER_NAME" "HTTP_PORT" "STATIC_DIR"
# Verify static directory exists
[ -d "${STATIC_DIR}" ] || _die "Static directory does not exist: ${STATIC_DIR}"
# Remove existing container if stopped
_remove_container "$CONTAINER_NAME" 2>/dev/null || true
# Start Caddy with file-server command
docker run -d \
--name "${CONTAINER_NAME}" \
--restart unless-stopped \
-p "${HTTP_PORT}:80" \
-v "${STATIC_DIR}:/srv:ro" \
caddy:alpine \
caddy file-server --root /srv --listen :80 \
|| _die "Failed to start container"
echo "Started ${CONTAINER_NAME} on port ${HTTP_PORT}"

11
caddy-static/status.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "CONTAINER_NAME"
if _is_container_running "$CONTAINER_NAME"; then
echo "Running"
else
echo "Stopped"
fi

11
caddy-static/stop.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "CONTAINER_NAME"
echo "Stopping ${CONTAINER_NAME}..."
_stop_container "$CONTAINER_NAME"
echo "Stopped ${CONTAINER_NAME}."

View File

@@ -0,0 +1,8 @@
# Template info - AUTO GENERATED, DO NOT EDIT
TEMPLATE=caddy-static
REQUIRES_HOST_ROOT=false
REQUIRES_DOCKER=true
REQUIRES_DOCKER_ROOT=false
# Default container name
CONTAINER_NAME=caddy-static

12
caddy-static/uninstall.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "CONTAINER_NAME"
echo "Uninstalling ${CONTAINER_NAME}..."
_remove_container "$CONTAINER_NAME"
echo "Uninstallation of ${CONTAINER_NAME} complete."
echo "Static files preserved at original location."