From 9660dfdd2c51baef09fa27213cd60476995709db Mon Sep 17 00:00:00 2001 From: Nikhil Thomas Date: Wed, 31 Jul 2019 19:57:16 +0530 Subject: [PATCH] Api server works --- .gitignore | 6 +----- Dockerfile | 18 ++++++++++++++++++ go.mod | 6 +++--- k8s/voting-api-deployment-manifest.yaml | 22 ++++++++++++++++++++++ k8s/voting-api-service-manifest.yaml | 13 +++++++++++++ 5 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 Dockerfile create mode 100644 k8s/voting-api-deployment-manifest.yaml create mode 100644 k8s/voting-api-service-manifest.yaml diff --git a/.gitignore b/.gitignore index f1c181e..69b6002 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,5 @@ # Binaries for programs and plugins -*.exe -*.exe~ -*.dll -*.so -*.dylib +vote-api-server # Test binary, build with `go test -c` *.test diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0978313 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM golang:1.13 as builder + +WORKDIR /build +ADD . /build/ + + +ENV GOOS=linux GARCH=amd64 CGO_ENABLED=0 +RUN go build -o api-server . + +FROM alpine:3.7 + +#RUN adduser -S -D -H -h /app appuser +#USER appuser + +WORKDIR /app +COPY --from=builder /build/api-server /app/api-server + +CMD [ "/app/api-server" ] diff --git a/go.mod b/go.mod index c86f975..2beef7e 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ -module github.com:nikhil-thomas/tekton-pipelines-demo.git +module github.com/sthaha/vote-api-server -go 1.12 +go 1.13 -require github.com/gin-gonic/gin v1.4.0 // indirect +require github.com/gin-gonic/gin v1.4.0 diff --git a/k8s/voting-api-deployment-manifest.yaml b/k8s/voting-api-deployment-manifest.yaml new file mode 100644 index 0000000..df2e637 --- /dev/null +++ b/k8s/voting-api-deployment-manifest.yaml @@ -0,0 +1,22 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + creationTimestamp: null + labels: + app: voting-api + name: voting-api +spec: + replicas: 1 + selector: + matchLabels: + app: voting-api + template: + metadata: + labels: + app: voting-api + spec: + containers: + - image: nikhilvep/voting-api:latest + name: voting-api + ports: + - containerPort: 8080 diff --git a/k8s/voting-api-service-manifest.yaml b/k8s/voting-api-service-manifest.yaml new file mode 100644 index 0000000..bd66397 --- /dev/null +++ b/k8s/voting-api-service-manifest.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: voting-api + name: voting-api +spec: + ports: + - port: 8080 + protocol: TCP + targetPort: 8080 + selector: + app: voting-api