From b5316e5b64a3c56efb7df7519d60c02b9dc27d3e Mon Sep 17 00:00:00 2001 From: w9315273 Date: Sun, 5 May 2024 23:10:36 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86config.yml?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E4=B8=8E=E5=90=A6=E7=9A=84=E5=BA=94=E5=AF=B9?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 48 ++++++++++++++++++++++++++---------------------- entrypoint.sh | 6 +++++- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/Dockerfile b/Dockerfile index e4d359aa..125d32ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" ] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 941ca985..11cf4985 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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 \ No newline at end of file From 78807ac2d2f8a1dddd429cd5c82d10d794da9242 Mon Sep 17 00:00:00 2001 From: w9315273 Date: Mon, 6 May 2024 03:41:41 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0docker=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E6=8C=87=E5=8D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e2f64c8b..a72e4a04 100644 --- a/README.md +++ b/README.md @@ -195,20 +195,60 @@ https://github.com/hr3lxphr6j/bililive-go/wiki/Install-Linux 使用 https://hub.docker.com/r/chigusa/bililive-go 镜像创建容器运行。 例如: -``` -docker run --restart=always -v ~/config.yml:/etc/bililive-go/config.yml -v ~/Videos:/srv/bililive -p 8080:8080 -d chigusa/bililive-go +```bash +docker run -d \ +--name=bililive-go \ +--restart=unless-stopped \ +-p 8080:8080 \ +-v ~/bililive-go/config:/etc/bililive-go \ +-v ~/bililive-go/video:/srv/bililive \ +chigusa/bililive-go ``` ### docker compose +创建 `vim docker-compose.yaml` +```yaml +version: '3.9' +services: + bililive-go: + image: chigusa/bililive-go + container_name: bililive-go + ports: + - "8080:8080" + volumes: + - ./config:/etc/bililive-go + - ./video:/srv/bililive + restart: unless-stopped +``` +部署容器 +``` +docker compose up +``` -使用项目根目录下的 `docker-compose.yml` 配置文件启动 docker compose 运行。 +
+ 进阶设置 -例如: +```bash +# docker cli +-e PUID=0 # 映射用户 +-e PGID=0 # 映射组 ``` -docker compose up +```yaml +# docker compose + environment: + - PUID=0 # 映射用户 + - PGID=0 # 映射组 +``` +`PUID` `PGID` 不建议为`0` 这将以`root`身份运行容器 一些情况下会对权限管理造成麻烦
+使用非 `root` 用户运行容器是推荐的安全做法 可以通过运行 id "你的用户名" 来查找你的 `UID` 和 `GID`
+``` +id "你的用户名" ``` -此时默认使用 `config.docker.yml` 文件作为程序的配置文件,`Videos/` 目录作为录制视频的输出目录。 +会显示例如 `uid=1000` `gid=1000` 等信息 + +
+### NAS NAS 用户使用系统自带 GUI 创建 docker compose 的情况请参考群晖用 docker compose 安装 bgo 的 [图文说明](./docs/Synology-related.md#如何用-docker-compose-安装-bgo) ## 常见问题