aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarin Ivanov <[email protected]>2019-05-31 01:09:50 +0300
committerMarin Ivanov <[email protected]>2019-05-31 02:18:21 +0300
commitbb8a589303d572bb1c9d7be736c785e84f739bc3 (patch)
treec1dd7a2c9e0ba98a527a2397aadbb8d372ef2306
parente74246db707ed168fa0444f5dfcbfa20b2aeacbe (diff)
Add dokerized image
-rw-r--r--.dockerignore3
-rw-r--r--Dockerfile13
-rw-r--r--Makefile2
3 files changed, 17 insertions, 1 deletions
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..5ce33ff
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,3 @@
+.git
+/build
+/Dockerfile
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..4052183
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,13 @@
+FROM golang:1.12-alpine as builder
+WORKDIR /app
+COPY . /app
+RUN apk add --no-cache git make \
+ && make linux-amd64
+
+# Runtime
+FROM scratch
+COPY --from=builder /app/build/tarpit-linux-amd64 /tarpit
+USER 65534:65534
+EXPOSE 2022
+ENTRYPOINT ["/tarpit"]
+CMD ["-p", "2022"]
diff --git a/Makefile b/Makefile
index 3956af1..994382f 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ linux-amd64: build/tarpit-linux-amd64
windows-amd64: build/tarpit-windows-amd64.exe
build/tarpit-linux-amd64: $(SRC)
- GOOS=linux GOARCH=amd64 go build -o "$@"
+ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o "$@" -ldflags '-extldflags "-static"'
build/tarpit-windows-amd64.exe: $(SRC)
GOOS=windows GOARCH=amd64 go build -o "$@"