-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsave-docker-images.sh
More file actions
executable file
·164 lines (140 loc) · 6.72 KB
/
save-docker-images.sh
File metadata and controls
executable file
·164 lines (140 loc) · 6.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/env bash
# Save Docker images for offline distribution
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
IMAGES_DIR="${SCRIPT_DIR}/docker-images"
# Function to display image information
print_images_info() {
local show_names=${1:-false}
if [[ "$show_names" == "false" ]]; then
echo "=== Saving Docker Images for Offline Use ==="
echo "This will download and save the following images:"
else
echo "📋 Available images for offline use:"
fi
echo " 📚 Kiwix: $([ "$show_names" == "true" ] && echo "ghcr.io/kiwix/kiwix-serve:latest" || echo "server for offline content")"
echo " 🌐 Zimit: $([ "$show_names" == "true" ] && echo "ghcr.io/openzim/zimit:latest" || echo "for web content archiving")"
echo " 🤖 Ollama: $([ "$show_names" == "true" ] && echo "ollama/ollama:latest" || echo "for local AI models")"
echo " 🌐 Open WebUI: $([ "$show_names" == "true" ] && echo "ghcr.io/open-webui/open-webui:main" || echo "for AI chat interface")"
echo " 🎉 Ollama Chat Party: $([ "$show_names" == "true" ] && echo "psyb0t/ollama-chat-party:latest" || echo "for RAG-enabled chat")"
echo " 🦙 LLaMA.cpp CPU: $([ "$show_names" == "true" ] && echo "ghcr.io/ggml-org/llama.cpp:light" || echo "for local LLM inference")"
echo " 🦙 LLaMA.cpp GPU: $([ "$show_names" == "true" ] && echo "ghcr.io/ggml-org/llama.cpp:light-cuda" || echo "for GPU-accelerated LLM inference")"
echo " 🖥️ LLaMA.cpp Server CPU: $([ "$show_names" == "true" ] && echo "ghcr.io/ggml-org/llama.cpp:server" || echo "for local LLM server with web UI")"
echo " 🖥️ LLaMA.cpp Server GPU: $([ "$show_names" == "true" ] && echo "ghcr.io/ggml-org/llama.cpp:server-cuda" || echo "for GPU LLM server with web UI")"
echo " 💬 TheLounge: $([ "$show_names" == "true" ] && echo "thelounge/thelounge:latest" || echo "for web-based IRC client")"
echo " 🌐 InspIRCd: $([ "$show_names" == "true" ] && echo "inspircd/inspircd-docker:latest" || echo "for IRC server hosting")"
echo " 📻 Icecast: $([ "$show_names" == "true" ] && echo "libretime/icecast:latest" || echo "for audio streaming")"
echo " 📁 Nginx: $([ "$show_names" == "true" ] && echo "nginx:alpine" || echo "web server")"
echo " 🐍 Python: $([ "$show_names" == "true" ] && echo "python:3.12" || echo "runtime")"
echo " 🐹 Go: $([ "$show_names" == "true" ] && echo "golang:1.24" || echo "development environment")"
echo " 🖥️ Base: $([ "$show_names" == "true" ] && echo "ubuntu:22.04" || echo "Ubuntu OS for containers")"
}
print_images_info
echo ""
# Create images directory if it doesn't exist
mkdir -p "$IMAGES_DIR"
# List of images to save
IMAGES=(
# Offline content server
"ghcr.io/kiwix/kiwix-serve:latest"
"ghcr.io/openzim/zimit:latest" # Web content archiving tool
# AI/LLM server and UI
"ollama/ollama:latest" # Local AI model server
"ghcr.io/open-webui/open-webui:main" # Web UI for Ollama
"psyb0t/ollama-chat-party:latest" # RAG-enabled chat interface
# LLaMA.cpp runtime containers
"ghcr.io/ggml-org/llama.cpp:light" # CPU-only llama.cpp runtime
"ghcr.io/ggml-org/llama.cpp:light-cuda" # GPU-enabled llama.cpp runtime
"ghcr.io/ggml-org/llama.cpp:server" # CPU-only llama.cpp server with web UI
"ghcr.io/ggml-org/llama.cpp:server-cuda" # GPU-enabled llama.cpp server with web UI
# IRC chat network
"thelounge/thelounge:latest" # Web-based IRC client
"inspircd/inspircd-docker:latest" # IRC server
# Audio streaming
"libretime/icecast:latest" # Audio streaming server
# Web server
"nginx:alpine" # Web server (used for file server)
# Programming language runtimes (full versions)
"python:3.12" # Latest stable Python (full)
"golang:1.24" # Latest stable Go (full)
# Base operating system for development
"ubuntu:22.04" # LTS Ubuntu for general development
)
# Pull and save each image
for image in "${IMAGES[@]}"; do
echo ""
echo "Processing: $image"
# Extract image name for filename (replace / and : with -)
filename=$(echo "$image" | sed 's|/|-|g' | sed 's|:|_|g')
tarfile="${IMAGES_DIR}/${filename}.tar"
# Check if we need to update this image
needs_update=false
# Check if local image exists and get its ID
local_image_id=$(docker images -q "$image" 2>/dev/null)
if [[ -z "$local_image_id" ]]; then
echo " ↳ Image not found locally, pulling..."
if docker pull "$image"; then
echo " ↳ Pull successful"
needs_update=true
else
echo " ❌ Failed to pull $image"
exit 1
fi
else
# Check if there's a newer version available
echo " ↳ Checking for updates..."
if docker pull "$image"; then
new_image_id=$(docker images -q "$image" 2>/dev/null)
if [[ "$local_image_id" != "$new_image_id" ]]; then
echo " ↳ New version found, will update"
needs_update=true
else
echo " ↳ Image is up to date"
# Check if tar file exists and is newer than a reasonable threshold
if [[ -f "$tarfile" ]]; then
echo " ↳ Tar file already exists, skipping"
size=$(du -h "$tarfile" | cut -f1)
echo " 📦 Existing size: $size"
continue
else
echo " ↳ Tar file missing, will create"
needs_update=true
fi
fi
else
echo " ↳ Could not check for updates, using local image"
if [[ -f "$tarfile" ]]; then
echo " ↳ Tar file already exists, skipping"
size=$(du -h "$tarfile" | cut -f1)
echo " 📦 Existing size: $size"
continue
else
needs_update=true
fi
fi
fi
if [[ "$needs_update" == "true" ]]; then
echo " ↳ Saving to: $tarfile"
if docker save -o "$tarfile" "$image"; then
echo " ✅ Saved successfully"
# Show file size
size=$(du -h "$tarfile" | cut -f1)
echo " 📦 Size: $size"
else
echo " ❌ Failed to save $image"
exit 1
fi
fi
done
echo ""
echo "🎉 All images saved to: $IMAGES_DIR"
echo ""
echo "Files created:"
ls -lh "$IMAGES_DIR"/*.tar
echo ""
echo "Total size:"
du -sh "$IMAGES_DIR"
echo ""
print_images_info true
echo ""
echo "Use ./load-docker-images.sh on offline systems to load these images"