mirror of https://github.com/goproxyio/goproxy
add docker support
parent
42316d3ead
commit
59e1de8487
|
@ -1 +1,4 @@
|
|||
goproxy
|
||||
build/*
|
||||
go_repos/*
|
||||
.idea/*
|
|
@ -0,0 +1,8 @@
|
|||
FROM golang:1.11
|
||||
|
||||
COPY ./ /goproxy
|
||||
WORKDIR /goproxy
|
||||
RUN go build
|
||||
|
||||
CMD ["/goproxy/goproxy","-listen=0.0.0.0:8080"]
|
||||
|
14
README.md
14
README.md
|
@ -10,3 +10,17 @@ A global proxy for go modules. see: [https://goproxy.io](https://goproxy.io)
|
|||
## Started
|
||||
|
||||
./goproxy -listen=0.0.0.0:80
|
||||
|
||||
## Docker
|
||||
|
||||
docker run -it goproxyio/goproxy
|
||||
|
||||
Use the -v flag to persisting the proxy module data (change ___go_repo___ to your own dir):
|
||||
|
||||
docker run -it -v go_repo:/go/pkg/mod/cache/download goproxyio/goproxy
|
||||
|
||||
## Docker Compose
|
||||
|
||||
docker-compose up
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
version: "3"
|
||||
services:
|
||||
|
||||
goproxy:
|
||||
image: goproxyio/goproxy:latest
|
||||
ports:
|
||||
- "8080"
|
||||
restart: always
|
||||
volumes:
|
||||
- ./go_repos:/go/pkg/mod/cache/download
|
5
main.go
5
main.go
|
@ -28,8 +28,13 @@ func main() {
|
|||
if gpEnv == "" {
|
||||
panic("can not find $GOPATH")
|
||||
}
|
||||
fmt.Fprintf(os.Stdout, "goproxy: %s inited.\n", time.Now().Format("2006-01-02 15:04:05"))
|
||||
gp := filepath.SplitList(gpEnv)
|
||||
cacheDir = filepath.Join(gp[0], "pkg", "mod", "cache", "download")
|
||||
if _, err := os.Stat(cacheDir); os.IsNotExist(err) {
|
||||
fmt.Fprintf(os.Stdout, "goproxy: %s cache dir is not exist. %s\n", time.Now().Format("2006-01-02 15:04:05"), cacheDir)
|
||||
os.MkdirAll(cacheDir, 0644)
|
||||
}
|
||||
http.Handle("/", mainHandler(http.FileServer(http.Dir(cacheDir))))
|
||||
err := http.ListenAndServe(listen, nil)
|
||||
if nil != err {
|
||||
|
|
Loading…
Reference in New Issue