From e4ea65f8e342863c0d840219c91449f524ecea7d Mon Sep 17 00:00:00 2001 From: simon987 Date: Fri, 9 Aug 2019 20:24:58 -0400 Subject: [PATCH] docker support --- Dockerfile | 26 +++++++++ README.md | 6 ++ api/api.go | 1 + ...416d513-5464-414c-97b2-af47bc86e2ad.NDJSON | 54 ++++++++++++++++++ jenkins/deploy.sh | 0 test/data/test.png | 1 + test/data/testfile | 1 + test/data/testlargefile | Bin 0 -> 100000 bytes test/data/testmaxsize | Bin 0 -> 10 bytes test/data/testuploadoverwrites | 1 + 10 files changed, 90 insertions(+) create mode 100644 Dockerfile create mode 100644 data/110147_2416d513-5464-414c-97b2-af47bc86e2ad.NDJSON mode change 100755 => 100644 jenkins/deploy.sh create mode 100644 test/data/test.png create mode 100644 test/data/testfile create mode 100644 test/data/testlargefile create mode 100644 test/data/testmaxsize create mode 100644 test/data/testuploadoverwrites diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0180167 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM alpine as go_build +RUN apk update +RUN apk upgrade +RUN apk add --update git go gcc g++ + +WORKDIR /go/src/github.com/simon987/ws_bucket/ +ENV GOPATH /go + +COPY api api +COPY *.go . +RUN go get . && CGO_ENABLED=1 GOOS=linux go build -a -o ws_bucket . + +FROM alpine +WORKDIR /root + +COPY --from=go_build ["/go/src/github.com/simon987/ws_bucket/ws_bucket", "./"] + +ENV WS_BUCKET_DIALECT=sqlite3 +ENV WS_BUCKET_CONNSTR=wsb.db +ENV WS_BUCKET_WORKDIR=/data +ENV WS_BUCKET_LOGLEVEL=info + +VOLUME ["/data"] + +CMD ["/root/ws_bucket"] + diff --git a/README.md b/README.md index d75a0e8..92a2805 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ [![Build Status](https://ci.simon987.net/buildStatus/icon?job=ws_bucket)](https://ci.simon987.net/job/ws_bucket/) [![CodeFactor](https://www.codefactor.io/repository/github/simon987/ws_bucket/badge)](https://www.codefactor.io/repository/github/simon987/ws_bucket) +### Docker example + +```bash +docker run --rm -v $PWD/data:/data -p 3020:3020 -e WS_BUCKET_SECRET=secret simon987/ws_bucket +``` + ### Environment variables | Name | Default | diff --git a/api/api.go b/api/api.go index 057733d..eff9c1d 100644 --- a/api/api.go +++ b/api/api.go @@ -6,6 +6,7 @@ import ( "github.com/fasthttp/websocket" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/postgres" + _ "github.com/jinzhu/gorm/dialects/sqlite" "github.com/robfig/cron" "github.com/sirupsen/logrus" "github.com/valyala/fasthttp" diff --git a/data/110147_2416d513-5464-414c-97b2-af47bc86e2ad.NDJSON b/data/110147_2416d513-5464-414c-97b2-af47bc86e2ad.NDJSON new file mode 100644 index 0000000..4b326d4 --- /dev/null +++ b/data/110147_2416d513-5464-414c-97b2-af47bc86e2ad.NDJSON @@ -0,0 +1,54 @@ +{"name":"Fallout 4.desktop","size":171,"mtime":1545233183,"path":""} +{"name":"The Elder Scrolls V Skyrim Special Edition.desktop","size":205,"mtime":1545233043,"path":""} +{"name":"steam.desktop","size":7392,"mtime":1545232058,"path":""} +{"name":"test.html","size":2405,"mtime":1553040356,"path":""} +{"name":"ul.mar","size":41244,"mtime":1545493542,"path":""} +{"name":".gitignore","size":101,"mtime":1553040408,"path":"neovis.js"} +{"name":".gitmodules","size":226,"mtime":1553040408,"path":"neovis.js"} +{"name":".npmignore","size":39,"mtime":1553040408,"path":"neovis.js"} +{"name":"LICENSE","size":11357,"mtime":1553040408,"path":"neovis.js"} +{"name":"README.md","size":8503,"mtime":1553040408,"path":"neovis.js"} +{"name":"package.json","size":833,"mtime":1553040408,"path":"neovis.js"} +{"name":"webpack.config.js","size":464,"mtime":1553040408,"path":"neovis.js"} +{"name":"HEAD","size":23,"mtime":1553040408,"path":"neovis.js/.git"} +{"name":"config","size":267,"mtime":1553040408,"path":"neovis.js/.git"} +{"name":"description","size":73,"mtime":1553040406,"path":"neovis.js/.git"} +{"name":"index","size":2898,"mtime":1553040408,"path":"neovis.js/.git"} +{"name":"packed-refs","size":325,"mtime":1553040408,"path":"neovis.js/.git"} +{"name":"02d321edc6e03aea1675001899d8f479.png","size":20981,"mtime":1553040408,"path":"neovis.js/dist"} +{"name":"260c9c6535065674bb5e59a73f894abb.png","size":18303,"mtime":1553040408,"path":"neovis.js/dist"} +{"name":"a1a2d01bcd034270a3bc92176edfb66c.png","size":20998,"mtime":1553040408,"path":"neovis.js/dist"} +{"name":"d5267b8db2498e44bd567bd12e07576b.png","size":20764,"mtime":1553040408,"path":"neovis.js/dist"} +{"name":"d5422321c4f6feed4081891051f9a6b2.png","size":21016,"mtime":1553040408,"path":"neovis.js/dist"} +{"name":"dd0baa69a69937600dc3bf035f3873c4.png","size":20802,"mtime":1553040408,"path":"neovis.js/dist"} +{"name":"neovis.js","size":2105246,"mtime":1553040408,"path":"neovis.js/dist"} +{"name":"vis.min.css","size":22195,"mtime":1553040408,"path":"neovis.js/dist"} +{"name":"README.md","size":27,"mtime":1553040408,"path":"neovis.js/doc"} +{"name":"trolltweets.html","size":2625,"mtime":1553040408,"path":"neovis.js/docs"} +{"name":"example-labels.html","size":2555,"mtime":1553040408,"path":"neovis.js/examples"} +{"name":"simple-example.html","size":2415,"mtime":1553040827,"path":"neovis.js/examples"} +{"name":"twitter-trolls.html","size":1252,"mtime":1553040408,"path":"neovis.js/examples"} +{"name":"example-viz.png","size":667881,"mtime":1553040408,"path":"neovis.js/img"} +{"name":"got-neo4j-browser.png","size":1002461,"mtime":1553040408,"path":"neovis.js/img"} +{"name":"defaults.js","size":1820,"mtime":1553040408,"path":"neovis.js/src"} +{"name":"events.js","size":963,"mtime":1553040408,"path":"neovis.js/src"} +{"name":"neovis.js","size":15040,"mtime":1553040408,"path":"neovis.js/src"} +{"name":"test-neovis.js","size":21,"mtime":1553040408,"path":"neovis.js/test"} +{"name":"applypatch-msg.sample","size":478,"mtime":1553040406,"path":"neovis.js/.git/hooks"} +{"name":"commit-msg.sample","size":896,"mtime":1553040406,"path":"neovis.js/.git/hooks"} +{"name":"fsmonitor-watchman.sample","size":3327,"mtime":1553040406,"path":"neovis.js/.git/hooks"} +{"name":"post-update.sample","size":189,"mtime":1553040406,"path":"neovis.js/.git/hooks"} +{"name":"pre-applypatch.sample","size":424,"mtime":1553040406,"path":"neovis.js/.git/hooks"} +{"name":"pre-commit.sample","size":1638,"mtime":1553040406,"path":"neovis.js/.git/hooks"} +{"name":"pre-push.sample","size":1348,"mtime":1553040406,"path":"neovis.js/.git/hooks"} +{"name":"pre-rebase.sample","size":4898,"mtime":1553040406,"path":"neovis.js/.git/hooks"} +{"name":"pre-receive.sample","size":544,"mtime":1553040406,"path":"neovis.js/.git/hooks"} +{"name":"prepare-commit-msg.sample","size":1492,"mtime":1553040406,"path":"neovis.js/.git/hooks"} +{"name":"update.sample","size":3610,"mtime":1553040406,"path":"neovis.js/.git/hooks"} +{"name":"exclude","size":240,"mtime":1553040406,"path":"neovis.js/.git/info"} +{"name":"HEAD","size":194,"mtime":1553040408,"path":"neovis.js/.git/logs"} +{"name":"got-centralities.csv","size":28823,"mtime":1553040408,"path":"neovis.js/examples/data"} +{"name":"pack-352ff901fbb981411ab9546aac34133a998f1566.idx","size":11460,"mtime":1553040408,"path":"neovis.js/.git/objects/pack"} +{"name":"pack-352ff901fbb981411ab9546aac34133a998f1566.pack","size":6475046,"mtime":1553040408,"path":"neovis.js/.git/objects/pack"} +{"name":"master","size":41,"mtime":1553040408,"path":"neovis.js/.git/refs/heads"} +{"name":"HEAD","size":32,"mtime":1553040408,"path":"neovis.js/.git/refs/remotes/origin"} diff --git a/jenkins/deploy.sh b/jenkins/deploy.sh old mode 100755 new mode 100644 diff --git a/test/data/test.png b/test/data/test.png new file mode 100644 index 0000000..30d74d2 --- /dev/null +++ b/test/data/test.png @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/data/testfile b/test/data/testfile new file mode 100644 index 0000000..3312279 --- /dev/null +++ b/test/data/testfile @@ -0,0 +1 @@ +testuploadsmallfile \ No newline at end of file diff --git a/test/data/testlargefile b/test/data/testlargefile new file mode 100644 index 0000000000000000000000000000000000000000..7ae22fcf0e0c8d07a602990978d9a483226f87d7 GIT binary patch literal 100000 zcmeIuK@k7|2m>I?n!xqH)$jok$X*5m1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r z3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@ z0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VK zfB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b*1`HT5 zV8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM z7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b* z1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd z0RsjM7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwA vz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b*23`&nL>vLZ literal 0 HcmV?d00001 diff --git a/test/data/testmaxsize b/test/data/testmaxsize new file mode 100644 index 0000000000000000000000000000000000000000..6e5f22352ce40928e02c2511bb80fc1cab0ee8b4 GIT binary patch literal 10 NcmXR(EiPdI0{{-=0l@$O literal 0 HcmV?d00001 diff --git a/test/data/testuploadoverwrites b/test/data/testuploadoverwrites new file mode 100644 index 0000000..f88d6d8 --- /dev/null +++ b/test/data/testuploadoverwrites @@ -0,0 +1 @@ +newvalue \ No newline at end of file