我正在尝试将 this project(分支滑翔机)部署到 Heroku。该项目是用 .net core 5.0 编写的,我为 github 操作创建了一个 YML 脚本:
name: Heroku
on: [push]
jobs:
deploy_glista:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Build and deploy the Docker image
env:
HEROKU_USERNAME: ${{ secrets.HEROKU_USERNAME }}
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
APP_NAME: ${{ 'glista' }}
run: |
docker login --username=$HEROKU_USERNAME --password=$HEROKU_API_KEY registry.heroku.com
heroku container:push web -a $APP_NAME
heroku container:release web -a $APP_NAME
附带Dockerfile:
# NuGet restore
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY *.sln .
COPY Test/*.csproj Test/
COPY Core/*.csproj Core/
COPY Api/*.csproj Api/
RUN dotnet restore "Api/Glista.Api.csproj"
COPY . .
# testing
FROM build AS testing
WORKDIR /src/Api
RUN dotnet build
WORKDIR /src/Test
RUN dotnet test
# publish
FROM build AS publish
WORKDIR /src/Api
RUN dotnet publish -c Release -o /src/publish
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS runtime
WORKDIR /app
COPY --from=publish /src/publish .
# ENTRYPOINT ["dotnet", "Api.dll"]
# heroku uses the following
CMD ASPNETCORE_URLS=http://*:$PORT dotnet Api.dll
为了测试,每次推送都会执行部署。无论如何,从 Dockerfile 调用 dotnet restore
时会出错。似乎我无法通过以下错误:
/src/Api/Glista.Api.csproj : error NU3028: Package 'System.Text.Encoding.CodePages 4.5.1' from source 'https://api.nuget.org/v3/index.json': The repository countersignature's timestamp found a chain building issue: UntrustedRoot: self signed certificate in certificate chain
Failed to restore /src/Api/Glista.Api.csproj (in 9.04 sec).
The command '/bin/sh -c dotnet restore "Api/Glista.Api.csproj"' returned a non-zero code: 1
▸ Error: docker build exited with Error: 1
Error: Process completed with exit code 1.
由于我对 Docker 没有经验,而且我无法在谷歌上搜索任何有用的解决方案,有人知道我的部署脚本或 docker 文件有什么问题吗?