From 7cfaf01f221285afb2ecdd8d1149c171939859bb Mon Sep 17 00:00:00 2001 From: mapperr Date: Sat, 10 Oct 2020 20:57:43 +0200 Subject: [PATCH] Fix soju cert --- soju/Dockerfile | 7 ++----- soju/README.md | 3 ++- soju/build.sh | 4 ++++ soju/entrypoint.sh | 20 ++++++++++++++++++++ soju/run.sh | 9 +++++++++ 5 files changed, 37 insertions(+), 6 deletions(-) create mode 100755 soju/build.sh create mode 100755 soju/entrypoint.sh create mode 100755 soju/run.sh diff --git a/soju/Dockerfile b/soju/Dockerfile index 6ba3ae3..99688f9 100755 --- a/soju/Dockerfile +++ b/soju/Dockerfile @@ -5,14 +5,11 @@ RUN apk update &&\ git clone https://git.sr.ht/~emersion/soju && \ cd soju && \ make && \ - openssl req -new -newkey rsa:4096 -x509 -sha256 -days 3650 -nodes \ - -out cert.pem -keyout key.pem \ - -subj "/CN=soju" && \ - echo 'tls /soju/cert.pem /soju/key.pem' > soju.conf && \ echo 'sql sqlite3 /sojudb/soju.db' >> soju.conf && \ echo 'listen 0.0.0.0:6697' >> soju.conf && \ mkdir /sojudb +COPY ./entrypoint.sh /entrypoint.sh EXPOSE 6697 -CMD ["/soju/soju", "-config", "/soju/soju.conf"] +ENTRYPOINT /entrypoint.sh diff --git a/soju/README.md b/soju/README.md index 6dc7f78..7a0ab59 100755 --- a/soju/README.md +++ b/soju/README.md @@ -4,7 +4,7 @@ https://sr.ht/~emersion/soju ## Build the image - docker build -t whatever/you:want . + docker build -t mapperr/soju:latest . ## Using the image @@ -14,6 +14,7 @@ Suppose you tagged the image as `mapperr/soju:latest`: --name soju \ -p 6697:6697 \ -v $PWD/sojudb:/sojudb \ + -v $PWD/cert:/cert \ mapperr/soju:latest then create a user with: diff --git a/soju/build.sh b/soju/build.sh new file mode 100755 index 0000000..7671503 --- /dev/null +++ b/soju/build.sh @@ -0,0 +1,4 @@ +#! /bin/sh + +docker build -t mapperr/soju:latest . + diff --git a/soju/entrypoint.sh b/soju/entrypoint.sh new file mode 100755 index 0000000..8c74b3a --- /dev/null +++ b/soju/entrypoint.sh @@ -0,0 +1,20 @@ +#! /bin/sh + +certfile="/cert/cert.pem" +keyfile="/cert/key.pem" + +if [ -f "$certfile" ] && [ -f "$keyfile" ]; then + echo 'cert already present' + +else + openssl req -new \ + -newkey rsa:4096 -x509 -sha256 -days 3650 -nodes \ + -out $certfile \ + -keyout $keyfile \ + -subj "/CN=soju" +fi + +echo "tls $certfile $keyfile" >> /soju/soju.conf + +/soju/soju -config /soju/soju.conf + diff --git a/soju/run.sh b/soju/run.sh new file mode 100755 index 0000000..40887c2 --- /dev/null +++ b/soju/run.sh @@ -0,0 +1,9 @@ +#! /bin/sh + +docker run -d \ + --name soju \ + --restart unless-stopped \ + -p 6697:6697 \ + -v $PWD/sojudb:/sojudb \ + -v $PWD/cert:/cert \ + mapperr/soju:latest -- 2.45.2