Hi
I am injecting build details into a docker image through the dockerfile build, with this code
FROM node:10.15.3
Build information passed in, this can be bound into the application if required
ARG BUILD_TAG
ARG BUILD_DATE
set working directory
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
add /usr/src/app/node_modules/.bin
to $PATH
ENV PATH /usr/src/app/node_modules/.bin:$PATH
install and cache app dependencies
COPY ./ /usr/src/app/
COPY package.json /usr/src/app/package.json
RUN echo “{ “buildDate”: “$BUILD_DATE” }” > /usr/src/app/src/build-date.json
RUN echo “{ “buildVersion”: “$BUILD_TAG” }” > /usr/src/app/src/build-version.json
RUN npm install --silent
RUN npm install react-scripts@1.1.1 -g --silent
RUN npm run build
start app
CMD [“npm”, “start”]
This works so that if I run
docker run -it imageName bash
I can see the files and verify the content. Starting the image using docker-compose also works and I can show the build details in and about box widget. All good so far.
If I rebuild the image using the same scripts. and check the files with docker run -it again they are correct, however, when I start the image with docker-compose and execute
docker exec -it containerName bash
and cat the files they are still the files from the original build. It is as though they are cached but I can’t see where. The docker build command is;
docker build --no-cache --build-arg BUILD_TAG=$localTag --build-arg BUILD_DATE="$localTimeStamp" -t $localImage .
I hope I have explained that, in summary docker run image seems to give the correct information, docker exec container shows an old file.
Any suggestions?
Thanks
Diane