Skip to content

Commit

Permalink
chore: add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Sep 22, 2024
1 parent 3aaaf8d commit deab285
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
app:
# image: registry.tbxark.cn/docker-registry-proxy:latest
build: .
network_mode: bridge
container_name: docker-registry-proxy
pull_policy: always
ports:
- "8989:8989"
restart: always
command: ["--address", "0.0.0.0:8989", "--registry", "mirror.ccs.tencentyun.com"]
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func main() {

proxy := NewRegistryProxy(registryHost)
http.HandleFunc("/", proxy.handler)
log.Printf("server start: %s", serveAddress)
log.Fatal(http.ListenAndServe(serveAddress, nil))
}

Expand All @@ -49,6 +50,7 @@ func NewRegistryProxy(host string) *RegistryProxy {
func (p *RegistryProxy) handler(w http.ResponseWriter, r *http.Request) {
path := r.URL.Path
originalHost := r.Host
log.Printf("[%s] %s", r.Method, path)
if strings.HasPrefix(path, "/v2/") {
registryURL := fmt.Sprintf("https://%s%s", p.host, path)
req, err := http.NewRequest(r.Method, registryURL, r.Body)
Expand Down

0 comments on commit deab285

Please sign in to comment.