docker: working gmid

This commit is contained in:
dongdigua 2023-06-27 13:47:08 +08:00
parent a49b18355f
commit 6f3ecb076e
7 changed files with 33 additions and 7 deletions

4
.meta
View File

@ -1,4 +0,0 @@
org/*.org: text/plain
misc/*: text/plain
pgp: text/plain

View File

@ -2,16 +2,18 @@ FROM alpine:latest
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
&& sed -i 'a https://mirrors.tuna.tsinghua.edu.cn/alpine/edge/testing' /etc/apk/repositories \
&& apk add agate git python3 perl \
&& apk add gmid git python3 perl \
&& touch /var/log/git.log \
&& echo "0 * * * * run-parts /etc/periodic/hourly" > /var/spool/cron/crontabs/root
RUN git clone https://github.com/dongdigua/dongdigua.github.io.git --depth 1 \
&& cd dongdigua.github.io \
&& git config filter.dater.smudge 'perl -pe "\$last_date = `git log --pretty=format:\\"%ad\\" -1`;s/\\\$Date\\\$/\\\$Date: \$last_date\\\$/"' \
&& git config filter.dater.clean 'perl -pe "s/\\\$Date[^\\\$]*\\\$/\\\$Date\\\$/"' \
&& git config filter.dater.clean 'perl -pe "s/\\\$Date[^\\\$]*\\\$/\\\$Date\\\$/"'
COPY run-wrapper.sh .
COPY gmid.conf /dongdigua.github.io/gmi/docker/
COPY cgi/* /dongdigua.github.io/gmi/docker/cgi/
COPY update-git.sh /etc/periodic/hourly/
# for testing purpose only

4
gmi/docker/cgi/stat.cgi Executable file
View File

@ -0,0 +1,4 @@
#! /usr/bin/sh
printf "20 text/gemini\r\n";
printf "OS: $(uname -rv)\r\nuptime: $(uptime)\r\nserver: $SERVER_SOFTWARE\r\nauth: $AUTH\r\n";

12
gmi/docker/genkey.sh Executable file
View File

@ -0,0 +1,12 @@
#! /usr/bin/sh
if test -f /etc/ssl/gmid.pem; then
echo "OK certificate exists"
else
echo "generating certificate..."
apk add libressl
libressl req -x509 -newkey rsa:4096 -nodes \
-keyout /etc/ssl/private/gmid.key \
-out /etc/ssl/gmid.pem \
-days 365 -subj "/CN=$GEMINI_HOST"
fi

9
gmi/docker/gmid.conf Normal file
View File

@ -0,0 +1,9 @@
server $gem_host {
cert "/etc/ssl/gmid.pem"
key "/etc/ssl/private/gmid.key"
root "/dongdigua.github.io"
cgi "/cgi/*"
default type "text/plain"
}

View File

@ -1,8 +1,10 @@
#! /bin/sh
sh genkey.sh
crond -f -d 8 &
tail -f /var/log/git.log &
agate -C --content dongdigua.github.io --hostname $GEMINI_HOST
gmid -f -c /dongdigua.github.io/gmi/docker/gmid.conf -Dgem_host=$GEMINI_HOST
wait -n
echo $?

View File

@ -3,3 +3,4 @@
cd /dongdigua.github.io
git pull --rebase >> /var/log/git.log 2>&1
python misc/mdlist2gmi.py > posts.gmi
pkill -HUP gmid