diff --git a/.gitignore b/.gitignore index 1377554..25db753 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *.swp +bin/ +stage.tmp/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3109bcc --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +GOC=go build +GOFLAGS=-a -ldflags '-s' +CGOR=CGO_ENABLED=0 +IMAGE_NAME=smpldbot + +all: lorebot + +lorebot: + $(GOC) lorebot/lorebot.go + +run: + go run lorebot/lorebot.go + +stat: + mkdir -p bin/ + $(CGOR) $(GOC) -o bin/lorebot $(GOFLAGS) lorebot/*.go + +docker: stat + mkdir stage.tmp/ + cp bin/lorebot stage.tmp/ + cp deps/rootfs.tar.gz stage.tmp/ + cp deps/Dockerfile stage.tmp/ + chmod +x deps/run.sh + cp deps/run.sh stage.tmp/ + cp config.gcfg stage.tmp/ + cd stage.tmp/ && \ + sudo docker build -t $(IMAGE_NAME) . + @echo "$(IMAGE_NAME) built" + +clean: + rm -rf bin/ + rm -rf stage.tmp/ diff --git a/config.gcfg b/config.gcfg index 6ce1952..4c668af 100644 --- a/config.gcfg +++ b/config.gcfg @@ -4,5 +4,5 @@ APIToken = "xoxb-189788161987-7FK5NKnBtrFGGtv4yszr2URb" [redis] - host = "localhost:6379" + host = "127.0.0.1:6379" password = "" diff --git a/deps/Dockerfile b/deps/Dockerfile new file mode 100644 index 0000000..8cc529c --- /dev/null +++ b/deps/Dockerfile @@ -0,0 +1,8 @@ +FROM scratch + +ADD rootfs.tar.gz / +COPY config.gcfg / +COPY lorebot / +COPY run.sh / + +CMD ["/run.sh"] diff --git a/deps/rootfs.tar.gz b/deps/rootfs.tar.gz new file mode 100644 index 0000000..dd37d4c Binary files /dev/null and b/deps/rootfs.tar.gz differ diff --git a/deps/run.sh b/deps/run.sh new file mode 100755 index 0000000..81a0ab0 --- /dev/null +++ b/deps/run.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +#echo "daemonize yes" > /redis.conf +echo "dbfilename dump.rdb" >> /redis.conf +echo "dir /redisbackup/" >> /redis.conf +echo "save 30 1" >> /redis.conf + +redis-server /redis.conf & + +/lorebot $@