This is my github actions yaml file content:
name: .NET
on:
push:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build the Docker image
working-directory: CICD-API
run: docker build . -t jushstone/cicd-docker:latest
- name: Log into Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push the image to Docker Hub
run: docker push jushstone/cicd-docker
- name: Pull the image to VM
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script:
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/cicd-docker:latest
docker stop cicd-docker || true
docker rm cicd-docker || true
docker run -d -p 80:80 --name cicd-docker ${{ secrets.DOCKERHUB_USERNAME }}/cicd-docker:latest
This is my dockerfile content:
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["CICD-API/CICD-API.csproj", "CICD-API/"]
COPY ["CICD-Core/CICD-Core.csproj", "CICD-Core/"]
RUN dotnet restore "./CICD-API/CICD-API.csproj"
COPY . .
WORKDIR "/src/CICD-API"
RUN dotnet build "./CICD-API.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./CICD-API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "CICD-API.dll"]
I get an error when building the Docker image and in these two lines in dockerfile produce this error:
COPY ["CICD-API/CICD-API.csproj", "CICD-API/"]
COPY ["CICD-Core/CICD-Core.csproj", "CICD-Core/"]
It says that:
ERROR: failed to calculate checksum of ref 66cd06a6-b278-495c-ae3e-04e926acdc46::8a98uq2w3sytdrzki0tdwy8qq: "/CICD-API/CICD-API.csproj": not found
ERROR: failed to calculate checksum of ref 66cd06a6-b278-495c-ae3e-04e926acdc46::8a98uq2w3sytdrzki0tdwy8qq: "/CICD-Core/CICD-Core.csproj": not found
What is the problem? I think it is from the work directory path, but how can I fix it?