spech66 / lifelogbb

Lifelog - All your life related things in one place.
GNU Affero General Public License v3.0
6 stars 0 forks source link

Docker build error 18.08 CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [/src/LifelogBb/LifelogBb.csproj] #1

Open JahFyahh opened 9 months ago

JahFyahh commented 9 months ago

I just tried to install the docker version, but I'm getting the below during the build proces. Im running it on a Debian OS:

5.10.0-26-amd64 #1 SMP Debian 5.10.197-1 (2023-09-29) x86_64 GNU/Linux

Build log:

[+] Building 123.9s (15/17)                                                                                                                                                                    docker:default
 => [internal] load .dockerignore                                                                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                                                                          0.0s
 => [internal] load build definition from Dockerfile                                                                                                                                                     0.0s
 => => transferring dockerfile: 714B                                                                                                                                                                     0.0s
 => [internal] load metadata for mcr.microsoft.com/dotnet/sdk:7.0                                                                                                                                        0.4s
 => [internal] load metadata for mcr.microsoft.com/dotnet/aspnet:7.0                                                                                                                                     0.4s
 => [build 1/7] FROM mcr.microsoft.com/dotnet/sdk:7.0@sha256:6b9c857a60b67f968fd5bae373e414690947b8b58e7951b3228fd712b82938e8                                                                           42.7s
 => => resolve mcr.microsoft.com/dotnet/sdk:7.0@sha256:6b9c857a60b67f968fd5bae373e414690947b8b58e7951b3228fd712b82938e8                                                                                  0.1s
 => => sha256:6b9c857a60b67f968fd5bae373e414690947b8b58e7951b3228fd712b82938e8 1.79kB / 1.79kB                                                                                                           0.0s
 => => sha256:8735e8a035f1e0570dfb1445a77796553303551a1e82d5a2b6d50361b0251182 2.01kB / 2.01kB                                                                                                           0.0s
 => => sha256:8708e7f49f5ee03721b3a7cd08fcac0aa438a3bf13b7a4bf724b09a28531227a 5.31kB / 5.31kB                                                                                                           0.0s
 => => sha256:33fea50aa175135c2055291e1b467357bb9966df295a268ee223c04502808566 32.46MB / 32.46MB                                                                                                         4.8s
 => => sha256:f1a16b642b9ba3749153bc3b7a94febdd7c29f4a8b1117e1b6a34d64a075ba0e 154B / 154B                                                                                                               0.5s
 => => sha256:bb235668063aeb3b34222b7ed334c4896a8969ee05e2e9678bc700b3cfc81030 10.12MB / 10.12MB                                                                                                         4.4s
 => => sha256:afe0786398bf4a067bc9472f25a7193bc85427c74c519c09c14b797a400d4da3 25.38MB / 25.38MB                                                                                                         9.8s
 => => sha256:5ee0f6f05da7b7a3bfbdbb30450063efe9645986df6328d3e609544ff70c8d5e 181.06MB / 181.06MB                                                                                                      24.8s
 => => extracting sha256:33fea50aa175135c2055291e1b467357bb9966df295a268ee223c04502808566                                                                                                              118.4s
 => => sha256:8bc34004474621cb8a5a861be1e20661554d6d7fd3aa1788e07cd091125d6d53 13.97MB / 13.97MB                                                                                                        11.4s
 => => extracting sha256:bb235668063aeb3b34222b7ed334c4896a8969ee05e2e9678bc700b3cfc81030                                                                                                              115.9s
 => => extracting sha256:afe0786398bf4a067bc9472f25a7193bc85427c74c519c09c14b797a400d4da3                                                                                                                4.2s
 => => extracting sha256:5ee0f6f05da7b7a3bfbdbb30450063efe9645986df6328d3e609544ff70c8d5e                                                                                                               15.8s
 => => extracting sha256:8bc34004474621cb8a5a861be1e20661554d6d7fd3aa1788e07cd091125d6d53                                                                                                                1.3s
 => [internal] load build context                                                                                                                                                                        0.1s
 => => transferring context: 16.21kB                                                                                                                                                                     0.0s
 => [base 1/2] FROM mcr.microsoft.com/dotnet/aspnet:7.0@sha256:9658a001bc235f15d2d7f3a68f90cb1897f2fdc3e2e74161605c076d3472e39c                                                                          8.7s
 => => resolve mcr.microsoft.com/dotnet/aspnet:7.0@sha256:9658a001bc235f15d2d7f3a68f90cb1897f2fdc3e2e74161605c076d3472e39c                                                                               0.1s
 => => sha256:9658a001bc235f15d2d7f3a68f90cb1897f2fdc3e2e74161605c076d3472e39c 1.79kB / 1.79kB                                                                                                           0.0s
 => => sha256:48db698e04b79ef02519a0e15957cbe51f42473679d23a434e371555237934d8 1.37kB / 1.37kB                                                                                                           0.0s
 => => sha256:e064f572da944c2c04303aaf8fdcacd7dd016473edbbbdf69b0b6e9b3d2a7f40 2.35kB / 2.35kB                                                                                                           0.0s
 => => sha256:33fea50aa175135c2055291e1b467357bb9966df295a268ee223c04502808566 32.46MB / 32.46MB                                                                                                         4.8s
 => => sha256:f1a16b642b9ba3749153bc3b7a94febdd7c29f4a8b1117e1b6a34d64a075ba0e 154B / 154B                                                                                                               0.5s
 => => sha256:bb235668063aeb3b34222b7ed334c4896a8969ee05e2e9678bc700b3cfc81030 10.12MB / 10.12MB                                                                                                         4.4s
 => => extracting sha256:33fea50aa175135c2055291e1b467357bb9966df295a268ee223c04502808566                                                                                                                2.3s
 => => extracting sha256:f1a16b642b9ba3749153bc3b7a94febdd7c29f4a8b1117e1b6a34d64a075ba0e                                                                                                                0.0s
 => => extracting sha256:bb235668063aeb3b34222b7ed334c4896a8969ee05e2e9678bc700b3cfc81030                                                                                                                1.1s
 => [base 2/2] WORKDIR /app                                                                                                                                                                              3.3s
 => [final 1/2] WORKDIR /app                                                                                                                                                                             1.0s
 => [build 2/7] WORKDIR /src                                                                                                                                                                            14.7s
 => [build 3/7] COPY [LifelogBb.csproj, LifelogBb/]                                                                                                                                                      0.3s
 => [build 4/7] RUN dotnet restore LifelogBb/LifelogBb.csproj                                                                                                                                           45.8s
 => [build 5/7] COPY . .                                                                                                                                                                                 0.6s
 => [build 6/7] WORKDIR /src/LifelogBb                                                                                                                                                                   0.1s
 => ERROR [build 7/7] RUN dotnet build "LifelogBb.csproj" -c Release -o /app/build                                                                                                                      19.1s
