Skip to content

Angular fails to build inside docker when target directory for dist does not exist #21208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rongem opened this issue Jun 25, 2021 · 2 comments
Closed

Comments

@rongem
Copy link

rongem commented Jun 25, 2021

Bug Report

Affected Package

Angular compiler(?)

Is this a regression?

Yes, it worked in 12.0.x. Doesn't work in 12.1.0.

Description

When running ng build --configuration production inside a docker image, and the target dist directory does not exist, build fails with the following error (before compiling ES2015 to ESM2015 messages appear):
angular/angular#15 31.41 An unhandled exception occurred: ENOENT: no such file or directory, stat '/usr/app/dist/project'
angular/angular#15 31.41 See "/tmp/ng-WYeBTH/angular-errors.log" for further details.
Can't get to the log, since the image is thrown away.

  • Error does not occure when running ng build locally on my Windows machine.
  • Error occurs on docker hub and on my local machine's Docker desktop in multiple projects.
  • Error does not occure while building a library, but on every frontend (app).

Minimal Reproduction

Dockerfile

FROM node AS build
WORKDIR /usr/app

COPY ./package*.json ./
RUN npm install
COPY ./ ./
RUN npm run build --configuration production

FROM nginx
WORKDIR /usr/app
COPY --from=build /usr/app/dist/project/ /usr/share/nginx/html/
COPY ./nginx/angular.conf /etc/nginx/conf.d/default.conf

Reproducing with (nearly minimal) repo:
https://github.com/rongem/spi/

Exception or Error



An unhandled exception occurred: ENOENT: no such file or directory, stat '/usr/app/dist/project'

Your Environment

Angular Version:



Angular CLI: 12.1.0
Node: 14.16.0
Package Manager: npm 7.19.0
OS: win32 x64

Angular: 12.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1201.0
@angular-devkit/build-angular   12.1.0
@angular-devkit/core            12.1.0
@angular-devkit/schematics      12.1.0
@schematics/angular             12.1.0
rxjs                            6.6.7
typescript                      4.2.4

Anything else relevant?
Docker version 20.10.7, build f0df350, and also Docker hub autobuild feature
Only Docker related, and libs are not affected

Workaround inside Dockerfile is pasting mkdir between copy and ng build
COPY ./ ./
RUN mkdir dist/project
RUN npm run build:all

@JoostK JoostK transferred this issue from angular/angular Jun 25, 2021
@JoostK
Copy link
Member

JoostK commented Jun 25, 2021

Duplicate of #21202.

@JoostK JoostK closed this as completed Jun 25, 2021
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants