mirror of
https://github.com/nickyeoman/docker-compose-cookbooks.git
synced 2026-12-06 12:28:50 +00:00
Add metube stack and dockhand-stack_dev.bash
MeTube (yt-dlp web UI) downloads into the shared media folder so Lidarr can manual-import with hardlinks. First stack to use a configurable container_name. dockhand-stack_dev.bash creates a Dockhand git stack via the API with sample.env preloaded as editable stack variables (untested). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Executable
+84
@@ -0,0 +1,84 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Create a Dockhand git stack for a cookbook, with sample.env preloaded as
|
||||||
|
# editable stack environment variables. Does NOT deploy unless --deploy.
|
||||||
|
|
||||||
|
show_help() {
|
||||||
|
cat <<EOF
|
||||||
|
USAGE:
|
||||||
|
$0 <stack-dir> [--name <stack-name>] [--deploy]
|
||||||
|
|
||||||
|
Creates a git stack in Dockhand from this repo:
|
||||||
|
compose path <stack-dir>/compose.yaml
|
||||||
|
env file <stack-dir>/sample.env
|
||||||
|
variables every KEY=VALUE in sample.env (edit them in Dockhand)
|
||||||
|
|
||||||
|
REQUIRED ENV:
|
||||||
|
DOCKHAND_URL e.g. https://dockhand.example.com
|
||||||
|
DOCKHAND_TOKEN API token (dh_...), Settings -> API Tokens
|
||||||
|
|
||||||
|
OPTIONAL ENV:
|
||||||
|
DOCKHAND_REPO git repository name in Dockhand (default: cookbooks, case-insensitive match)
|
||||||
|
DOCKHAND_ENV environment name to deploy to (default: the only/first environment)
|
||||||
|
|
||||||
|
EXAMPLE:
|
||||||
|
DOCKHAND_URL=https://dockhand.example.com DOCKHAND_TOKEN=dh_xxx $0 metube
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
STACK_DIR="" ; STACK_NAME="" ; DEPLOY=false
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
-h|--help) show_help; exit 0 ;;
|
||||||
|
--deploy) DEPLOY=true ;;
|
||||||
|
--name) STACK_NAME="$2"; shift ;;
|
||||||
|
*) STACK_DIR="${1%/}" ;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
[[ -z "$STACK_DIR" ]] && { show_help; exit 1; }
|
||||||
|
: "${DOCKHAND_URL:?set DOCKHAND_URL}" "${DOCKHAND_TOKEN:?set DOCKHAND_TOKEN}"
|
||||||
|
command -v jq >/dev/null || { echo "jq is required" >&2; exit 1; }
|
||||||
|
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
[[ -f "$STACK_DIR/compose.yaml" ]] || { echo "No $STACK_DIR/compose.yaml" >&2; exit 1; }
|
||||||
|
ENV_FILE="$STACK_DIR/sample.env"
|
||||||
|
STACK_NAME="${STACK_NAME:-$(echo "$STACK_DIR" | tr '[:upper:]' '[:lower:]')}"
|
||||||
|
DOCKHAND_URL="${DOCKHAND_URL%/}"
|
||||||
|
|
||||||
|
api() {
|
||||||
|
curl -fsS -H "Authorization: Bearer $DOCKHAND_TOKEN" -H "Content-Type: application/json" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Resolve repository id by name
|
||||||
|
REPO_NAME="${DOCKHAND_REPO:-cookbooks}"
|
||||||
|
REPO_ID=$(api "$DOCKHAND_URL/api/git/repositories" |
|
||||||
|
jq -r --arg n "$REPO_NAME" 'map(select(.name | ascii_downcase | contains($n | ascii_downcase))) | .[0].id // empty')
|
||||||
|
[[ -n "$REPO_ID" ]] || { echo "No Dockhand git repository matching '$REPO_NAME'" >&2; exit 1; }
|
||||||
|
|
||||||
|
# Resolve environment id
|
||||||
|
ENV_ID=$(api "$DOCKHAND_URL/api/environments" |
|
||||||
|
jq -r --arg n "${DOCKHAND_ENV:-}" 'if $n == "" then .[0].id else (map(select(.name == $n)) | .[0].id) end // empty')
|
||||||
|
[[ -n "$ENV_ID" ]] || { echo "No Dockhand environment '${DOCKHAND_ENV:-}'" >&2; exit 1; }
|
||||||
|
|
||||||
|
# sample.env -> [{key, value, isSecret}]; ChangeThisPassword values are marked secret
|
||||||
|
ENV_VARS='[]'
|
||||||
|
if [[ -f "$ENV_FILE" ]]; then
|
||||||
|
ENV_VARS=$(grep -E '^[A-Za-z_][A-Za-z0-9_]*=' "$ENV_FILE" | jq -R -s '
|
||||||
|
split("\n") | map(select(length > 0) | capture("^(?<key>[^=]+)=(?<value>.*)$")
|
||||||
|
| .value |= (sub("^\"(?<v>.*)\"$"; "\(.v)"))
|
||||||
|
| .isSecret = (.value == "ChangeThisPassword"))')
|
||||||
|
fi
|
||||||
|
|
||||||
|
BODY=$(jq -n \
|
||||||
|
--arg name "$STACK_NAME" --argjson repo "$REPO_ID" --argjson env "$ENV_ID" \
|
||||||
|
--arg compose "$STACK_DIR/compose.yaml" --arg envfile "$ENV_FILE" \
|
||||||
|
--argjson vars "$ENV_VARS" --argjson deploy "$DEPLOY" \
|
||||||
|
'{stackName: $name, repositoryId: $repo, environmentId: $env,
|
||||||
|
composePath: $compose, envFilePath: $envfile, envVars: $vars, deployNow: $deploy}')
|
||||||
|
|
||||||
|
echo "Creating stack '$STACK_NAME' (repo $REPO_ID, env $ENV_ID, $(echo "$ENV_VARS" | jq length) vars)..."
|
||||||
|
api -X POST "$DOCKHAND_URL/api/git/stacks" -d "$BODY" >/dev/null
|
||||||
|
echo "Done. Review the variables in Dockhand, then deploy."
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
# MeTube
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
MeTube is a self-hosted web UI for yt-dlp. Paste a video or playlist URL from YouTube (or any of the hundreds of sites yt-dlp supports) and it downloads the media to the server.
|
||||||
|
|
||||||
|
## Project Details
|
||||||
|
|
||||||
|
- **Project Repository:** [https://github.com/alexta69/metube](https://github.com/alexta69/metube)
|
||||||
|
- **Container Image:** [ghcr.io/alexta69/metube](https://github.com/alexta69/metube/pkgs/container/metube)
|
||||||
|
- **Documentation:** [README](https://github.com/alexta69/metube#readme)
|
||||||
|
- **Reverse Proxy Port:** `8081`
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
1. Start the container: `docker compose up -d`
|
||||||
|
2. Open http://localhost:8081 in your browser
|
||||||
|
3. Paste a URL, pick a quality/format, and click **Add**. Finished files land in the downloads volume.
|
||||||
|
|
||||||
|
## Environment Variable Notes
|
||||||
|
|
||||||
|
| Variable | Description |
|
||||||
|
|---|---|
|
||||||
|
| `METUBE_IMAGE` | Container image (default: `ghcr.io/alexta69/metube:latest`) |
|
||||||
|
| `METUBE_CONTAINER_NAME` | Container name shown in Dockhand / `docker ps` (default: `metube`) |
|
||||||
|
| `METUBE_RESTART` | Restart policy (default: `unless-stopped`) |
|
||||||
|
| `METUBE_PORT` | Published port for the web UI (default: `8081`) |
|
||||||
|
| `METUBE_MEDIA` | Shared media root on the host (default: `/data`, so files land in `/data/media/downloads/metube`). Must be the same root Lidarr, Jellyfin, etc. use |
|
||||||
|
|
||||||
|
`UID`/`GID`/`UMASK` are fixed at `1000`/`1000`/`002` (same as the other media apps) in the compose file so downloaded files are owned by your normal user. Many more options (`DARK_MODE`, `YTDL_OPTIONS`, `OUTPUT_TEMPLATE`, `DEFAULT_THEME`, …) are listed in the upstream README.
|
||||||
|
|
||||||
|
## Volume Notes
|
||||||
|
|
||||||
|
| Volume | Purpose |
|
||||||
|
|---|---|
|
||||||
|
| `${METUBE_MEDIA:-/data}/media/downloads/metube` → `/downloads` | Downloaded files and the queue/history state (`.metube` folder). Lives in the shared media downloads folder so Lidarr can see it as `/media/downloads/metube` |
|
||||||
|
|
||||||
|
## Network Notes
|
||||||
|
|
||||||
|
Requires an external `proxy` network. Create it once with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker network create proxy
|
||||||
|
```
|
||||||
|
|
||||||
|
## Docker Run
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -d \
|
||||||
|
--name=metube \
|
||||||
|
-e UID=1000 \
|
||||||
|
-e GID=1000 \
|
||||||
|
-e UMASK=002 \
|
||||||
|
-p 8081:8081 \
|
||||||
|
-v ${METUBE_MEDIA:-/data}/media/downloads/metube:/downloads \
|
||||||
|
--network proxy \
|
||||||
|
--restart unless-stopped \
|
||||||
|
ghcr.io/alexta69/metube:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
## Additional Notes / Gotchas
|
||||||
|
|
||||||
|
- **Importing music into Lidarr.** MeTube writes to `/data/media/downloads/metube`, which Lidarr sees as `/media/downloads/metube`. In Lidarr go to **Wanted → Manual Import**, pick that folder, match the tracks to an artist/album and import. Because both folders are on the same `/data/media` filesystem, Lidarr hardlinks the files (enable **Settings → Media Management → Use Hardlinks instead of Copy**) instead of copying them.
|
||||||
|
- **Don't point MeTube straight at `/media/music`.** Lidarr only recognizes files inside its `Artist/Album/` layout, so loose MeTube files there show up as unmapped instead of being imported.
|
||||||
|
- Create the folder as user 1000 first (`sudo mkdir -p /data/media/downloads/metube && sudo chown -R 1000:1000 /data/media/downloads/metube`). MeTube runs as UID/GID 1000 to match the other media apps.
|
||||||
|
- MeTube has no built-in authentication — put it behind an auth layer (NPM access list, Authelia, etc.) if exposed publicly.
|
||||||
|
- yt-dlp breaks periodically when sites change; pull the latest image to get fixes.
|
||||||
|
|
||||||
|
## Dockhand Stack, Deploy from Git
|
||||||
|
|
||||||
|
- **Cookbooks Repository**
|
||||||
|
- **stackname:** metube
|
||||||
|
- **Compose file path:** metube/compose.yaml
|
||||||
|
- **Additional env file (optional):** metube/sample.env
|
||||||
|
|
||||||
|
Load `metube/sample.env` into the Environment variables in Dockhand, then create the Stack.
|
||||||
|
|
||||||
|
Or create it from the CLI with the defaults preloaded (edit the variables in Dockhand, then deploy):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DOCKHAND_URL=https://dockhand.example.com DOCKHAND_TOKEN=dh_xxx ./dockhand-stack_dev.bash metube
|
||||||
|
```
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
services:
|
||||||
|
metube:
|
||||||
|
image: ${METUBE_IMAGE:-ghcr.io/alexta69/metube:latest}
|
||||||
|
container_name: ${METUBE_CONTAINER_NAME:-metube}
|
||||||
|
restart: ${METUBE_RESTART:-unless-stopped}
|
||||||
|
volumes:
|
||||||
|
- ${METUBE_MEDIA:-/data}/media/downloads/metube:/downloads
|
||||||
|
environment:
|
||||||
|
- UID=1000
|
||||||
|
- GID=1000
|
||||||
|
- UMASK=002
|
||||||
|
ports:
|
||||||
|
- "${METUBE_PORT:-8081}:8081"
|
||||||
|
networks:
|
||||||
|
- proxy
|
||||||
|
|
||||||
|
networks:
|
||||||
|
proxy:
|
||||||
|
external: true
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# MeTube
|
||||||
|
METUBE_IMAGE=ghcr.io/alexta69/metube:latest
|
||||||
|
METUBE_CONTAINER_NAME=metube
|
||||||
|
METUBE_PORT=8081
|
||||||
|
METUBE_RESTART=unless-stopped
|
||||||
|
METUBE_MEDIA=/data
|
||||||
Reference in New Issue
Block a user