简体   繁体   English

在 GitLab 上部署 Docker 项目失败,退出代码为 137?

[英]Deploying Docker project on GitLab fails with 137 exit code?

I am trying to deploy a Dockerized Angular/Node.js project on GitLab via Pipelines.我正在尝试通过管道在 GitLab 上部署一个 Dockerized Angular/Node.js 项目。

The issue is, once the build gets to ng build --prod , the build is stuck there for several minutes, before failing with an exit code of 137 .问题是,一旦构建到达ng build --prod ,构建就会在那里停留几分钟,然后以exit code of 137失败。

在此处输入图片说明 ] ] 在此处输入图片说明

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

GitLab CI/CD config: 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

client/Dockerfile客户端/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客户端/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

When I try to build this locally, everything works fine.当我尝试在本地构建它时,一切正常。 Could this be a memory issue on the server?这可能是服务器上的内存问题吗?

I'm still investigating, but so far, the build is able to succeed after these changes:我仍在调查中,但到目前为止,构建能够在这些更改后成功:

  • Use node:12-alpine (actually this just produced a different error message, but essentially still the same error -> out of memory)使用node:12-alpine (实际上这只是产生了不同的错误消息,但本质上仍然是相同的错误 -> 内存不足)
  • Upgrade the server RAM to 2GB from 1GB将服务器内存从 1GB 升级到 2GB

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM