https://prefect.io logo
f

Florian Kühnlenz

01/20/2022, 4:40 PM
Hi, I have a question about DockerStorage I did not manage to figure out on my own. I would like to pass a variable to the docker build so that it is replaced inside the docker file. It seems the env_vars in the DockerStore are not the right place. Any hints on how to do this?
k

Kevin Kho

01/20/2022, 4:41 PM
Why is env_vars not the right place? What happens when you set it there?
What do you think of extra_dockerfile_commands?
f

Florian Kühnlenz

01/20/2022, 4:45 PM
I tried to set the variable there but then I does not seem to get replaced in the Dockerfile. How would the extra solution work?
k

Kevin Kho

01/20/2022, 5:00 PM
The code example here shows what it would look like. Maybe just use the Docker
ENV
command to set it?
f

Florian Kühnlenz

01/20/2022, 5:03 PM
But this would run after my dockerfile so it would help me set the vars for running it
I am looking for something to do the same as --build-arg VAR_NAME=6 basically
Okay I found the way to do it. I needed to add the the variable explicitly via ARG in the docker file and then pass it via
storage = Docker(dockerfile=str(project_path/"Dockerfile"), prefect_directory="/tmp/prefect", build_kwargs={"buildargs":{"PROJECT_PATH":"projects/path/"}})
k

Kevin Kho

01/20/2022, 6:58 PM
Oof sorry I forgot to respond. Thanks for circling back though!
5 Views