Skip to content

Commit 9b3ebc1

Browse files
Added application code
1 parent 67cb219 commit 9b3ebc1

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

source-code/Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM golang:1.15.1-alpine3.12 AS build-env
2+
3+
WORKDIR /tmp/simple-go-app
4+
5+
COPY . .
6+
7+
RUN CGO_ENABLED=0 GOOS=linux go build
8+
9+
FROM scratch
10+
COPY --from=build-env /tmp/simple-go-app/simple-web-app /app/simple-web-app
11+
12+
EXPOSE 8080
13+
CMD ["/app/simple-web-app"]

source-code/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
A sample GO web application with Dockerfile
2+

source-code/go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/codefresh-contrib/gitops-certification-examples/simple-web-app
2+
3+
go 1.15

source-code/trivial-web-server.go

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"net/http"
6+
)
7+
8+
func indexHandler(w http.ResponseWriter, r *http.Request) {
9+
fmt.Fprintf(w, "I am an application running in Kubernetes. Now at Version 1.0")
10+
11+
}
12+
13+
func main() {
14+
fmt.Println("Basic web server is starting on port 8080...")
15+
http.HandleFunc("/", indexHandler)
16+
http.ListenAndServe(":8080", nil)
17+
}

0 commit comments

Comments
 (0)