diff --git a/.editorconfig b/.editorconfig index cb0017e..7bc14d8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,6 +11,10 @@ indent_size = 4 charset = utf-8 insert_final_newline = true +[*.yml] + +indent_size = 2 + [NLog.{Debug,Release}.config] indent_size = 2 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0c72f5f..269f3f8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -82,6 +82,7 @@ jobs: build_docker: needs: test runs-on: ubuntu-latest + if: github.event_name != 'pull_request' permissions: contents: read packages: write @@ -94,11 +95,11 @@ jobs: uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - name: Log into registry ${{ env.REGISTRY }} + - name: Login to GitHub Container Registry if: github.event_name != 'pull_request' - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: - registry: ${{ env.REGISTRY }} + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} # Extract metadata (tags, labels) for Docker @@ -107,7 +108,8 @@ jobs: id: meta uses: docker/metadata-action@v3 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build CLI run: dotnet build -c Release -o ./BililiveRecorder.Cli/bin/docker_out BililiveRecorder.Cli/BililiveRecorder.Cli.csproj # Build and push Docker image with Buildx (don't push on PR) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b0f3a54..1c2e745 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -126,20 +126,28 @@ jobs: uses: docker/setup-buildx-action@v1 # Login against a Docker registry except on PR # https://github.com/docker/login-action - - name: Log into registry ${{ env.REGISTRY }} + - name: Login to GitHub Container Registry if: github.event_name != 'pull_request' - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: - registry: ${{ env.REGISTRY }} + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} # Extract metadata (tags, labels) for Docker # https://github.com/docker/metadata-action - name: Extract Docker metadata id: meta uses: docker/metadata-action@v3 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + bililive/recorder - name: Build CLI run: dotnet build -c Release -o ./BililiveRecorder.Cli/bin/docker_out BililiveRecorder.Cli/BililiveRecorder.Cli.csproj # Build and push Docker image with Buildx (don't push on PR) diff --git a/Dockerfile b/Dockerfile index 2e50767..87bacef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,8 @@ RUN cd /src/BililiveRecorder.Cli && dotnet build -o /output -c Release FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine RUN apk add --no-cache tzdata ENV TZ=Asia/Shanghai -COPY --from=0 /output /app -VOLUME [ "/rec" ] WORKDIR /app +VOLUME [ "/rec" ] +COPY --from=0 /output /app ENTRYPOINT [ "/app/BililiveRecorder.Cli" ] -CMD [ "run", "/rec" ] +CMD [ "run", "--bind", "http://*:2356", "/rec" ] diff --git a/Dockerfile.GitHubActions b/Dockerfile.GitHubActions index 2e286de..ee5e3b3 100644 --- a/Dockerfile.GitHubActions +++ b/Dockerfile.GitHubActions @@ -1,8 +1,8 @@ FROM mcr.microsoft.com/dotnet/aspnet:6.0 ENV TZ=Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone -COPY ./BililiveRecorder.Cli/bin/docker_out /app -VOLUME [ "/rec" ] WORKDIR /app +VOLUME [ "/rec" ] +COPY ./BililiveRecorder.Cli/bin/docker_out /app ENTRYPOINT [ "dotnet", "/app/BililiveRecorder.Cli.dll" ] -CMD [ "run", "/rec" ] +CMD [ "run", "--bind", "http://*:2356", "/rec" ]