I have a docker container running and I want to execute command make target-branch branch="branch_name"
so that inside container I have TARGET
environment variable set to "branch_name"
.
I tried writing the following in Makefile
target-branch:
@ export TARGET=$(branch)
It didn't work, after going inside container and executing printenv
there is no such environment variable.
Also tried exporting it using bash script
--- Makefile ---
target-branch:
@ sh scripts/set_target_branch.sh $(branch)
--- scripts/set_target_branch.sh ---
#!/bin/bash
export TARGET="$1"
echo $TARGET
After make target-branch branch="branch_name"
, echo
inside script outputs "branch_name"
, but the TARGET
variable still absents inside the container upon printenv
.
Just in case, my Dockerfile, docker-compose.yml,