Skip to content

Commit

Permalink
Merge e3b7b95 into 8d12e46
Browse files Browse the repository at this point in the history
  • Loading branch information
donutloop authored Dec 5, 2018
2 parents 8d12e46 + e3b7b95 commit 8d43ff2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
12 changes: 2 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,15 @@ RUN mkdir -p /go/src/${PACKAGE}
WORKDIR /go/src/${PACKAGE}
COPY . /go/src/${PACKAGE}

RUN go build ${PACKAGE}/cmd/httpcache
RUN CGO_ENABLED=0 go build ${PACKAGE}/cmd/httpcache

FROM alpine:3.7

ENV PACKAGE=github.com/donutloop/httpcache

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

COPY --from=builder /go/src/${PACKAGE}/httpcache /httpcache
COPY --from=builder /go/src/${PACKAGE}/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

USER nobody:nobody

ENV PORT=":8000"
ENV CAP=1000000
ENV EXPIRE=5

EXPOSE 8000
ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["./httpcache"]
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,29 @@ FLAGS
-key server.key TLS key
-rbcl 524288000 response size limit
-tls serve TLS on this address (optional)
```

## Usage of cache from outside (GO Example)

```golang
...
transport := &http.Transport{
Proxy: SetProxyURL(proxyServer.URL), // Set url of http cache
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
}

client = &http.Client{
Transport: transport,
}

client.Do(req)
...
```
2 changes: 1 addition & 1 deletion cmd/httpcache/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func main() {

fs := flag.NewFlagSet("http-proxy", flag.ExitOnError)
var (
httpAddr = fs.String("http", ":80", "serve HTTP on this address (optional)")
httpAddr = fs.String("http", ":8000", "serve HTTP on this address (optional)")
tlsAddr = fs.String("tls", "", "serve TLS on this address (optional)")
cert = fs.String("cert", "server.crt", "TLS certificate")
key = fs.String("key", "server.key", "TLS key")
Expand Down
2 changes: 0 additions & 2 deletions entrypoint.sh

This file was deleted.

0 comments on commit 8d43ff2

Please sign in to comment.