mirror of
https://github.com/dqzboy/Docker-Proxy.git
synced 2026-06-25 17:03:59 +08:00
feat: Add a UI interface for obtaining commands to pull images via a proxy.
This commit is contained in:
@@ -0,0 +1,276 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Docker 镜像代理加速</title>
|
||||
<link rel="icon" href="https://cdn.jsdelivr.net/gh/dqzboy/Blog-Image/BlogCourse/docker-proxy.png" type="image/png">
|
||||
<style>
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Lato', 'Helvetica', 'Arial', sans-serif;
|
||||
line-height: 1.6;
|
||||
color: #24292e;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #f6f8fa;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
}
|
||||
.header {
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
padding: 10px 30px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.header-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
max-width: 1200px;
|
||||
}
|
||||
.logo {
|
||||
max-height: 70px;
|
||||
}
|
||||
.nav-menu {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
font-size: 18px;
|
||||
margin-left: auto;
|
||||
}
|
||||
.nav-menu a {
|
||||
color: #0366d6;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: color 0.3s;
|
||||
}
|
||||
.nav-menu a:hover {
|
||||
color: #0056b3;
|
||||
}
|
||||
.container {
|
||||
max-width: 800px;
|
||||
width: 100%;
|
||||
margin: 20px auto;
|
||||
background: white;
|
||||
padding: 30px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
flex-grow: 1;
|
||||
}
|
||||
h1, h2 {
|
||||
border-bottom: 2px solid #eaecef;
|
||||
padding-bottom: 0.5em;
|
||||
margin-bottom: 1em;
|
||||
color: #0366d6;
|
||||
}
|
||||
.input-group {
|
||||
margin-bottom: 30px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
input[type="text"] {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
font-size: 16px;
|
||||
border: 1px solid #d1d5da;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 15px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
button {
|
||||
padding: 12px 20px;
|
||||
background-color: #2ea44f;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
transition: background-color 0.3s;
|
||||
align-self: flex-start;
|
||||
}
|
||||
button:hover {
|
||||
background-color: #2c974b;
|
||||
}
|
||||
pre {
|
||||
background-color: #f6f8fa;
|
||||
border-radius: 4px;
|
||||
padding: 16px;
|
||||
overflow: auto;
|
||||
font-size: 14px;
|
||||
border: 1px solid #e1e4e8;
|
||||
}
|
||||
.copy-btn {
|
||||
float: right;
|
||||
padding: 6px 12px;
|
||||
font-size: 12px;
|
||||
margin-top: -5px;
|
||||
background-color: #0366d6;
|
||||
}
|
||||
.copy-btn:hover {
|
||||
background-color: #0256b9;
|
||||
}
|
||||
.step {
|
||||
margin-bottom: 25px;
|
||||
background-color: #fff;
|
||||
border: 1px solid #e1e4e8;
|
||||
border-radius: 6px;
|
||||
padding: 20px;
|
||||
}
|
||||
.step h3 {
|
||||
margin-top: 0;
|
||||
color: #24292e;
|
||||
}
|
||||
.footer {
|
||||
background-color: #f6f8fa;
|
||||
color: #6a737d;
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.footer a {
|
||||
color: #58a6ff;
|
||||
text-decoration: none;
|
||||
}
|
||||
.footer a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
#backToTopBtn {
|
||||
display: none;
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
z-index: 100;
|
||||
font-size: 16px;
|
||||
padding: 10px;
|
||||
background-color: #0366d6;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
}
|
||||
#backToTopBtn:hover {
|
||||
background-color: #0256b9;
|
||||
}
|
||||
#backToTopBtn:before {
|
||||
display: inline-block;
|
||||
font-size: 20px;
|
||||
}
|
||||
#backToTopBtn::after {
|
||||
content: '返回顶部';
|
||||
display: none;
|
||||
position: absolute;
|
||||
bottom: 50px;
|
||||
right: 0;
|
||||
padding: 5px 10px;
|
||||
background-color: #333;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
#backToTopBtn:hover::after {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header class="header">
|
||||
<div class="header-content">
|
||||
<img src="https://cdn.jsdelivr.net/gh/dqzboy/Blog-Image/BlogCourse/docker-proxy.png" alt="Logo" class="logo">
|
||||
<nav class="nav-menu">
|
||||
<a href="https://www.dqzboy.com" target="_blank">首页</a>
|
||||
<a href="https://www.dqzboy.com" target="_blank">博客</a>
|
||||
<a href="https://www.dqzboy.com/zanzu" target="_blank">捐赠</a>
|
||||
<a href="https://t.me/dqzboyblog" target="_blank">交流群</a>
|
||||
<a href="https://github.com/dqzboy/Docker-Proxy" target="_blank">GitHub</a>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
<div class="container">
|
||||
<h1>Docker 镜像代理加速</h1>
|
||||
<div class="input-group">
|
||||
<input type="text" id="imageInput" placeholder="输入 Docker 镜像,例如:nginx 或 mysql:5.7">
|
||||
<button onclick="generateCommands()">获取加速命令</button>
|
||||
</div>
|
||||
<div id="result" style="display:none;">
|
||||
<h2>加速命令</h2>
|
||||
<div id="commandsContainer"></div>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="footer">
|
||||
<p>Copyright © <span id="currentYear"></span> dqzboy.com. All Rights Reserved. <a href="https://github.com/dqzboy/Docker-Proxy" target="_blank" rel="noopener noreferrer">Docker-Proxy</a>版权所有</p>
|
||||
</footer>
|
||||
|
||||
<button id="backToTopBtn" onclick="scrollToTop()">⌃</button>
|
||||
|
||||
<script>
|
||||
// 设置当前年份
|
||||
document.getElementById('currentYear').textContent = new Date().getFullYear();
|
||||
|
||||
function generateCommands() {
|
||||
const imageInput = document.getElementById('imageInput').value.trim();
|
||||
if (!imageInput) {
|
||||
alert('请输入 Docker 镜像');
|
||||
return;
|
||||
}
|
||||
|
||||
const proxyDomain = 'hub.dqzboy.xyz';
|
||||
let [imageName, tag] = imageInput.split(':');
|
||||
tag = tag || 'latest';
|
||||
|
||||
let originalImage = `${imageName}:${tag}`;
|
||||
let proxyImage = '';
|
||||
|
||||
if (!imageName.includes('/')) {
|
||||
proxyImage = `${proxyDomain}/library/${imageName}:${tag}`;
|
||||
} else {
|
||||
proxyImage = `${proxyDomain}/${imageName}:${tag}`;
|
||||
}
|
||||
|
||||
const commands = [
|
||||
{ title: "原始拉取命令", cmd: `docker pull ${originalImage}` },
|
||||
{ title: "代理拉取镜像", cmd: `docker pull ${proxyImage}` },
|
||||
{ title: "重命名镜像", cmd: `docker tag ${proxyImage} ${originalImage}` },
|
||||
{ title: "删除代理镜像", cmd: `docker rmi ${proxyImage}` }
|
||||
];
|
||||
|
||||
const resultDiv = document.getElementById('result');
|
||||
const container = document.getElementById('commandsContainer');
|
||||
container.innerHTML = '';
|
||||
|
||||
commands.forEach((command, index) => {
|
||||
const cmdDiv = document.createElement('div');
|
||||
cmdDiv.className = 'step';
|
||||
cmdDiv.innerHTML = `
|
||||
<h3>${index + 1}. ${command.title}</h3>
|
||||
<pre><code>${command.cmd}</code></pre>
|
||||
<button class="copy-btn" onclick="copyToClipboard('${command.cmd}')">复制</button>
|
||||
`;
|
||||
container.appendChild(cmdDiv);
|
||||
});
|
||||
|
||||
resultDiv.style.display = 'block';
|
||||
document.getElementById('backToTopBtn').style.display = 'block';
|
||||
}
|
||||
|
||||
function copyToClipboard(text) {
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
alert('命令已复制到剪贴板');
|
||||
}, (err) => {
|
||||
console.error('无法复制文本: ', err);
|
||||
});
|
||||
}
|
||||
|
||||
function scrollToTop() {
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -202,7 +202,21 @@ docker pull gcr.your_domain_name/google-containers/pause:3.1
|
||||
</table>
|
||||
|
||||
## 💻 UI
|
||||

|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td width="50%" align="center"><b>Docker Registry UI</b></td>
|
||||
<td width="50%" align="center"><b>Docker-Proxy CmdUI</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="50%" align="center">
|
||||
<img src="https://github.com/dqzboy/Docker-Proxy/assets/42825450/0ddb041b-64f6-4d93-b5bf-85ad3b53d0e0?raw=true" width="300" height="200">
|
||||
</td>
|
||||
<td width="50%" align="center">
|
||||
<img src="https://github.com/user-attachments/assets/7d9443cc-f94c-4c1a-9f0a-48ead46f2d0d?raw=true" width="300" height="200">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user