Gitlab docker only has 1GB RAM while its runner has 3GB?

I am trying to do building within a docker within the docker runner on gitlab to push to AWS ECS as a built image, however, I am seeing something that is causing me to build twice and so double my execution time, I have a pipeline like so:

docker alpha2 build:
  stage: Build Image
  script:
    - apk add --no-cache nodejs npm curl jq musl-dev gcc python2-dev python py-pip git g++ make && pip install awscli
    - cp ./.env.alpha2 ./.env
    - sed -i -e "s/APP_ENV=DEV/APP_ENV=ALPHA2/" ./.env
    - sed -i -e "s/3000/80/" ./server.ts
    - npm install && npm run build
    - $(aws ecr get-login --no-include-email --region $AWS_REGION)
    - docker build -t api-alpha2 .
  when: manual
  except:
    - main
    - live

npm run build is quite a simple command: tsc && shx cp -R templates dist

but then within the docker itself, docker build -t api-alpha2 I have to run:

FROM node:erbium-alpine3.11

WORKDIR /usr/src/app

COPY . .

RUN apk add --no-cache musl musl-dev git make gcc g++ python

RUN npm install

EXPOSE 80

CMD ["npm", "run", "start"]

Because I cannot simply copy the C++ bindings from the parent docker runner to the child image for AWS ECS but then I cannot move npm run build to the dockerfile since the docker within the runner only runs on 1GB of RAM.

Anyone got an idea on how I can fix this so I am not building double every time?