------
 > [build 7/7] RUN dotnet build "LifelogBb.csproj" -c Release -o /app/build:
1.179 MSBuild version 17.7.4+3ebbd7c49 for .NET
4.996   Determining projects to restore...
6.455   All projects are up-to-date for restore.
18.08 CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [/src/LifelogBb/LifelogBb.csproj]
18.18
18.18 Build FAILED.
18.18
18.18 CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [/src/LifelogBb/LifelogBb.csproj]
18.18     0 Warning(s)
18.18     1 Error(s)
18.18
18.18 Time Elapsed 00:00:16.56
------
Dockerfile:14
--------------------
  12 |     COPY . .
  13 |     WORKDIR "/src/LifelogBb"
  14 | >>> RUN dotnet build "LifelogBb.csproj" -c Release -o /app/build
  15 |
  16 |     FROM build AS publish
--------------------
ERROR: failed to solve: process "/bin/sh -c dotnet build \"LifelogBb.csproj\" -c Release -o /app/build" did not complete successfully: exit code: 1

My Dockerfile:

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["LifelogBb.csproj", "LifelogBb/"]
RUN dotnet restore LifelogBb/LifelogBb.csproj
COPY . .
WORKDIR "/src/LifelogBb"
RUN dotnet build "LifelogBb.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "LifelogBb.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "LifelogBb.dll"]
spech66 commented 3 months ago

Hey, sorry for the really late reply. I rarely use Docker but deploy to the server using ansible.

The release version is build without the UseAppHost flag https://github.com/spech66/lifelogbb/blob/main/.github/workflows/release.yml Could you give this a try?