Skip to content

Commit 2ec3a1f

Browse files
maysunfaisalelsony
authored andcommitted
Update the Dockerfile to COPY all files
Signed-off-by: Maysun J Faisal <[email protected]>
1 parent 9a5a02a commit 2ec3a1f

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

docker/Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
FROM registry.access.redhat.com/ubi9/go-toolset:1.18.9-14
22

3-
COPY go.mod ./
3+
COPY . .
44
RUN go mod download
55

6-
COPY *.go ./
7-
86
RUN go build -o ./main
97

8+
ENV PORT 8081
109
EXPOSE 8081
1110

12-
CMD [ "./main" , "-p=8081"]
11+
CMD [ "./main" ]

main.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
package main
22

33
import (
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

1111
func 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

1719
func HelloServer(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)