Basic explanation how to handle multiple stages

I need some help to understand the concept of drone:

There is a monorepo (NX), which has multiple applications. After pushing some changes, the following is happening:

  1. Check which applications have changed. This is done by NX itself and returns a string list of each app: e.g. frontend-1, frontend-2, backend-1. Maybe this string is helpful later, so I write it to the affected.apps file.
  2. The affected apps are build. This is also done by NX itself. It creates the apps in the dist folder.
  3. Now I would like to dockerize all apps, which have been build in the step before.

This is how my .drone.yml file looks like. As you can see, there is only a single hardcoded docker stage, but I need to build multiple docker images. How can I pass any parameters to determine which application should be build and deployed?

kind: pipeline
type: docker
name: default

  - name: affected
    image: custom-alpine:latest
      - npm ci
      - npm run affected:apps > "affected.apps"

  - name: build
    image: custom-alpine:latest
      - npm run affected:build

  - name: docker
    image: plugins/docker
      username: user
      password: pa55word
      tags: latest
      dockerfile: ./tools/ci/dockerfiles/nextJS.Dockerfile
      context: ./dist/apps/frontend-1
      mtu: 1000