Skip to content

Commit

Permalink
修改了config.yml存在与否的应对逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
w9315273 committed May 5, 2024
1 parent 1a55764 commit b5316e5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
48 changes: 26 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,40 @@ FROM alpine

ARG tag

ENV WORKDIR="/srv/bililive"
ENV OUTPUT_DIR="/srv/bililive" \
ENV WORKDIR="/srv/bililive" \
OUTPUT_DIR="/srv/bililive" \
CONF_DIR="/etc/bililive-go" \
PORT=8080
PORT=8080 \
PUID=0 \
PGID=0 \
UMASK=022

ENV PUID=0 PGID=0 UMASK=022

RUN mkdir -p $OUTPUT_DIR && \
mkdir -p $CONF_DIR && \
RUN mkdir -p $OUTPUT_DIR $CONF_DIR && \
apk update && \
apk --no-cache add ffmpeg libc6-compat curl su-exec tzdata && \
cp -r -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

RUN sh -c "case $(arch) in aarch64) go_arch=arm64 ;; arm*) go_arch=arm ;; i386|i686) go_arch=386 ;; x86_64) go_arch=amd64;; esac && \
cd /tmp && curl -sSLO https://github.com/hr3lxphr6j/bililive-go/releases/download/$tag/bililive-linux-\${go_arch}.tar.gz && \
tar zxvf bililive-linux-\${go_arch}.tar.gz bililive-linux-\${go_arch} && \
chmod +x bililive-linux-\${go_arch} && \
mv ./bililive-linux-\${go_arch} /usr/bin/bililive-go && \
rm ./bililive-linux-\${go_arch}.tar.gz" && \
sh -c "if [ $tag != $(/usr/bin/bililive-go --version | tr -d '\n') ]; then return 1; fi"

COPY config.docker.yml $CONF_DIR/config.yml

apk add --no-cache ffmpeg libc6-compat curl su-exec tzdata && \
cp -r -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
rm -rf /var/cache/apk/*

RUN set -ex; \
case $(arch) in \
aarch64) go_arch="arm64" ;; \
arm*) go_arch="arm" ;; \
i386|i686) go_arch="386" ;; \
x86_64) go_arch="amd64" ;; \
esac; \
curl -fsSLo bililive-linux-${go_arch}.tar.gz "https://github.com/hr3lxphr6j/bililive-go/releases/download/${tag}/bililive-linux-${go_arch}.tar.gz" && \
tar zxvf bililive-linux-${go_arch}.tar.gz && \
chmod +x bililive-linux-${go_arch} && \
mv bililive-linux-${go_arch} /usr/bin/bililive-go && \
rm -rf bililive-linux-${go_arch}.tar.gz /tmp/*

COPY config.yml /defaults/config.yml
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

VOLUME $OUTPUT_DIR

EXPOSE $PORT

WORKDIR ${WORKDIR}
ENTRYPOINT [ "sh" ]
CMD [ "/entrypoint.sh" ]
CMD [ "/entrypoint.sh" ]
6 changes: 5 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

HOME=/srv/bililive

if [ ! -f $CONF_DIR/config.yml ]; then
cp /defaults/config.yml $CONF_DIR/config.yml
fi

chown -R ${PUID}:${PGID} ${HOME}

umask ${UMASK}

exec su-exec ${PUID}:${PGID} /usr/bin/bililive-go -c /etc/bililive-go/config.yml
exec su-exec ${PUID}:${PGID} /usr/bin/bililive-go -c /etc/bililive-go/config.yml

0 comments on commit b5316e5

Please sign in to comment.