aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjackyzha0 <[email protected]>2020-05-09 14:48:51 -0700
committerjackyzha0 <[email protected]>2020-05-09 14:48:51 -0700
commit8026f03b111d65ffbac7f11fc056abef430a77f8 (patch)
tree49ee3cd9b69866e53068476dbbe8d27d6f386911
parentip changes and remove some debug (diff)
downloadctrl-v-8026f03b111d65ffbac7f11fc056abef430a77f8.tar.xz
ctrl-v-8026f03b111d65ffbac7f11fc056abef430a77f8.zip
add dockerfile and makefile
-rw-r--r--.Dockerignore1
-rw-r--r--Dockerfile25
-rw-r--r--Makefile11
-rw-r--r--api/routes.go2
4 files changed, 38 insertions, 1 deletions
diff --git a/.Dockerignore b/.Dockerignore
new file mode 100644
index 0000000..10d4fb7
--- /dev/null
+++ b/.Dockerignore
@@ -0,0 +1 @@
+frontend \ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..5a14889
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,25 @@
+## Build stage
+FROM golang:alpine AS builder
+ENV GO111MODULE=on
+
+# Copy files to image
+COPY . /app/src
+WORKDIR /app/src
+
+RUN apk add git ca-certificates
+RUN go mod download
+
+# Build image
+RUN CGO_ENABLED=0 GOOS=linux go build -o /go/bin/app
+
+## Image creation stage
+FROM scratch
+
+# Copy app
+COPY --from=builder /go/bin/app /go/bin/app
+
+# Expose ports, change port to whatever you need to expose
+EXPOSE 8080
+
+# Run app
+ENTRYPOINT ["/go/bin/app"] \ No newline at end of file
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..23c4374
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,11 @@
+run:
+ go run .
+lint:
+ golangci-lint run
+docker-build:
+ docker build -t jzhao2k19/ctrl-v:latest .
+docker-run:
+ docker run -p 8080:8080 jzhao2k19/ctrl-v:latest
+docker-all: docker-build docker-run
+docker-push:
+ docker push jzhao2k19/ctrl-v:latest \ No newline at end of file
diff --git a/api/routes.go b/api/routes.go
index 6f9c17b..103de04 100644
--- a/api/routes.go
+++ b/api/routes.go
@@ -19,7 +19,7 @@ func insertFunc(w http.ResponseWriter, r *http.Request) {
content := r.FormValue("content")
// get ip
- ip, _ := getIP(r)
+ ip := getIP(r)
log.Infof("got content '%s' and ip '%s'", content, ip)