Compare commits

...

4 Commits

Author SHA1 Message Date
96d49bc25a
Updated ignore 2023-02-24 20:54:20 +01:00
d62744001d
Docker compose 2023-02-24 20:53:10 +01:00
c07af4e05e
Go Bump 2023-02-24 20:53:05 +01:00
40ac5580fa
Docker image bump 2023-02-24 20:50:01 +01:00
4 changed files with 24 additions and 37 deletions

3
.gitignore vendored
View File

@ -16,3 +16,6 @@ build/
# APFS cache
.DS_Store
# Docker compose
data

View File

@ -1,7 +1,5 @@
# === BUILD STAGE === #
FROM golang:1.12-alpine as build
ARG ACCESS_TOKEN
FROM golang:1.20-alpine3.16 as build
RUN apk add --no-cache git
@ -16,7 +14,7 @@ RUN go test -v ./...
RUN go build -ldflags="-w -s" -o build
# === RUN STAGE === #
FROM alpine as run
FROM registry.odit.services/hub/library/alpine:3.16 as run
RUN apk update \
&& apk upgrade \

19
docker-compose.yaml Normal file
View File

@ -0,0 +1,19 @@
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

View File

@ -1,33 +0,0 @@
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()
}