Setting up variables during build

so the objective is to have a different image for prod and testing so there are certain variables change accordingly so I need to set env variables during the build.

Current workflow:


ENV name1=$name1
ENV name2=$name2

Build command:
Docker build –build-arg name1=value build-arg name2=value –t test .

Run command
Docker run –d –p someport:someport test