File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change 11FROM registry.access.redhat.com/ubi9/go-toolset:1.18.9-14
22
3- COPY go.mod ./
3+ COPY . .
44RUN go mod download
55
6- COPY *.go ./
7-
86RUN go build -o ./main
97
8+ ENV PORT 8081
109EXPOSE 8081
1110
12- CMD [ "./main" , "-p=8081" ]
11+ CMD [ "./main" ]
Original file line number Diff line number Diff line change 11package main
22
33import (
4- "flag"
54 "fmt"
65 "net/http"
6+ "os"
77)
88
9- var port = flag . Int ( "p" , 8080 , "server port " )
9+ var port = os . Getenv ( "PORT " )
1010
1111func main () {
12- flag .Parse ()
12+ if port == "" {
13+ port = "8080"
14+ }
1315 http .HandleFunc ("/" , HelloServer )
14- http .ListenAndServe (fmt .Sprintf ("0.0.0.0:%d " , * port ), nil )
16+ http .ListenAndServe (fmt .Sprintf ("0.0.0.0:%s " , port ), nil )
1517}
1618
1719func HelloServer (w http.ResponseWriter , r * http.Request ) {
You can’t perform that action at this time.
0 commit comments