<p>I have a application running react as front end and node as back end code. In react public folder, we have a meta.json which has the version number, every time we run npm run build, it will update version number in that file. we are using this method to make sure the website always displays the new release version, in the database also we update the version number and if both doesn't match website automatically loads new version.</p>
<p>We are on the process of shifting to Kubernetes and the problem now I have is we have a Dockerfile for react in which we have following steps</p>
<pre><code>FROM node:12.18.3 AS build

ENV CI=false
ENV WDS_SOCKET_PORT=0

WORKDIR /app

COPY [&quot;package.json&quot;, &quot;package-lock.json&quot;, &quot;./&quot;]

RUN npm install --production

COPY . .

RUN npm run build:development

FROM nginx:alpine

COPY --from=build /app/build /usr/share/nginx/html

COPY --from=build /app/nginx-custom.conf /etc/nginx/conf.d/default.conf
</code></pre>
<p>We are using this Dockerfile in azure pipelines and building a image with it and pushing that docker image to Azure container registry and using kubectl restart to pull that image and restart the deployment in AKS. After npm run build from the Dockerfile, my meta.json file will have updated version, I want to commit and push that changed files to azure repo, so that next time if pipeline is run it will have updated version number.</p>
<p>I have done my POC on this item but not able to find any easy to follow steps,
I have come across this repo <a href="https://github.com/ShadowApex/docker-git-push" rel="nofollow noreferrer">https://github.com/ShadowApex/docker-git-push</a> but not clear on how to execute this one properly, any help would be greatly appreciated.</p>

<p>Instead of adding the <strong>Git</strong> into the <strong>Docker</strong>, it will add extra layers to the docker image.</p>
<p>Once your image build is <strong>completed</strong> after that what you can do is something like copy the <strong>JSON</strong> outside of the docker image and push it from the <strong>CI</strong> machine to git or bucket where you want to manage.</p>
<p>command you can use the</p>
<pre><code>docker create --name container_name 
</code></pre>
<p><code>Docker create</code> will <strong>create</strong> the <strong>new</strong> container without running it.</p>
<p>The docker container create (or shorthand: docker create) command creates a new container from the specified image, without starting it.</p>
<blockquote>
<p>When creating a container, the docker daemon creates a writeable
container layer over the specified image and prepares it for running
the specified command. The container ID is then printed to STDOUT.
This is similar to docker run -d except the container is never started.</p>
</blockquote>
<p>So once container filesystem there run command to copy a file from docker to <strong>CI</strong> <strong>machine</strong> simple as that.</p>
<p><strong>Docker copy command</strong></p>
<pre><code>docker cp container_name:/app/build/meta.json .
</code></pre>
<p>Now you have a file on the CI machine you can upload it to Git now or Bucket anywhere.</p>
