Add Docker resources

This commit is contained in:
jdtron 2023-03-17 10:02:22 +01:00
parent 9488ade7fb
commit dae058b53d
4 changed files with 66 additions and 0 deletions

6
.dockerignore Normal file
View File

@ -0,0 +1,6 @@
docs/
Dockerfile
Makefile
README.md
readme.png
todo.org

22
Dockerfile Normal file
View File

@ -0,0 +1,22 @@
FROM python:alpine
RUN apk add --no-cache \
bash sqlite
WORKDIR /app
COPY . .
RUN adduser -D bbj
RUN chown -R bbj:bbj .
USER bbj
RUN /bin/bash /app/setup.sh
EXPOSE 7099
ENV PORT=7099
ENV HOST=127.0.0.1
ENV INSTANCE_NAME=BBJ
ENV ALLOW_ANON=true
ENV DEBUG=false
ENV ADMINS=
ENTRYPOINT ["/bin/sh", "/app/docker-entrypoint.sh"]

8
Makefile Normal file
View File

@ -0,0 +1,8 @@
IMAGE_NAME = tildegit.org/jdtron/bbj
IMAGE_TAG = latest
image:
docker build -t ${IMAGE_NAME}:${IMAGE_TAG} .
push:
docker push ${IMAGE_NAME}:${IMAGE_TAG}

30
docker-entrypoint.sh Normal file
View File

@ -0,0 +1,30 @@
#!/bin/sh
# Helper to build a JSON list
function json_list {
[ -z $1 ] && printf '[]' && return
local list="\"$1\""
shift
for i in $@; do
list="$list, \"$i\""
done
printf "[$list]"
}
# Build config from env
cat <<EOL > /app/config.json
{
"port": $PORT,
"host": "$HOST",
"instance_name": "$INSTANCE_NAME",
"allow_anon": $ALLOW_ANON,
"debug": $DEBUG,
"admins": $(json_list $ADMINS)
}
EOL
[ ! -f data.sqlite ] && /bin/bash /app/setup.sh --dbset
python /app/server.py