docs(hugo): add Docker installation support

This commit is contained in:
iyear 2024-11-10 17:34:36 +08:00
parent 7fbe61e153
commit a6e95cef17
5 changed files with 215 additions and 6 deletions

View File

@ -36,7 +36,7 @@ $Block=[ScriptBlock]::Create($Script); Invoke-Command -ScriptBlock $Block -Argum
{{< /tab >}}
{{< tab "MacOS & Linux" >}}
{{< tab "macOS & Linux" >}}
`tdl` will be installed to `/usr/local/bin/tdl`, and script also can be used to upgrade `tdl`.
#### Install latest version
@ -114,6 +114,108 @@ nix-shell -p tdl
[![Packaging status](https://repology.org/badge/vertical-allrepos/telegram-downloader.svg)](https://repology.org/project/telegram-downloader/versions)
## Docker
Available images:
- [`iyear/tdl`](https://hub.docker.com/r/iyear/tdl)
- [`ghcr.io/iyear/tdl`](https://ghcr.io/iyear/tdl)
Available tags:
- `latest`(default): The latest stable release
- `X.Y.Z`: A specific version of `tdl`
{{< tabs "docker" >}}
{{< tab "Docker" >}}
To run `tdl` in one-off command:
{{< command >}}
docker run --rm -it iyear/tdl <ARGUMENTS>
{{< /command >}}
Further, to keep config persistent, you can mount the config directory:
{{< command >}}
docker run --rm -it \
-v $HOME/.tdl:/root/.tdl \
iyear/tdl <ARGUMENTS>
{{< /command >}}
To get download files, you can mount the download and other directories as needed:
{{< command >}}
docker run --rm -it \
-v $HOME/.tdl:/root/.tdl \
-v $HOME/Downloads:/downloads \
iyear/tdl <ARGUMENTS>
{{< /command >}}
To run `tdl` inside the container shell:
{{< command >}}
docker run --rm -it <FLAGS> --entrypoint sh iyear/tdl
{{< /command >}}
{{< details title="Preview output" open=false >}}
```1
/ # tdl version
Version: 0.17.7
Commit: ace2402
Date: 2024-11-01T14:40:56+08:00
go1.21.13 linux/amd64
/ #
```
{{< /details >}}
To use proxy with `localhost` address, run it with `host` network:
{{< command >}}
docker run --rm -it <FLAGS> --network host iyear/tdl <ARGUMENTS>
{{< /command >}}
{{< /tab >}}
{{< tab "Docker Compose" >}}
Run `tdl` with Docker Compose to avoid typing `docker run` flags each time.
{{< details title="docker-compose.yml" open=false >}}
{{< hint info >}}
Example configuration uses Docker Compose v2 syntax.
{{< /hint >}}
```yaml
services:
tdl:
image: iyear/tdl # or specify X.Y.Z tag for a specific version
volumes:
- $HOME/.tdl:/root/.tdl # keep config persistent
- $HOME/Downloads:/downloads # optional
# - /path/to/your/need:/path/in/container
stdin_open: true
tty: true
# use host network if you need to use proxy with localhost address
network_mode: host
```
{{< /details >}}
Run `tdl` with Docker Compose:
{{< command >}}
docker compose run --rm tdl <ARGUMENTS>
{{< /command >}}
To run `tdl` inside the container shell:
{{< command >}}
docker compose run --rm --entrypoint sh tdl
{{< /command >}}
{{< details title="Preview output" open=false >}}
```1
/ # tdl version
Version: 0.17.7
Commit: ace2402
Date: 2024-11-01T14:40:56+08:00
go1.21.13 linux/amd64
/ #
```
{{< /details >}}
{{< /tab >}}
{{< /tabs >}}
## Prebuilt Binaries
1. Download the archive for the desired operating system, and architecture:
@ -129,7 +231,7 @@ nix-shell -p tdl
{{< button href="https://github.com/iyear/tdl/releases/latest/download/tdl_Windows_armv7.zip" >}}armv7{{< /button >}}
{{< /tab >}}
{{< tab "MacOS" >}}
{{< tab "macOS" >}}
{{< button href="https://github.com/iyear/tdl/releases/latest/download/tdl_MacOS_64bit.tar.gz" >}}Intel{{< /button >}}
{{< button href="https://github.com/iyear/tdl/releases/latest/download/tdl_MacOS_arm64.tar.gz" >}}M1/M2{{< /button >}}
{{< /tab >}}

View File

@ -35,7 +35,7 @@ $Block=[ScriptBlock]::Create($Script); Invoke-Command -ScriptBlock $Block -Argum
{{< /tab >}}
{{< tab "MacOS Linux" >}}
{{< tab "macOS Linux" >}}
`tdl` 将被安装到 `/usr/local/bin/tdl`,该脚本还可用于升级 `tdl`
#### 安装最新版本
@ -113,6 +113,108 @@ nix-shell -p tdl
[![Packaging status](https://repology.org/badge/vertical-allrepos/telegram-downloader.svg)](https://repology.org/project/telegram-downloader/versions)
## Docker
可用镜像:
- [`iyear/tdl`](https://hub.docker.com/r/iyear/tdl)
- [`ghcr.io/iyear/tdl`](https://ghcr.io/iyear/tdl)
可用标签:
- `latest`(默认):最新的稳定版本
- `X.Y.Z``tdl`的特定版本
{{< tabs "docker" >}}
{{< tab "Docker" >}}
以一次性命令运行 `tdl`
{{< command >}}
docker run --rm -it iyear/tdl <ARGUMENTS>
{{< /command >}}
进一步,挂载配置目录以保持持久化:
{{< command >}}
docker run --rm -it \
-v $HOME/.tdl:/root/.tdl \
iyear/tdl <ARGUMENTS>
{{< /command >}}
为了方便获取下载的文件,可以挂载下载目录和其他需要的目录:
{{< command >}}
docker run --rm -it \
-v $HOME/.tdl:/root/.tdl \
-v $HOME/Downloads:/downloads \
iyear/tdl <ARGUMENTS>
{{< /command >}}
在容器内运行 `tdl`
{{< command >}}
docker run --rm -it <FLAGS> --entrypoint sh iyear/tdl
{{< /command >}}
{{< details title="预览输出" open=false >}}
```1
/ # tdl version
Version: 0.17.7
Commit: ace2402
Date: 2024-11-01T14:40:56+08:00
go1.21.13 linux/amd64
/ #
```
{{< /details >}}
如果希望使用 `localhost` 地址的代理,使用 `host` 网络运行:
{{< command >}}
docker run --rm -it <FLAGS> --network host iyear/tdl <ARGUMENTS>
{{< /command >}}
{{< /tab >}}
{{< tab "Docker Compose" >}}
使用 Docker Compose 运行 `tdl`,避免每次输入 `docker run` 选项。
{{< details title="docker-compose.yml" open=false >}}
{{< hint info >}}
示例配置使用 Docker Compose v2 语法。
{{< /hint >}}
```yaml
services:
tdl:
image: iyear/tdl # 或指定特定版本的 X.Y.Z 版本标签
volumes:
- $HOME/.tdl:/root/.tdl # 保持配置持久化
- $HOME/Downloads:/downloads # 可选
# - /path/to/your/need:/path/in/container
stdin_open: true
tty: true
# 如果需要使用 localhost 地址的代理,使用 host 网络
network_mode: host
```
{{< /details >}}
使用 Docker Compose 运行 `tdl`
{{< command >}}
docker compose run --rm tdl <ARGUMENTS>
{{< /command >}}
在容器内运行 `tdl`
{{< command >}}
docker compose run --rm --entrypoint sh tdl
{{< /command >}}
{{< details title="预览输出" open=false >}}
```1
/ # tdl version
Version: 0.17.7
Commit: ace2402
Date: 2024-11-01T14:40:56+08:00
go1.21.13 linux/amd64
/ #
```
{{< /details >}}
{{< /tab >}}
{{< /tabs >}}
## 预编译二进制
1. 下载指定操作系统和架构的压缩包:
@ -128,7 +230,7 @@ nix-shell -p tdl
{{< button href="https://github.com/iyear/tdl/releases/latest/download/tdl_Windows_armv7.zip" >}}armv7{{< /button >}}
{{< /tab >}}
{{< tab "MacOS" >}}
{{< tab "macOS" >}}
{{< button href="https://github.com/iyear/tdl/releases/latest/download/tdl_MacOS_64bit.tar.gz" >}}Intel{{< /button >}}
{{< button href="https://github.com/iyear/tdl/releases/latest/download/tdl_MacOS_arm64.tar.gz" >}}M1/M2{{< /button >}}
{{< /tab >}}

View File

@ -9,6 +9,8 @@ module:
# Needed for mermaid/katex shortcodes
markup:
highlight:
style: onedark
goldmark:
renderer:
unsafe: true

View File

@ -28,7 +28,10 @@
}, 300);
}, 1500);
return await originalWriteText.apply(this, arguments);
// Replace '\' with '\' and newline
const newText = text.replace(/\\/g, '\\\n');
return await originalWriteText.apply(this, [newText]);
},
writable: true,
configurable: true,

View File

@ -9,7 +9,7 @@
{{- if not $slash -}}
<code class="command" prompt="$">{{ $line }}</code><br>
{{- else -}}
<code class="command" prompt=" ">{{ $line }}</code><br>
<code class="command" prompt=" "> {{ $line }}</code><br>
{{- end -}}
{{- $slash = hasSuffix $line "\\" -}}
{{- end -}}