diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 20ce578..27caab4 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -47,7 +47,8 @@ jobs: - name: Build and push API image uses: docker/build-push-action@v5 with: - context: ./src/OpenWish.ApiService + context: ./src + file: ./src/OpenWish.Api/Dockerfile push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta-api.outputs.tags }} labels: ${{ steps.meta-api.outputs.labels }} @@ -68,7 +69,8 @@ jobs: - name: Build and push Web image uses: docker/build-push-action@v5 with: - context: ./src/OpenWish.Web + context: ./src + file: ./src/OpenWish.Web/Dockerfile push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta-web.outputs.tags }} labels: ${{ steps.meta-web.outputs.labels }} diff --git a/src/OpenWish.ApiService/Dockerfile b/src/OpenWish.ApiService/Dockerfile index b154407..a4ac82c 100644 --- a/src/OpenWish.ApiService/Dockerfile +++ b/src/OpenWish.ApiService/Dockerfile @@ -4,10 +4,14 @@ EXPOSE 80 FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build WORKDIR /src -COPY ["*.csproj", "./"] -RUN dotnet restore +# Copy solution and project files first +COPY ["OpenWish.ApiService/OpenWish.ApiService.csproj", "OpenWish.ApiService/"] +COPY ["OpenWish.Common/OpenWish.Common.csproj", "OpenWish.Common/"] +COPY ["OpenWish.Data/OpenWish.Data.csproj", "OpenWish.Data/"] +RUN dotnet restore "OpenWish.ApiService/OpenWish.ApiService.csproj" +# Copy the rest of the code COPY . . -RUN dotnet publish -c Release -o /app/publish /p:UseAppHost=false +RUN dotnet publish "OpenWish.ApiService/OpenWish.ApiService.csproj" -c Release -o /app/publish /p:UseAppHost=false FROM base AS final WORKDIR /app diff --git a/src/OpenWish.Web/Dockerfile b/src/OpenWish.Web/Dockerfile index af14ce0..7af592b 100644 --- a/src/OpenWish.Web/Dockerfile +++ b/src/OpenWish.Web/Dockerfile @@ -4,10 +4,14 @@ EXPOSE 80 FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build WORKDIR /src -COPY ["*.csproj", "./"] -RUN dotnet restore +# Copy solution and project files first +COPY ["OpenWish.Web/OpenWish.Web.csproj", "OpenWish.Web/"] +COPY ["OpenWish.Common/OpenWish.Common.csproj", "OpenWish.Common/"] +COPY ["OpenWish.Data/OpenWish.Data.csproj", "OpenWish.Data/"] +RUN dotnet restore "OpenWish.Web/OpenWish.Web.csproj" +# Copy the rest of the code COPY . . -RUN dotnet publish -c Release -o /app/publish /p:UseAppHost=false +RUN dotnet publish "OpenWish.Web/OpenWish.Web.csproj" -c Release -o /app/publish /p:UseAppHost=false FROM base AS final WORKDIR /app