优化配置

This commit is contained in:
NewName
2024-11-15 03:02:14 +08:00
parent 6147b8527f
commit f55e5e4163
5 changed files with 25 additions and 19 deletions

View File

@@ -8,7 +8,7 @@
--- ---
1域名解析到你的服务器,将`k8sgcr``ghcr``gcr``docker``registryk8s`这个几个配置解析为你的二级域名。 1域名解析:将`hub``quay``ghcr``gcr``docker``registryk8s`这个几个解析为你的二级域名。
> 直接泛解析更方便 > 直接泛解析更方便
@@ -19,10 +19,10 @@ git clone https://github.com/sky22333/docker-proxy.git
``` ```
3其他无需修改只需修改`docker-compose.yml`配置里的域名环境变量,修改为你的域名 3其他无需修改只需修改`docker-compose.yml`配置里的域名环境变量,修改为你的域名
然后启动即可。 然后启动即可。
``` ```
docker compose up -d docker compose up -d
``` ```
4部署完成后访问域名查看 4部署完成后访问`hub.example.com`查看前端

View File

@@ -12,12 +12,12 @@ services:
- DOMAIN=example.com # 修改为你的域名 - DOMAIN=example.com # 修改为你的域名
restart: always restart: always
k8sgcr: quay:
image: "registry:2.8.3" image: "registry:2.8.3"
container_name: "k8sgcr" container_name: "quay"
restart: "always" restart: "always"
volumes: volumes:
- "./k8sgcr/config.yml:/etc/docker/registry/config.yml" - "./quay/config.yml:/etc/docker/registry/config.yml"
ghcr: ghcr:
image: "registry:2.8.3" image: "registry:2.8.3"

View File

@@ -13,4 +13,4 @@ storage:
http: http:
addr: 0.0.0.0:5000 addr: 0.0.0.0:5000
proxy: proxy:
remoteurl: https://k8s.gcr.io remoteurl: https://quay.io

View File

@@ -1,4 +1,4 @@
{$DOMAIN} { hub.{$DOMAIN} {
root * /srv root * /srv
file_server file_server
} }
@@ -15,8 +15,8 @@ gcr.{$DOMAIN} {
reverse_proxy * gcr:5000 reverse_proxy * gcr:5000
} }
k8sgcr.{$DOMAIN} { quay.{$DOMAIN} {
reverse_proxy * k8sgcr:5000 reverse_proxy * quay:5000
} }
registryk8s.{$DOMAIN} { registryk8s.{$DOMAIN} {

View File

@@ -91,23 +91,23 @@
<div class="domain-container"> <div class="domain-container">
<div class="domain-item"> <div class="domain-item">
<div class="domain-text">docker.<span id="domain-base"></span></div> <div class="domain-text">docker.<span id="domain-docker"></span></div>
<button class="copy-button">复制</button> <button class="copy-button">复制</button>
</div> </div>
<div class="domain-item"> <div class="domain-item">
<div class="domain-text">ghcr.<span id="domain-base"></span></div> <div class="domain-text">ghcr.<span id="domain-ghcr"></span></div>
<button class="copy-button">复制</button> <button class="copy-button">复制</button>
</div> </div>
<div class="domain-item"> <div class="domain-item">
<div class="domain-text">gcr.<span id="domain-base"></span></div> <div class="domain-text">gcr.<span id="domain-gcr"></span></div>
<button class="copy-button">复制</button> <button class="copy-button">复制</button>
</div> </div>
<div class="domain-item"> <div class="domain-item">
<div class="domain-text">k8sgcr.<span id="domain-base"></span></div> <div class="domain-text">quay.<span id="domain-quay"></span></div>
<button class="copy-button">复制</button> <button class="copy-button">复制</button>
</div> </div>
<div class="domain-item"> <div class="domain-item">
<div class="domain-text">registryk8s.<span id="domain-base"></span></div> <div class="domain-text">registryk8s.<span id="domain-registryk8s"></span></div>
<button class="copy-button">复制</button> <button class="copy-button">复制</button>
</div> </div>
</div> </div>
@@ -127,11 +127,17 @@
</div> </div>
<script> <script>
const domainBase = new URL(window.location.href).hostname.replace(/^www\./, ''); // 从 Docker 环境变量获取根域名
document.querySelectorAll('#domain-base').forEach(el => { const rootDomain = process.env.DOMAIN || 'example.com';
el.textContent = domainBase;
});
// 动态设置每个仓库的根域名部分
document.getElementById('domain-docker').textContent = rootDomain;
document.getElementById('domain-ghcr').textContent = rootDomain;
document.getElementById('domain-gcr').textContent = rootDomain;
document.getElementById('domain-quay').textContent = rootDomain;
document.getElementById('domain-registryk8s').textContent = rootDomain;
// 复制按钮功能
document.querySelectorAll('.copy-button').forEach(button => { document.querySelectorAll('.copy-button').forEach(button => {
button.addEventListener('click', async () => { button.addEventListener('click', async () => {
const domainText = button.previousElementSibling.textContent; const domainText = button.previousElementSibling.textContent;