GITLAB CI creates container for every stage

I believe it was answered a bazillion times, just can’t find anything relevant.
Have this very simple ci configuration:

image: someregistry/image:latest
stages:

  • build
  • deploy-prod
  • deploy-dev

build:
stage:
build
script:
- git fetch
- git status
- npm install
- npm run build
only:
- master
- dev

deploy-dev:
stage:
deploy-prod
script:
- scp -r public prodserver:public_html/
only:
- master
deploy-dev:
stage:
deploy-dev
script:
- scp -r public devserver:public_html/
only:
- dev

and what I see is that gitlab builds the build stage ok,
but for the DEPLOY stages it creates the new container, and of course in the new container there will be no ‘public’ directory.
how to eliminate the problem?
thanks