I deploy my nestjs based backend in a docker container to AWS fargate. The deployment works and the container is reachable and the health check is green. Everthing works normal and as expected. After around 5mins the error below occurs the the container task is not reachable anymore and gets restarted. I have not clue what is happening and what I am doing wrong.
Here is the error log from Cloudwatch:
npm timing command:run-script Completed in 305483ms
npm notice
npm notice New minor version of npm available! 8.1.2 -> 8.3.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.3.0>
npm notice Run `npm install -g [email protected]` to update!
npm notice
npm verb stack Error: command failed
npm verb stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
npm verb stack at ChildProcess.emit (node:events:390:28)
npm verb stack at maybeClose (node:internal/child_process:1064:16)
npm verb stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm verb pkgid [email protected]
npm verb cwd /
npm verb Linux 4.14.248-189.473.amzn2.x86_64
npm verb argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "start:prod" "--verbose"
npm verb node v16.13.1
npm verb npm v8.1.2
npm ERR! path /
npm ERR! command failed
npm ERR! signal SIGTERM
npm ERR! command sh -c npm run migrate:deploy && node dist/main
npm verb exit 1
npm timing npm Completed in 305969ms
npm verb code 1
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-12-14T12_24_28_315Z-debug.log
Here is my docker file:
FROM node:16 as build-stage
WORKDIR /app
COPY package*.json ./
COPY prisma ./prisma/
RUN npm install
COPY . .
RUN npm run build
FROM node:16
COPY --from=build-stage /app/node_modules ./node_modules
COPY --from=build-stage /app/prisma ./prisma
COPY --from=build-stage /app/resources ./resources
COPY --from=build-stage /app/package*.json ./
COPY --from=build-stage /app/dist ./dist
EXPOSE 3001
CMD [ "npm", "run", "start:prod", "--verbose"]
Would be really glad and thankful, if someone could help me :) Thanks.
CodePudding user response:
It looks like you are getting a SIGTERM. Is it possible that you have configured a load balancer in front of the ECS service and the healthcheck is failing (thus forcing a recycle of the container(s))?