Skip to content

Commit

Permalink
Update the Dockerfile to COPY all files
Browse files Browse the repository at this point in the history
Signed-off-by: Maysun J Faisal <[email protected]>
  • Loading branch information
maysunfaisal authored and elsony committed Apr 19, 2023
1 parent 9a5a02a commit 2ec3a1f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 3 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
FROM registry.access.redhat.com/ubi9/go-toolset:1.18.9-14

COPY go.mod ./
COPY . .
RUN go mod download

COPY *.go ./

RUN go build -o ./main

ENV PORT 8081
EXPOSE 8081

CMD [ "./main" , "-p=8081"]
CMD [ "./main" ]
10 changes: 6 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package main

import (
"flag"
"fmt"
"net/http"
"os"
)

var port = flag.Int("p", 8080, "server port")
var port = os.Getenv("PORT")

func main() {
flag.Parse()
if port == "" {
port = "8080"
}
http.HandleFunc("/", HelloServer)
http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", *port), nil)
http.ListenAndServe(fmt.Sprintf("0.0.0.0:%s", port), nil)
}

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

0 comments on commit 2ec3a1f

Please sign in to comment.