1

I am trying to setup Github Actions workflow to automatically build and push docker image of my nuxt app,

When the workflow finishes and I pull the image and run it, the web application doesn't load and memory consumption starts getting higher and higher until the docker container stops with the following error.

<--- Last few GCs --->

[28:0x7f75bc1ae310] 730417 ms: Mark-sweep (reduce) 2040.7 (2083.0) -> 2039.5 (2083.2) MB, 4274.1 / 0.5 ms (average mu = 0.200, current mu = 0.163) allocation failure scavenge might not succeed [28:0x7f75bc1ae310] 734992 ms: Mark-sweep (reduce) 2040.6 (2083.2) -> 2039.7 (2083.2) MB, 4549.0 / 0.5 ms (average mu = 0.112, current mu = 0.006) allocation failure scavenge might not succeed

<--- JS stacktrace -->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. error Command failed with signal "SIGABRT".

I did an strace of my container's process and this portion kept repeating infinitely (a network call for an API endpoint I am calling in my application "GET /tags/active")

write(42261, "GET /tags/active HTTP/1.1\r\nAccep"..., 797) = 797
getsockopt(42262, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
write(42262, "GET /tags/active HTTP/1.1\r\nAccep"..., 778) = 778
epoll_ctl(13, EPOLL_CTL_ADD, 42263, {events=EPOLLIN, data={u32=42263, u64=42263}}) = 0
epoll_ctl(13, EPOLL_CTL_ADD, 42264, {events=EPOLLIN, data={u32=42264, u64=42264}}) = 0
epoll_ctl(13, EPOLL_CTL_ADD, 42261, {events=EPOLLIN, data={u32=42261, u64=42261}}) = -1 EEXIST (File exists)
epoll_ctl(13, EPOLL_CTL_MOD, 42261, {events=EPOLLIN, data={u32=42261, u64=42261}}) = 0
epoll_ctl(13, EPOLL_CTL_ADD, 42262, {events=EPOLLIN, data={u32=42262, u64=42262}}) = -1 EEXIST (File exists)
epoll_ctl(13, EPOLL_CTL_MOD, 42262, {events=EPOLLIN, data={u32=42262, u64=42262}}) = 0
epoll_pwait(13, [{events=EPOLLIN, data={u32=42263, u64=42263}}, {events=EPOLLIN, data={u32=42264, u64=42264}}], 1024, 0, NULL, 8) = 2
read(42263, "GET /tags/active HTTP/1.1\r\nAccep"..., 65536) = 797
futex(0x7f75b35e69a4, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x557c4d5da464, FUTEX_WAKE_PRIVATE, 1) = 1
read(42264, "GET /tags/active HTTP/1.1\r\nAccep"..., 65536) = 778
futex(0x7f75b25e09a4, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x557c4d5da464, FUTEX_WAKE_PRIVATE, 1) = 1
epoll_pwait(13, [{events=EPOLLIN, data={u32=16, u64=16}}], 1024, 0, NULL, 8) = 1
read(16, "\1\0\0\0\0\0\0\0", 1024)      = 8
futex(0x7f75b2de39a4, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x557c4d5da464, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f75b1ddd9a4, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x557c4d5da464, FUTEX_WAKE_PRIVATE, 1) = 1
epoll_pwait(13, [{events=EPOLLIN, data={u32=16, u64=16}}], 1024, 0, NULL, 8) = 1
read(16, "\1\0\0\0\0\0\0\0", 1024)      = 8
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 42265
connect(42265, {sa_family=AF_INET, sin_port=htons(3000), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 42266
connect(42266, {sa_family=AF_INET, sin_port=htons(3000), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)
epoll_ctl(13, EPOLL_CTL_ADD, 42265, {events=EPOLLOUT, data={u32=42265, u64=42265}}) = 0
epoll_ctl(13, EPOLL_CTL_ADD, 42266, {events=EPOLLOUT, data={u32=42266, u64=42266}}) = 0
epoll_pwait(13, [{events=EPOLLIN, data={u32=18, u64=18}}, {events=EPOLLOUT, data={u32=42265, u64=42265}}, {events=EPOLLOUT, data={u32=42266, u64=42266}}], 1024, 0, NULL, 8) = 3
accept4(18, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK) = 42267
getpeername(42267, {sa_family=AF_INET, sin_port=htons(35257), sin_addr=inet_addr("127.0.0.1")}, [128 => 16]) = 0
accept4(18, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK) = 42268
getpeername(42268, {sa_family=AF_INET, sin_port=htons(35259), sin_addr=inet_addr("127.0.0.1")}, [128 => 16]) = 0
accept4(18, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK) = -1 EAGAIN (Resource temporarily unavailable)
getsockopt(42265, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
write(42265, "GET /tags/active HTTP/1.1\r\nAccep"..., 797) = 797
getsockopt(42266, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
write(42266, "GET /tags/active HTTP/1.1\r\nAccep"..., 778) = 778

This is my Dockerfile

FROM node:alpine as builder


WORKDIR /app
 
RUN apk update && apk upgrade && apk add git
 
COPY package.json yarn.lock ./
 
RUN yarn install \
  --prefer-offline \
  --frozen-lockfile \
  --non-interactive \
  --production=false
 
COPY . .
 
RUN --mount=type=secret,id=MOUHIM_API_URL \
    --mount=type=secret,id=GOOGLE_CLIENT_ID \
      --mount=type=secret,id=GOOGLE_REDIRECT_URI \
        --mount=type=secret,id=FACEBOOK_CLIENT_ID \
          --mount=type=secret,id=FACEBOOK_REDIRECT_URI \
           export MOUHIM_API_URL=$(cat /run/secrets/MOUHIM_API_URL) && \
           export GOOGLE_CLIENT_ID=$(cat /run/secrets/GOOGLE_CLIENT_ID) && \
           export GOOGLE_REDIRECT_URI=$(cat /run/secrets/GOOGLE_REDIRECT_URI) && \
           export FACEBOOK_CLIENT_ID=$(cat /run/secrets/FACEBOOK_CLIENT_ID) && \
           export FACEBOOK_REDIRECT_URI=$(cat /run/secrets/FACEBOOK_REDIRECT_URI) && \
           yarn build && \
           rm -rf node_modules
 
RUN NODE_ENV=production yarn install \
  --prefer-offline \
  --pure-lockfile \
  --non-interactive \
  --production=true
 
FROM node:alpine
 
WORKDIR /app
 
COPY --from=builder /app  .
 
ENV HOST 0.0.0.0
EXPOSE 3000
 
CMD [ "yarn", "start" ]

this is my Github Workflow yml file

name: Docker
 
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
 
on:
  push:
    branches: [ master ]
    # Publish semver tags as releases.
    tags: [ 'v*.*.*' ]
  pull_request:
    branches: [ master ]
 
 
env:
  # Use docker.io for Docker Hub if empty
  REGISTRY: ghcr.io
  # github.repository as <account>/<repo>
  IMAGE_NAME: ${{ github.repository }}
 
jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
 
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
 
      # Login against a Docker registry except on PR
      # https://github.com/docker/login-action
      - name: Log into registry ${{ env.REGISTRY }}
        if: github.event_name != 'pull_request'
        uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
 
      # Extract metadata (tags, labels) for Docker
      # https://github.com/docker/metadata-action
      - name: Extract Docker metadata
        id: meta
        uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
        with:
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
 
      # Build and push Docker image with Buildx (don't push on PR)
      # https://github.com/docker/build-push-action
      - name: Build and push Docker image
        uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
        with:
          context: .
          push: ${{ github.event_name != 'pull_request' }}
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          secrets: |
            "MOUHIM_API_URL=https://example.com/api"
            "GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }}"
            "GOOGLE_REDIRECT_URI=${{ secrets.GOOGLE_REDIRECT_URI }}"
            "FACEBOOK_CLIENT_ID=${{ secrets.FACEBOOK_CLIENT_ID }}"
            "FACEBOOK_REDIRECT_URI=${{ secrets.FACEBOOK_REDIRECT_URI }}"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.