I packaged my Node.js/Angular app using Docker, and I setup a GitLab Runner for one-click deployment to deploy the changes to the live server. docker-compose.yml: version: "3" services: client: build: context: ... dockerfile: ... ... server: build: context: ... dockerfile: ... ... Problem is, when the build reaches this part in the Dockerfile: ng build --prod It always fails, and I get an out of memory error on the server (1GB of RAM). "build-prod": "ng build --prod --aot=true --buildOptimizer=true", Is there a workaround, aside from building the files on my local machine and committing them to the repository, and just copy/pasting those files? Dockerfile for client: # STAGE 1 - Build app FROM node:12-alpine as client WORKDIR /app COPY package*.json ./ RUN npm install COPY . . RUN npm run build-prod #STAGE 2: Run NGINX FROM nginx COPY --from=client /app/dist/* /var/www/html COPY default.conf /etc/nginx/conf.d/default.conf EXPOSE 80 UPDATE: I tried the suggestion to use max_old_space_size, but the build still fails, although the error is different this time: Before using max_old_space_size, the build usually already fails right after Browserslist: caniuse-lite is outdated. Please run next command npm update, but here, it managed to get past that. Continue reading...