How to build an docker image and execute commands after? (Build + Tests)

I want to build an docker image, that download dependencies, run some commands in it, and push the image if all tests passes. I’m trying to use the docker plugin, but I think it’s not working, because the build_args are not being passed to the container. The echo command prints "CAUTH AFTER -> ".

The COMPOSER_AUTH may not work as far as I’ve read, I don’t know if I can use the from_secret from there.

.drone.yml

steps:
- name: build_docker_image
  image: plugins/docker
  environment:
    COMPOSER_AUTH:
      from_secret: composer_auth
  settings:
    dry_run: true
    repo: myrepo/myimg
    tags:
    - ${DRONE_COMMIT:0:7}
    build_args:
      COMPOSER_AUTH: $COMPOSER_AUTH
      APP_STAGE: testing

Dockerfile:
ARG COMPOSER_AUTH

ENV COMPOSER_AUTH $COMPOSER_AUTH

ARG APP_STAGE

ENV APP_STAGE $APP_STAGE

RUN echo "CAUTH AFTER $COMPOSER_AUTH -> $APP_STAGE"