diff --git a/images/shiori/Dockerfile b/images/shiori/Dockerfile new file mode 100644 index 0000000..3299b63 --- /dev/null +++ b/images/shiori/Dockerfile @@ -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" ] diff --git a/images/shiori/run.sh b/images/shiori/run.sh new file mode 100755 index 0000000..d11bfca --- /dev/null +++ b/images/shiori/run.sh @@ -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 diff --git a/images/shiori/type.txt b/images/shiori/type.txt new file mode 100644 index 0000000..bdb9670 --- /dev/null +++ b/images/shiori/type.txt @@ -0,0 +1 @@ +docker