mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-11-15 19:22:19 +08:00
feat: Optimize the way to get 'gosu' files (#600)
* feat: Optimize the way to get 'gosu' files * Update Dockerfile and docker-entrypoint.sh * change gosu copy source --------- Co-authored-by: genteure <genteure@gmail.com>
This commit is contained in:
parent
5f047d4e4a
commit
0a2a00ca9f
|
@ -1,32 +1,22 @@
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0
|
||||||
ENV TZ=Asia/Shanghai
|
ENV TZ=Asia/Shanghai
|
||||||
ENV GOSU_VERSION=1.17
|
|
||||||
|
|
||||||
ENV UMASK=022
|
ENV UMASK=022
|
||||||
ENV PUID=1000
|
ENV PUID=0
|
||||||
ENV PGID=1000
|
ENV PGID=0
|
||||||
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
VOLUME [ "/rec" ]
|
VOLUME [ "/rec" ]
|
||||||
|
|
||||||
|
COPY --from=tianon/gosu:1.17 /gosu /usr/local/bin/
|
||||||
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
||||||
COPY ./BililiveRecorder.Cli/bin/docker_out /app
|
COPY ./BililiveRecorder.Cli/bin/docker_out /app
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN chmod a+x /usr/local/bin/docker-entrypoint.sh && \
|
||||||
apt-get install -y wget && \
|
chmod -R 777 /app && \
|
||||||
rm -rf /var/lib/apt/lists/* && \
|
|
||||||
useradd -r -g users user && \
|
|
||||||
chmod a+x /usr/local/bin/docker-entrypoint.sh && \
|
|
||||||
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
|
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
|
||||||
echo $TZ > /etc/timezone
|
echo $TZ > /etc/timezone
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
|
||||||
|
|
||||||
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then wget -O /usr/local/bin/gosu https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-amd64; fi; if [ "$TARGETPLATFORM" = "linux/arm64" ]; then wget -O /usr/local/bin/gosu https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-arm64; fi; if [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then wget -O /usr/local/bin/gosu https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-armhf; fi
|
|
||||||
|
|
||||||
RUN chmod +x /usr/local/bin/gosu
|
|
||||||
|
|
||||||
EXPOSE 2356/tcp
|
EXPOSE 2356/tcp
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||||
|
|
|
@ -2,14 +2,19 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
umask $UMASK
|
umask "$UMASK"
|
||||||
|
|
||||||
usermod -u $PUID user
|
if [ "$(id -u)" != "0" ]; then
|
||||||
groupmod -g $PGID users
|
echo "Skipped changing user and group because current user is not root."
|
||||||
|
exec dotnet /app/BililiveRecorder.Cli.dll "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
chown -R user:users /app
|
PUID=${PUID:-0}
|
||||||
chown -R user:users /rec
|
PGID=${PGID:-0}
|
||||||
|
|
||||||
export HOME=/home/user
|
if [ "${PUID}" != "0" ] && [ "${PGID}" != "0" ]; then
|
||||||
|
chown -R "${PUID}":"${PGID}" /rec
|
||||||
exec /usr/local/bin/gosu user dotnet /app/BililiveRecorder.Cli.dll $@
|
exec /usr/local/bin/gosu "${PUID}":"${PGID}" dotnet /app/BililiveRecorder.Cli.dll "$@"
|
||||||
|
else
|
||||||
|
exec dotnet /app/BililiveRecorder.Cli.dll "$@"
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user