0

I am trying the new docker kit to build an image since we need 2 different set of variables my docker file looks like:

FROM python:3.7 as base
RUN apt-get update -y

FROM base as basic_build
WORKDIR /app
COPY ./path/to/requirements.txt requirements.txt
RUN pip install -r requirements.txt
ENV DEPLOY_TYPE=local
RUN ls -lrth

FROM basic_build as testing_build
# for testing
ENV A_VARIBLE_TEST=some_string
COPY ./some/files/ /app/
EXPOSE 5000
CMD ["python", "-m", "flask", "run"]


FROM basic_build as normal_build
ENV my_docker_test_var=see_if_prints_in_log
EXPOSE 5000
CMD ["python", "-m", "flask", "run"]

in Jenkins is been call as:

sh "DOCKER_BUILDKIT=1 docker build --file ${docker_file_path} --target testing_build --no-cache ${WORKSPACE}"

but log doesn't show the lines of ENV been set

we can see RUNs the pip install, COPYs but not ENVs:

#28 [basic_build 22/24] RUN ls -lrth
#28 sha256
#28 0.351 total 20K
#28 0.351 -rw-r--r--. 1 root root 5.0K Jul 14 16:04 file1.py
#28 0.351 -rw-r--r--. 1 root root   30 Jul 14 16:04 file2.py
...
#28 DONE 0.4s

#29 [basic_build 23/24] RUN mkdir /app/temp
#29 sha256:e1edb01f6c54b011bed2a1695a982985f6a418668509602436e17c0528dc17ba
#29 DONE 0.4s

#31 [testing_build 1/5] COPY ./some/path/ /app/
# sha256

but not when I set the ENV... if I run with --progress=plain I still don't see ENVs... been assign as if i do the old normal docker build (with no buildkit)

--progress=plain

such:

sh "DOCKER_BUILDKIT=1 docker build --file ${docker_file_path} --target testing_build --no-cache ${WORKSPACE} --progress=plain"

I am missing something? or the ENV don't show anymore? or are they not been set? was expecting to see in one line something like:

Step 28/75 : DEPLOY_TYPE=local
 ---> Running in #####28a62
pelos
  • 1,744
  • 4
  • 24
  • 34
  • If you `docker run --rm your-image env`, does it include that environment variable? – David Maze Jul 14 '21 at 16:30
  • yes, is i do docker run, and in the CLI i do env yes they show up. so how is like they are not been display in the log while they are been set? – pelos Jul 14 '21 at 16:47
  • i don't ever see ENVs been print either with --progress=plain or with out, wonder why is that? with buildkit with the old default docker they do show up – pelos Jul 14 '21 at 17:06

0 Answers0