Base solution for your next web application
Open Closed

URGENT : NPM run build missing on Dockerfile #10072


User avatar
0
nagib.aouini created

Hi We tried to use the Dockerfile on the MVC project to build a docker image We use latest ASP.NET CORE MVC JQUERY

Here is the Generated Dockerfile by ASPNETZERO

  1. When we build the Docker image, the deployed image does not work because the minification process never happens
  2. the website then have error 404

Can you please provide exact Dockerfile include the minification process (npm run build)

-->

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base WORKDIR /app EXPOSE 80 EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build WORKDIR /src COPY ["src/ABC.ADMIN.Web.Mvc/ABC.ADMIN.Web.Mvc.csproj", "src/ABC.ADMIN.Web.Mvc/"] COPY ["src/ABC.ADMIN.Web.Core/ABC.ADMIN.Web.Core.csproj", "src/ABC.ADMIN.Web.Core/"] COPY ["src/ABC.ADMIN.Application/ABC.ADMIN.Application.csproj", "src/ABC.ADMIN.Application/"] COPY ["src/ABC.ADMIN.Application.Shared/ABC.ADMIN.Application.Shared.csproj", "src/ABC.ADMIN.Application.Shared/"] COPY ["src/ABC.ADMIN.Core.Shared/ABC.ADMIN.Core.Shared.csproj", "src/ABC.ADMIN.Core.Shared/"] COPY ["src/ABC.ADMIN.Core/ABC.ADMIN.Core.csproj", "src/ABC.ADMIN.Core/"] COPY ["src/ABC.ADMIN.EntityFrameworkCore/DUOKEY.ADMIN.EntityFrameworkCore.csproj", "src/ABC.ADMIN.EntityFrameworkCore/"] COPY ["src/ABC.ADMIN.GraphQL/ABC.ADMIN.GraphQL.csproj", "src/ABC.ADMIN.GraphQL/"] RUN dotnet restore "src/ABC.ADMIN.Web.Mvc/ABC.ADMIN.Web.Mvc.csproj" COPY . . WORKDIR "/src/src/ABC.ADMIN.Web.Mvc" RUN dotnet build "ABC.ADMIN.Web.Mvc.csproj" -c Release -o /app/build

FROM build AS publish RUN dotnet publish "ABC.ADMIN.Web.Mvc.csproj" -c Release -o /app/publish

FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "ABC.ADMIN.Web.Mvc.dll"]


