Browse Source

添加用户权限管理

SuperNG6 4 years ago
parent
commit
24c7cb7ba4

+ 49 - 0
.github/workflows/Build Image.yml

@@ -0,0 +1,49 @@
+name: Build Docker Image
+
+on:
+  push:
+    paths:
+      - "ReleaseTag"
+  workflow_dispatch:
+
+jobs:
+  buildx:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+
+      # Docker Image 构建环境
+      - name: Set up QEMU
+        uses: docker/setup-qemu-action@v1
+
+      - name: Set up Docker Buildx
+        uses: docker/setup-buildx-action@v1
+
+      - name: Login to DockerHub
+        uses: docker/login-action@v1 
+        with:
+          username: ${{ secrets.DOCKER_USERNAME }}
+          password: ${{ secrets.DOCKER_PASSWORD }}
+
+      # ReleaseTag
+      - name: Set Version
+        id: set-version
+        run: |
+          echo "::set-output name=version::$(cat ReleaseTag | head -n1)"
+          echo "ReleaseTag=$(cat ReleaseTag | head -n1)" 
+          echo "::set-output name=status::success"
+
+      # Build and push
+      - name: Build dockerfile
+        if: steps.set-version.outputs.status == 'success'
+        uses: docker/build-push-action@v2
+        with:
+          file: ./Dockerfile
+          platforms: linux/amd64,linux/arm/v7,linux/arm64
+          push: true
+          tags: |
+            ${{ secrets.DOCKER_USERNAME }}/chinesesubfinder:${{ steps.set-version.outputs.version }}
+            ${{ secrets.DOCKER_USERNAME }}/chinesesubfinder:latest
+
+

+ 11 - 0
Docker/root/etc/cont-init.d/30-config

@@ -0,0 +1,11 @@
+#!/usr/bin/with-contenv bash
+
+# 检查config配置文件,并创建
+if [ ! -e "/config/config.yaml" ] ;  then 
+cp /app/config.yaml /config/config.yaml
+fi
+
+# 检查用户config配置文件,并移动.
+if [ -e "/config/config.yaml" ] ;  then
+cp /config/config.yaml /app/config.yaml
+fi

+ 10 - 0
Docker/root/etc/cont-init.d/50-config

@@ -0,0 +1,10 @@
+#!/usr/bin/with-contenv bash
+
+# permissions
+chown -R abc:abc \
+	/app \
+    /config \
+    /media
+    
+chmod a+x \
+    /app/chinesesubfinder

+ 5 - 0
Docker/root/etc/services.d/chinesesubfinder/run

@@ -0,0 +1,5 @@
+#!/usr/bin/with-contenv bash
+
+# 启动chinesesubfinder
+cd /app
+exec s6-setuidgid abc chinesesubfinder

+ 11 - 8
Dockerfile

@@ -14,7 +14,9 @@ COPY . .
 # 执行编译,-o 指定保存位置和程序编译名称
 RUN go build -ldflags="-s -w" -o /app/chinesesubfinder
 
-FROM ubuntu:bionic
+FROM lsiobase/ubuntu:bionic
+
+COPY Docker/root /
 
 RUN ln -s /root/.cache/rod/chromium-869685/chrome-linux/chrome /usr/bin/chrome && \
     sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list && rm -Rf /var/lib/apt/lists/* && \
@@ -32,23 +34,24 @@ RUN ln -s /root/.cache/rod/chromium-869685/chrome-linux/chrome /usr/bin/chrome &
     ca-certificates \
     # fonts
     fonts-liberation fonts-noto-color-emoji fonts-noto-cjk \
-    # timezone
-    tzdata \
     # processs reaper
     dumb-init \
     # headful mode support, for example: $ xvfb-run chromium-browser --remote-debugging-port=9222
     xvfb \
     # cleanup
-    && rm -rf /var/lib/apt/lists/*
+    && apt-get clean \
+    && rm -rf \
+       /tmp/* \
+       /var/lib/apt/lists/* \
+       /var/tmp/*
 
-ENV TZ Asia/Shanghai
+ENV TZ=Asia/Shanghai \
+    PUID=1026 PGID=100
 
 WORKDIR /app
 # 主程序
 COPY --from=builder /app/chinesesubfinder /app/chinesesubfinder
 # 配置文件
 COPY --from=builder /homelab/buildspace/config.yaml.sample /app/config.yaml
-RUN chmod -R 777 /app
 EXPOSE 1200
-
-ENTRYPOINT ["/app/chinesesubfinder"]
+VOLUME /config /media

+ 1 - 0
ReleaseTag

@@ -0,0 +1 @@
+0.6.2