feat: add docker configuration
This commit is contained in:
parent
821712f43b
commit
cf2f624ae4
21 changed files with 232 additions and 13 deletions
16
rate/Dockerfile
Normal file
16
rate/Dockerfile
Normal file
|
@ -0,0 +1,16 @@
|
|||
FROM docker.io/golang:latest AS builder
|
||||
WORKDIR /build
|
||||
EXPOSE 5003
|
||||
|
||||
COPY . ./
|
||||
RUN go mod download -x
|
||||
ENV CGO_ENABLED 0
|
||||
RUN go build -v -o rate
|
||||
|
||||
FROM alpine:latest
|
||||
RUN apk --no-cache add ca-certificates
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=builder /build/rate rate
|
||||
|
||||
CMD ["/app/rate"]
|
9
rate/go.mod
Normal file
9
rate/go.mod
Normal file
|
@ -0,0 +1,9 @@
|
|||
module code.vulpine.solutions/sam/Foxnouns.NET
|
||||
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
github.com/go-chi/httprate v0.14.1
|
||||
)
|
||||
|
||||
require github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
7
rate/go.sum
Normal file
7
rate/go.sum
Normal file
|
@ -0,0 +1,7 @@
|
|||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/go-chi/httprate v0.14.1 h1:EKZHYEZ58Cg6hWcYzoZILsv7ppb46Wt4uQ738IRtpZs=
|
||||
github.com/go-chi/httprate v0.14.1/go.mod h1:TUepLXaz/pCjmCtf/obgOQJ2Sz6rC8fSf5cAt5cnTt0=
|
||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
|
||||
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
|
@ -23,6 +23,14 @@ func main() {
|
|||
log.Fatalf("unmarshaling config.json: %v", err)
|
||||
}
|
||||
|
||||
// Override port from environment if it's set
|
||||
if portEnv := os.Getenv("PORT"); portEnv != "" {
|
||||
port, err := strconv.Atoi(portEnv)
|
||||
if err == nil {
|
||||
hn.Port = port
|
||||
}
|
||||
}
|
||||
|
||||
proxyURL, err := url.Parse(hn.ProxyTarget)
|
||||
if err != nil {
|
||||
log.Fatalf("parsing proxy_target as URL: %v", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue