在GitLab上部署Docker项目失败,并显示137个退出代码?

时间:2020-03-16 17:19:23

标签: docker gitlab

我正在尝试通过管道在GitLab上部署Dockerized Angular / Node.js项目。

问题是,一旦构建到达ng build --prod,该构建就在那里停留了几分钟,然后失败了exit code of 137

enter image description here] enter image description here

Service 'client' failed to build: The command '/bin/sh -c npm run build-prod' returned a non-zero code: 137

GitLab CI / CD配置:

image: docker:latest

services:
    - docker:dind

stages:
    - deploy

deploy-live:
    stage: deploy
    only: 
        - develop
    script:
        - docker-compose -f client/docker-compose.yml up -d
    when: manual

客户端/ Dockerfile

# STAGE 1 - Build app

# Use node 4.4.5 LTS
FROM node:10.16.3 as client

# Copy files to container
COPY . /app

WORKDIR /app

RUN ls

RUN npm install

RUN npm run build-prod # Build fails when it reaches this part

FROM nginx

COPY --from=client /app/dist/* /usr/share/nginx/html

EXPOSE 80

client / docker-compose.yml

version: "3"
services:
  client:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - 5000:80
    links:
      - server
  server:
    build:
      context: ./server
      dockerfile: Dockerfile
    ports:
      - 3000:3000

当我尝试在本地构建时,一切正常。这可能是服务器上的内存问题吗?

1 个答案:

答案 0 :(得分:0)

我仍在调查,但到目前为止,在进行这些更改后,构建仍可以成功:

  • 使用node:12-alpine(实际上这只是产生了一条不同的错误消息,但基本上仍然是相同的错误->内存不足)
  • 将服务器RAM从1GB升级到2GB