11 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    These files updated recently. Could you copy the steps from https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/build/build-mvc.ps1 to your project ?

  • User Avatar
    0
    nagib.aouini created

    Thanks i added the yarn run build in the Dockerfile but i got a strange error in the Azure Pipeline

    Step 23/38 : RUN yarn run build ---> Running in 5a828dd87f77 yarn run v1.22.5 warning package.json: No license field $ yarn && gulp build warning package.json: No license field warning [email protected]: No license field [1/4] Resolving packages... success Already up-to-date. [08:01:51] Using gulpfile /app/gulpfile.js [08:01:51] Starting 'build'... File not found: /app/node_modules/gridstack/dist/gridstack.jQueryUI.min.js File not found: /app/wwwroot/view-resources/Areas/App/Views/CustomizableDashboard/Widgets/WidgetBase.js File not found: /app/wwwroot/view-resources/Areas/App/Views/CustomizableDashboard/Index.js File not found: /app/wwwroot/view-resources/Areas/App/Views/Common/Modals/_LookupModal.js File not found: /app/wwwroot/view-resources/Areas/App/Views/Common/Modals/_EntityTypeHistoryModal.js ..... [08:01:52] 'build' errored after 350 ms [08:01:52] Error: Invalid glob argument: at Gulp.src (/app/node_modules/vinyl-fs/lib/src/index.js:20:11) at createScriptBundle (/app/gulpfile.js:150:23) at createScriptBundles (/app/gulpfile.js:139:13) at build (/app/gulpfile.js:270:23) at build (/app/node_modules/undertaker/lib/set-task.js:13:15) at bound (node:domain:416:15) at runBound (node:domain:427:12) at asyncRunner (/app/node_modules/async-done/index.js:55:18) at processTicksAndRejections (node:internal/process/task_queues:76:11) error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. The command '/bin/sh -c yarn run build' returned a non-zero code: 1

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I can see that those files are (except gridstack.jQueryUI.min.js), in the source code of AspNet Zero. gridstack.jQueryUI.min.js must be installed by the yarn command. Could you check the solution directory to see if those files exist ?

  • User Avatar
    0
    nagib.aouini created

    Can you update so the Dockerfile to fix this issue it is related i think to NPM package missing

    https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Mvc/Dockerfile

    I think it missed the NPM Restore package step and yarn build step RUN yarn RUN yarn run build

  • User Avatar
    0
    nagib.aouini created

    This is my actual folder

  • User Avatar
    0
    nagib.aouini created

    Hi In Azure pipeline, it does not work to create a docker image --> Are you able to have a working Azure Pipeline which create a docker image ?

    Step 23/40 : RUN npm --version ---> Running in 01488bb0eb64 7.5.1 Removing intermediate container 01488bb0eb64 ---> ee95627dd624 Step 24/40 : RUN gulp --version ---> Running in df3b02c8bf1a CLI version: 2.3.0 Local version: Unknown Removing intermediate container df3b02c8bf1a ---> bfc87e02ad2a Step 25/40 : RUN yarn && gulp build ---> Running in 9ddb87ca676a yarn install v1.22.5

    Step 25/40 : RUN yarn && gulp build ---> Running in 9ddb87ca676a yarn install v1.22.5 warning package.json: No license field warning [email protected]: No license field [1/4] Resolving packages... [2/4] Fetching packages... warning [email protected]: Unable to read "./man" directory of module "json2" warning [email protected]: Unable to read "./man" directory of module "joosex-simplerequest" warning [email protected]: Unable to read "./man" directory of module "joose" warning [email protected]: Unable to read "./man" directory of module "joosex-namespace-depended" info [email protected]: The platform "linux" is incompatible with this module. info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... warning " > [email protected]" has incorrect peer dependency "bootstrap@^3.1.1". warning " > [email protected]" has incorrect peer dependency "[email protected]". warning "js-url > [email protected]" has unmet peer dependency "grunt@>=1.0.3". [4/4] Building fresh packages... Done in 32.83s. [12:30:29] Using gulpfile /app/gulpfile.js [12:30:29] Starting 'build'... .....

    [12:30:29] Error: Invalid glob argument: at Gulp.src (/app/node_modules/vinyl-fs/lib/src/index.js:20:11) at createScriptBundle (/app/gulpfile.js:150:23) at createScriptBundles (/app/gulpfile.js:139:13) at build (/app/gulpfile.js:270:23) at build (/app/node_modules/undertaker/lib/set-task.js:13:15) at bound (node:domain:416:15) at runBound (node:domain:427:12) at asyncRunner (/app/node_modules/async-done/index.js:55:18) at processTicksAndRejections (node:internal/process/task_queues:76:11) The command '/bin/sh -c yarn && gulp build' returned a non-zero code: 1 ##[error]The command '/bin/sh -c yarn && gulp build' returned a non-zero code: 1 ##[error]The process '/usr/bin/docker' failed with exit code 1 Finishing: Build and push an image to container registry

  • User Avatar
    0
    nagib.aouini created

    If i build on a Windows agent machine, it works, so i conclude a pb with path on ubuntu ? or linux ?

    ============================================================================== Task : Command line Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows Version : 2.182.0 Author : Microsoft Corporation Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line

    Generating script. ========================== Starting Command Output =========================== "C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\a_temp\23803865-00f0-4939-8aef-7e44aca3150d.cmd"" The system cannot find the path specified.

    [email protected] build D:\a\1\s\src\xxxxx.ADMIN.Web.Mvc yarn && gulp build

    yarn install v1.17.3 warning package.json: No license field warning [email protected]: No license field [1/4] Resolving packages... success Already up-to-date. Done in 0.56s. [12:56:20] Using gulpfile D:\a\1\s\src\xxxxx.ADMIN.Web.Mvc\gulpfile.js [12:56:20] Starting 'build'... File not found: D:\a\1\s\src\xxxxx.ADMIN.Web.Mvc\node_modules\gridstack\dist\gridstack.jQueryUI.min.js File not found: D:\a\1\s\src\xxxxx.ADMIN.Web.Mvc\wwwroot\view-resources\Areas\App\Views\DynamicEntityProperties_CreateOrEditModal.js [12:59:12] Finished 'build' after 2.87 min Finishing: NPM RUN build task

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @nagib.aouini

    We haven't tried this with an Azure pipeline. But, if it works on Windows, then you are right. Probably there is a case difference in one of the paths.

    Since you have access the folder structure, could you check full paths for gridstack.jQueryUI.min.js and DynamicEntityProperties_CreateOrEditModal.js and share it with us ?

    Thanks,

  • User Avatar
    0
    nagib.aouini created

    Hi We fixed tha path issue as it was requested /App on the dowload and linux VM look for /app

    But this is not helping us

    • Can you please help us to make a functional Dockerfile for MVC project that include the npm run build for Azure Pipeline
    • same for Angular project

    Does anyone have a full functional Azure pipeline that build and push docker image ?

    Cheers

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @nagib.aouini

    What is the latest problem you face ?

  • User Avatar
    0
    nagib.aouini created

    Thanks for your support. was a uppercase pb on Linux agent for Azure devOPS