Angular - Docker Auto Serve App via CI

I have one server with GitLab and another for deployment. The GitLab server is connected via a runner to the deployment server - connection works.

Now I want to auto deploy my angular app via docker. This is my .gitlab-ci.yml File:

image: node:latest

stages:
  - build
  - test

cache:
  paths:
    - node_modules/

install_dependencies:
  stage: build
  script:
    - npm install
    - npm i @angular/cli
    - npm i @angular-devkit/build-angular
  artifacts:
    paths:
      - node_modules/

test_ng_serve:
  stage: test
  script:
    - cd front && ng serve

My idea was to pull the node:latest docker image, install angular via npm and then serve the app (path: /front/). Unfortunately, docker can’t find the cmd ng:

Running with gitlab-runner 10.8.0 (079aad9e)
  on Run1 ff03421d
Using Docker executor with image node:latest ...
Pulling docker image node:latest ...
Using docker image sha256:bcaca117b84da3efe9499d07a38857c619b6ce753861735a78c568289575d1a2 for node:latest ...
Running on runner-ff03421d-project-1-concurrent-0 via web-ubuntu-s-1vcpu-2gb-fra1-01...
Fetching changes...
Removing node_modules/
HEAD is now at b6d24c6 GitLab CI Test
From https://git.socialsyner.gy/web/system
   b6d24c6..05a9c5b  dev        -> origin/dev
Checking out 05a9c5b5 as dev...
Skipping Git submodules setup
Checking cache for default...
Successfully extracted cache
$ npm install
npm WARN saveError ENOENT: no such file or directory, open '/builds/web/system/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/builds/web/system/package.json'
npm WARN system No description
npm WARN system No repository field.
npm WARN system No README data
npm WARN system No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

up to date in 67.679s
$ npm i @angular/cli

> @angular/cli@6.0.7 postinstall /builds/web/system/node_modules/@angular/cli
> node ./bin/ng-update-message.js

npm WARN saveError ENOENT: no such file or directory, open '/builds/web/system/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/builds/web/system/package.json'
npm WARN system No description
npm WARN system No repository field.
npm WARN system No README data
npm WARN system No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ @angular/cli@6.0.7
updated 1 package in 74.266s
$ npm i @angular-devkit/build-angular
npm WARN saveError ENOENT: no such file or directory, open '/builds/web/system/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/builds/web/system/package.json'
npm WARN system No description
npm WARN system No repository field.
npm WARN system No README data
npm WARN system No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ @angular-devkit/build-angular@0.6.8
updated 1 package and audited 51916 packages in 66.933s
found 13 moderate severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details
$ cd front && ng serve
/bin/bash: line 62: ng: command not found
ERROR: Job failed: exit code 1

What is my misconception about this?

I believe you need to install angular-cli globally. Have you tried npm i -g @angular/cli?