From d456ec32008e7a158da723f2273e94bea283d321 Mon Sep 17 00:00:00 2001 From: Alex Flores Date: Mon, 27 Mar 2023 15:13:30 -0400 Subject: [PATCH] expose --- Dockerfile | 10 +++------- go.mod | 24 ++++++++++++++++++++++-- go.sum | 1 - main.go | 10 ++++------ 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2f90c56..b53c34e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,7 @@ -FROM golang:1.15 +FROM golang:1.19 -WORKDIR /app -COPY go.* ./ -RUN go mod download - -COPY . . -CMD ["go", "run", "main.go"] +RUN go install github.com/audibleblink/passdb@latest +CMD ["passdb"] # $ docker build -t passdb-server . # $ docker run --env-file .env -p 3000:3000 passdb-server diff --git a/go.mod b/go.mod index 2e5b3b0..57c5c20 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,31 @@ module github.com/audibleblink/passdb -go 1.15 +go 1.19 require ( cloud.google.com/go/bigquery v1.10.0 github.com/go-chi/chi v4.1.2+incompatible github.com/go-chi/cors v1.1.1 - golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc // indirect google.golang.org/api v0.29.0 ) + +require ( + cloud.google.com/go v0.60.0 // indirect + github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect + github.com/golang/protobuf v1.4.2 // indirect + github.com/googleapis/gax-go/v2 v2.0.5 // indirect + github.com/jstemmer/go-junit-report v0.9.1 // indirect + go.opencensus.io v0.22.3 // indirect + golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect + golang.org/x/mod v0.3.0 // indirect + golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc // indirect + golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect + golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect + golang.org/x/text v0.3.2 // indirect + golang.org/x/tools v0.0.0-20200721223218-6123e77877b2 // indirect + golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect + google.golang.org/appengine v1.6.6 // indirect + google.golang.org/genproto v0.0.0-20200722002428-88e341933a54 // indirect + google.golang.org/grpc v1.30.0 // indirect + google.golang.org/protobuf v1.25.0 // indirect +) diff --git a/go.sum b/go.sum index d8b3a50..adf2cdb 100644 --- a/go.sum +++ b/go.sum @@ -226,7 +226,6 @@ golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200523222454-059865788121 h1:rITEj+UZHYC927n8GT97eC3zrpzXdb/voyeOuVKS46o= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= diff --git a/main.go b/main.go index 387671d..3250a07 100644 --- a/main.go +++ b/main.go @@ -24,8 +24,7 @@ var ( googleCred = os.Getenv("GOOGLE_APPLICATION_CREDENTIALS") hibpKey = os.Getenv("HIBP_API_KEY") - port = "3000" - + listenAddr = ":3000" bq *bigquery.Client ) @@ -37,7 +36,7 @@ func init() { } if len(os.Args) > 1 { - port = os.Args[1] + listenAddr = os.Args[1] } ctx := context.Background() @@ -63,9 +62,8 @@ func main() { r.Get("/emails/{email}", handleEmail) r.Get("/breaches/{email}", handleBreaches) - listen := fmt.Sprintf("127.0.0.1:%s", port) - log.Printf("Starting server on %s\n", listen) - err := http.ListenAndServe(listen, r) + log.Printf("Starting server on %s\n", listenAddr) + err := http.ListenAndServe(listenAddr, r) if err != nil { log.Fatal(err) }