docker: add docker stuff

This commit is contained in:
Chris Sexton 2020-06-15 14:52:11 -04:00 committed by Chris Sexton
parent 45adb3a242
commit b9d5606301
3 changed files with 111 additions and 0 deletions

59
Dockerfile Normal file
View File

@ -0,0 +1,59 @@
FROM alpine:edge
RUN apk add --no-cache git
RUN apk add --no-cache musl-dev
RUN apk add --no-cache gcc
RUN apk add --no-cache sqlite
RUN apk add --no-cache go
RUN apk add --no-cache perl
RUN apk add --no-cache make
VOLUME /app/var
VOLUME /app/src
EXPOSE 1337
ARG gomaxprocs="8"
WORKDIR /app
ENV SRC_DIR=/app/src/catbase/
RUN mkdir -p $SRC_DIR
ENV TWITCHAUTHORIZATION="OAuth "
ENV TWITCHCLIENTID=""
ENV UNTAPPDTOKEN=""
ENV HTTPADDR="0.0.0.0:1337"
ENV TWITTERACCESSTOKEN=""
ENV TWITTERACCESSSECRET=""
ENV TWITTERCONSUMERKEY=""
ENV TWITTERCONSUMERSECRET=""
ENV AOCSESSION=""
ENV TWILIOTOKEN=""
ENV TWILIOSID=""
ENV TWILIONUMBER="+5558675309"
ENV TYPE=slackapp
ENV SLACKTOKEN=FOO
ENV SLACKUSERTOKEN=FOO
ENV SLACKVERIFICATION=FOO
ENV SLACKBOTID=FOO
ENV SLACKAPPLOGDIR=/app/var/logs
ENV SLACKAPPLOGMESSAGEDIR=/app/var/logs
ENV GOMAXPROCS=8
ADD . $SRC_DIR
RUN apk add --no-cache tzdata
ENV TZ America/New_York
RUN git clone https://github.com/chrissexton/rank-amateur-cowsay.git cowsay && cd cowsay && ./install.sh
RUN cd $SRC_DIR; go get ./...; go build -o /app/catbase
RUN git clone https://gitlab.com/DavidGriffith/frotz.git frotz && cd frotz && make dfrotz && cp dfrotz /app
ENTRYPOINT ["/app/catbase", "-db=/app/var/catbase.db", "-debug"]

10
docker/build.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash -e
set -e
set -o pipefail
# To be run from the catbase src directory
[[ ! -f main.go ]] && echo "You must run this from the catbase src root." && exit 1
docker build -t velour/catbase -t chrissexton/private:catbase .
docker push chrissexton/private:catbase

42
docker/rebuild.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/bash -e
set -e
set -o pipefail
CONTAINER=catbase
OLD_ID=$(docker ps -f NAME="$CONTAINER" -q)
if [[ $OLD_ID -gt 0 ]]; then
echo "Removing old container $OLD_ID"
docker stop $CONTAINER
docker rm -f $CONTAINER
fi
docker run \
-d \
-p 127.0.0.1:1337:1337 \
-v var:/app/var \
-v src:/app/src \
-e TWITCHAUTHORIZATION="OAuth " \
-e TWITCHCLIENTID="" \
-e UNTAPPDTOKEN="" \
-e HTTPADDR="0.0.0.0:1337" \
-e TWITTERACCESSTOKEN="" \
-e TWITTERACCESSSECRET="" \
-e TWITTERCONSUMERKEY="" \
-e TWITTERCONSUMERSECRET="" \
-e AOCSESSION="" \
-e TWILIOTOKEN="" \
-e TWILIOSID="" \
-e TWILIONUMBER="+1" \
-e TYPE=slackapp \
-e SLACKTOKEN= \
-e SLACKUSERTOKEN= \
-e SLACKVERIFICATION= \
-e SLACKBOTID= \
-e SLACKAPPLOGDIR=/app/var/logs \
-e SLACKAPPLOGMESSAGEDIR=/app/var/logs \
-e GOMAXPROCS=8 \
--name $CONTAINER chrissexton/private:catbase
echo 'Subject: catbase built' | ssmtp noreply@velour.ninja