0

my angular app works fine (both ng serve and ng build), but when I try to dockerize the application using a Dockerfile like this

# Stage 1: Compile and Build angular codebase

# Use official node image as the base image
FROM node:latest as build

# Set the working directory
WORKDIR /usr/local/app

# Add the source code to app
COPY ./ /usr/local/app/

# Install all the dependencies
RUN npm install


# Generate the build of the application
RUN npm run build-prod-docker


# Stage 2: Serve app with nginx server

# Use official nginx image as the base image
FROM nginx:latest

# Copy the build output to replace the default nginx contents.
COPY --from=build /usr/local/app/dist/app /usr/share/nginx/html

The build fails only in the dockerfile with those kinds of errors:

#14 160.2 ./src/app/app.module.ts:28:0-148 - Error: Module not found: Error: Can't resolve './components/widgets/indicators/indicator-destinations-filter/indicator-destinations-filter.component' in '/usr/local/app/src/app' #14 160.2

#14 160.2 Error: src/app/app.module.ts:35:45 - error TS2307: Cannot find module './components/widgets/indicators/indicator-destinations-filter/indicator-destinations-filter.component' or its corresponding type declarations. #14 160.2 #14 160.2 35 import { IndicatorDestinationsFilter } from "./components/widgets/indicators/indicator-destinations-filter/indicator-destinations-filter.component";

#14 160.2 Error: src/app/components/map/map.component.html:35:1 - error NG8001: 'widget-timeslider' is not a known element: #14 160.2 1. If 'widget-timeslider' is an Angular component, then verify that it is part of this module. #14 160.2 2. If 'widget-timeslider' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. #14 160.2 #14 160.2 35 <widget-timeslider [id]="id+'_timeSlider'" [view]="mapManager.view" [heightVh]="heightVh">

I can't imagine this is due to code errors because both start and build works fine outside the Dockerfile.

Any ideas?

0 Answers0