shiori: write initial dockerfile

This commit is contained in:
Starbeamrainbowlabs 2021-04-03 20:09:57 +01:00
parent 19856f4f69
commit 0368929002
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
3 changed files with 63 additions and 0 deletions

37
images/shiori/Dockerfile Normal file
View file

@ -0,0 +1,37 @@
ARG REPO_LOCATION
FROM ${REPO_LOCATION}minideb AS builder
RUN install_packages software-properties-common git gpg dirmngr gpg-agent gcc libc-dev
# Add the golang apt repository
# Note that install_packages runs apt update automatically
# Apparentl apt-add-repository doesn't properly import the GPG key :-/
RUN add-apt-repository --yes ppa:longsleep/golang-backports \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F6BC817356A3D45E
RUN install_packages golang-go
RUN git clone https://github.com/go-shiori/shiori.git /srv/shiori
WORKDIR /srv/shiori
RUN git checkout "$(git describe --tags "$(git rev-list --tags --max-count=1)")"
# armv7l+, GOARM can be set as low as 5 if you have an old board (but I have Raspberry Pi 4B+ boards)
RUN GOOS=linux GOARCH=arm GOARM=7 go build -v
FROM ${REPO_LOCATION}minideb
COPY --from=builder /srv/shiori/shiori /srv/shiori
VOLUME /srv/data
WORKDIR /srv/data
USER 95:95
ENTRYPOINT [ "/srv/run.sh" ]
CMD [ "serve" ]

25
images/shiori/run.sh Executable file
View file

@ -0,0 +1,25 @@
#!/usr/bin/env bash
data_dir="/srv/data";
# The port number to listen on
port="${NOMAD_PORT_SHIORI:-8080}";
echo "[run.sh] I am running as UID $UID" >&2;
echo "[run.sh] Arguments to pass to shiori: '${*}'";
if [[ "${1}" == "serve" ]]; then
echo "[run.sh] Going to tell Shiori to listen on port ${port}." >&2;
fi
if [[ ! -d "${data_dir}" ]]; then
echo "[run.sh] Error: The data directory at '${data_dir}' does not appear to exist." >&2;
exit 2;
fi
cd "${data_dir}" || { echo "Error: Failed to cd into '${data_dir}' (have you checked the permissions?)"; exit 2; };
if [[ "${1}" == "serve" ]]; then
exec /srv/shiori/shiori "$@" -port "${port}";
else
exec /srv/shiori/shiori "$@";
fi

1
images/shiori/type.txt Normal file
View file

@ -0,0 +1 @@
docker