I have the cheapest instance os AWS Lightsail (512 MB RAM, 1 vCPU, 20 GB SSD) with Ubuntu 20.04 and I'm trying to deploy a project with 5 containers (django, react, nginx, postgres, redis and celery) using docker-compose (which I manually installed).
The django build was successfull, however docker is returning a 137 error during the react build. It seems that one of the libraries I used has a depreceated dependency at node 14.16.1:
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+.
Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries.
Upgrade to fsevents 2.
I don't know if npm is trying to fix these issues by upgrading the packages, but this is taking a lot of time for docker to continue until it one of two things happen:
- docker throws error 137;
The command '/bin/sh -c apk add --no-cache --virtual .gyp python make g++ && npm install && apk del .gyp' returned a non-zero code: 137
ERROR: Service 'react' failed to build : Build failed
- I lost connection with my instance and couldn't connect to it for hours. AWS returns the following error:
UPSTREAM_NOT_FOUND [519]
The OOM problem is happening because I'm trying to build something that the machine will not support? Or can I adjust some configurations to make it work? How can I fix this?
Dockerfile:
###########
# BUILDER #
###########
FROM node:14.16.1-alpine3.10 as builder
WORKDIR /app/react
# install dependencies and avoid `node-gyp rebuild` errors
COPY ./package.json .
RUN apk add --no-cache --virtual .gyp \
python \
make \
g++ \
&& npm install \
&& apk del .gyp
COPY . .
RUN npm run build
#########
# FINAL #
#########
FROM node:14.16.1-alpine3.10
WORKDIR /app/react
# install serve - deployment static server suggested by official create-react-app
RUN npm install -g serve
COPY --from=builder /app/react/build ./build
Thanks a lot!