mirror of https://github.com/goproxyio/goproxy
fix docker build
parent
477f7b3d7a
commit
043c484e5e
|
@ -1,6 +1,8 @@
|
|||
goproxy
|
||||
go_repos/*
|
||||
cacheDir/*
|
||||
.idea/*
|
||||
bin/*
|
||||
|
||||
pkg/*
|
||||
!pkg/proxy
|
||||
!pkg/proxy
|
||||
|
|
18
Dockerfile
18
Dockerfile
|
@ -1,3 +1,15 @@
|
|||
FROM alpine:3.8
|
||||
RUN apk add --no-cache git mercurial subversion bzr fossil
|
||||
COPY bin/goproxy /usr/bin/goproxy
|
||||
FROM golang:1.11 AS build
|
||||
|
||||
env GO111MODULE on
|
||||
env GOROOT /usr/local/go
|
||||
|
||||
COPY ./ /goproxy
|
||||
WORKDIR /goproxy
|
||||
RUN go generate
|
||||
RUN go build
|
||||
|
||||
FROM buildpack-deps:stretch-scm
|
||||
COPY --from=build /goproxy/goproxy /bin/goproxy
|
||||
EXPOSE 8081
|
||||
|
||||
CMD ["goproxy"]
|
14
README.md
14
README.md
|
@ -9,15 +9,19 @@ A global proxy for go modules. see: [https://goproxy.io](https://goproxy.io)
|
|||
|
||||
## Started
|
||||
|
||||
./goproxy -listen=0.0.0.0:80 -cacheDir=/cache
|
||||
./goproxy -listen=0.0.0.0:80 -cacheDir=/data
|
||||
|
||||
## Docker
|
||||
## Docker build
|
||||
|
||||
docker run --name goproxy -d -p80:8081 goproxyio/goproxy
|
||||
docker build . --no-cache -t goproxy/goproxy:latest
|
||||
|
||||
Use the -v flag to persisting the proxy module data (change ___go_repo___ to your own dir):
|
||||
## Docker run
|
||||
|
||||
docker run --name goproxy -d -p80:8081 -v go_repo:/cache goproxyio/goproxy
|
||||
docker run --name goproxy -d -p80:8081 goproxy/goproxy
|
||||
|
||||
Use the -v flag to persisting the proxy module data (change ___cacheDir___ to your own dir):
|
||||
|
||||
docker run --name goproxy -d -p80:8081 -v cacheDir:/go goproxy/goproxy
|
||||
|
||||
## Docker Compose
|
||||
|
||||
|
|
|
@ -7,4 +7,4 @@ services:
|
|||
- "8081:8081"
|
||||
restart: always
|
||||
volumes:
|
||||
- ./go_repos:/ext
|
||||
- ./cacheDir:/ext
|
||||
|
|
8
main.go
8
main.go
|
@ -33,9 +33,11 @@ func main() {
|
|||
if cacheDir == "" {
|
||||
cacheDir = "/go"
|
||||
gpEnv := os.Getenv("GOPATH")
|
||||
gp := filepath.SplitList(gpEnv)
|
||||
if gp[0] != "" {
|
||||
cacheDir = gp[0]
|
||||
if gpEnv != "" {
|
||||
gp := filepath.SplitList(gpEnv)
|
||||
if gp[0] != "" {
|
||||
cacheDir = gp[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
fullCacheDir := filepath.Join(cacheDir, "pkg", "mod", "cache", "download")
|
||||
|
|
Loading…
Reference in New Issue