Compare commits
No commits in common. "96d49bc25a5e41d8b2d338065349c3acc341fc4b" and "fa1c796f3c2677e8c702d2fc8d1bc7ca44e4e185" have entirely different histories.
96d49bc25a
...
fa1c796f3c
3
.gitignore
vendored
3
.gitignore
vendored
@ -16,6 +16,3 @@ build/
|
|||||||
|
|
||||||
# APFS cache
|
# APFS cache
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
# Docker compose
|
|
||||||
data
|
|
@ -1,5 +1,7 @@
|
|||||||
# === BUILD STAGE === #
|
# === BUILD STAGE === #
|
||||||
FROM golang:1.20-alpine3.16 as build
|
FROM golang:1.12-alpine as build
|
||||||
|
|
||||||
|
ARG ACCESS_TOKEN
|
||||||
|
|
||||||
RUN apk add --no-cache git
|
RUN apk add --no-cache git
|
||||||
|
|
||||||
@ -14,7 +16,7 @@ RUN go test -v ./...
|
|||||||
RUN go build -ldflags="-w -s" -o build
|
RUN go build -ldflags="-w -s" -o build
|
||||||
|
|
||||||
# === RUN STAGE === #
|
# === RUN STAGE === #
|
||||||
FROM registry.odit.services/hub/library/alpine:3.16 as run
|
FROM alpine as run
|
||||||
|
|
||||||
RUN apk update \
|
RUN apk update \
|
||||||
&& apk upgrade \
|
&& apk upgrade \
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
version: '3.3'
|
|
||||||
services:
|
|
||||||
redis:
|
|
||||||
image: redis/redis-stack
|
|
||||||
ports:
|
|
||||||
- 6379:6379
|
|
||||||
- 8001:8001
|
|
||||||
volumes:
|
|
||||||
- ./data:/data
|
|
||||||
cache:
|
|
||||||
# image: registry.odit.services/npm-cache-proxy:latest
|
|
||||||
build: .
|
|
||||||
ports:
|
|
||||||
- 8080:8080
|
|
||||||
environment:
|
|
||||||
- REDIS_ADDRESS=redis:6379
|
|
||||||
- CACHE_TTL=43200 #12h
|
|
||||||
- LISTEN_ADDRESS=0.0.0.0:8080
|
|
||||||
- UPSTREAM_ADDRESS=https://registry.npmjs.org
|
|
33
example/main.go
Normal file
33
example/main.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
npmproxy "github.com/pkgems/npm-cache-proxy/proxy"
|
||||||
|
"github.com/go-redis/redis"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
proxy := npmproxy.Proxy{
|
||||||
|
Database: npmproxy.DatabaseRedis{
|
||||||
|
Client: redis.NewClient(&redis.Options{
|
||||||
|
Addr: "localhost:6379",
|
||||||
|
DB: 0,
|
||||||
|
Password: "",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
HttpClient: &http.Client{},
|
||||||
|
}
|
||||||
|
|
||||||
|
proxy.Server(npmproxy.ServerOptions{
|
||||||
|
ListenAddress: "localhost:8080",
|
||||||
|
GetOptions: func() (npmproxy.Options, error) {
|
||||||
|
return npmproxy.Options{
|
||||||
|
DatabasePrefix: "ncp-",
|
||||||
|
DatabaseExpiration: 1 * time.Hour,
|
||||||
|
UpstreamAddress: "https://registry.npmjs.org",
|
||||||
|
}, nil
|
||||||
|
},
|
||||||
|
}).ListenAndServe()
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user