Skip to content

Commit 8c27a59

Browse files
committed
first commit
Signed-off-by: Stephanie <yangcao@redhat.com>
0 parents  commit 8c27a59

8 files changed

Lines changed: 121 additions & 0 deletions

File tree

outerloop-deploy.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
kind: Deployment
2+
apiVersion: apps/v1
3+
metadata:
4+
name: my-go
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: go-app
10+
template:
11+
metadata:
12+
labels:
13+
app: go-app
14+
spec:
15+
containers:
16+
- name: my-go
17+
image: go-image:latest
18+
ports:
19+
- name: http
20+
containerPort: 8081
21+
protocol: TCP
22+
resources:
23+
limits:
24+
memory: "1024Mi"
25+
cpu: "500m"

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.odo/env
2+
.odo/odo-file-index.json
3+
main
4+
.idea/
5+
.DS_Store

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM golang:1.16-alpine
2+
3+
WORKDIR /app
4+
5+
COPY go.mod ./
6+
RUN go mod download
7+
8+
COPY *.go ./
9+
10+
RUN go build -o /main
11+
12+
EXPOSE 8081
13+
14+
CMD [ "/main" , "-p=8081"]

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# devfile-sample-go-basic

devfile.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
schemaVersion: 2.2.0
2+
metadata:
3+
name: go
4+
language: go
5+
projectType: go
6+
tags:
7+
- Go
8+
version: 1.0.0
9+
provider: Red Hat
10+
supportUrl: https://github.com/devfile-samples/devfile-support#support-information
11+
attributes:
12+
alpha.dockerimage-port: 8081
13+
parent:
14+
id: go
15+
registryUrl: "https://registry.devfile.io"
16+
components:
17+
- name: outerloop-build
18+
image:
19+
imageName: go-image:latest
20+
dockerfile:
21+
uri: docker/Dockerfile
22+
buildContext: .
23+
rootRequired: false
24+
- name: outerloop-deploy
25+
kubernetes:
26+
uri: outerloop-deploy.yaml
27+
commands:
28+
- id: build-image
29+
apply:
30+
component: outerloop-build
31+
- id: deployk8s
32+
apply:
33+
component: outerloop-deploy
34+
- id: deploy
35+
composite:
36+
commands:
37+
- build-image
38+
- deployk8s
39+
group:
40+
kind: deploy
41+
isDefault: true

docker/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM golang:1.16-alpine
2+
3+
WORKDIR /app
4+
5+
COPY go.mod ./
6+
RUN go mod download
7+
8+
COPY *.go ./
9+
10+
RUN go build -o /main
11+
12+
EXPOSE 8081
13+
14+
CMD [ "/main" , "-p=8081"]

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/schultzp2020/devfile-starter-projects/go
2+
3+
go 1.16

main.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"net/http"
6+
"flag"
7+
)
8+
var port = flag.Int("p", 8080, "server port")
9+
10+
func main() {
11+
flag.Parse()
12+
http.HandleFunc("/", HelloServer)
13+
http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", *port), nil)
14+
}
15+
16+
func HelloServer(w http.ResponseWriter, r *http.Request) {
17+
fmt.Fprintf(w, "Hello, %s!", r.URL.Path[1:])
18+
}

0 commit comments

Comments
 (0)