Skip to content

Commit 54d46df

Browse files
prepare Dockerfile
1 parent 2148c27 commit 54d46df

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM alpine:latest AS ca-certs
2+
RUN apk add -U --no-cache ca-certificates
3+
4+
FROM golang:1.17 AS go-builder
5+
6+
WORKDIR /go/src/main
7+
COPY . .
8+
9+
RUN go get -d -v .
10+
RUN CGO_ENABLED=0 go install -v .
11+
12+
FROM scratch
13+
COPY --from=go-builder /go/bin/most-active-github-users-counter /go/bin/most-active-github-users-counter
14+
COPY --from=ca-certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
15+
16+
ENTRYPOINT ["/go/bin/most-active-github-users-counter"]

main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var locations arrayFlags
2525
var excludeLocations arrayFlags
2626

2727
func main() {
28-
token := flag.String("token", "", "Github auth token")
28+
token := flag.String("token", LookupEnvOrString("GITHUB_TOKEN", ""), "Github auth token")
2929
amount := flag.Int("amount", 256, "Amount of users to show")
3030
considerNum := flag.Int("consider", 1000, "Amount of users to consider")
3131
outputOpt := flag.String("output", "plain", "Output format: plain, csv")
@@ -78,3 +78,10 @@ func main() {
7878
}
7979
writer.Flush()
8080
}
81+
82+
func LookupEnvOrString(key string, defaultVal string) string {
83+
if val, ok := os.LookupEnv(key); ok {
84+
return val
85+
}
86+
return defaultVal
87+
}

0 commit comments

Comments
 (0)