<p>I've been working on a <code>Kubernetes</code> cluster with microservices written in <code>Flask</code> for some time now and I'm not sure if my current method for containerizing them is correct. </p>

<p>I've been using <a href="https://github.com/tiangolo/uwsgi-nginx-flask-docker" rel="nofollow noreferrer">this</a> image as a base.</p>

<p>But I've been seeing various posts saying that something like that may be a bit overkill.</p>

<p>The problem I have is that whenever I look up an article about using <code>Flask</code> with <code>Kubernetes</code>, they always skip over the details of the actual container and focus on building the cluster, which is something I already have a pretty solid handle on. I guess what I'm wondering is whether there's a better way to build a docker image for a single <code>Flask</code> app because it's hard to find a straight answer.</p>

<p>I got your point you are thinking you docker image creation method may be wrong. </p>

<p>The main idea while building docker image. The image should have only your dependencies. As you told to find an answer is hard because we don't know your requirement maybe your dockerfile is only way. </p>

<p>I recommend you to this document.
I read this document and really my docker images is improved. I think it will help you. </p>

<p><a href="https://drive.google.com/file/d/16t_-DRTohzyVPJy6Cx8a3PxLQ-95CfYK/view" rel="nofollow noreferrer">https://drive.google.com/file/d/16t_-DRTohzyVPJy6Cx8a3PxLQ-95CfYK/view</a></p>

<p>When I checked you dockerfile; I noticed only, I would like to share you;</p>

<p><a href="https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.7.dockerfile#L5" rel="nofollow noreferrer">https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.7.dockerfile#L5</a></p>

<p>Line 5th It should not be perform like that. The dockerfile should not be updated frequently and each dependency should be versioned.</p>

<p>I build this image like that.</p>

<p>I write all dependencies to req.txt with version.</p>

<p>req.txt</p>

<pre><code>flask==1.1.1
</code></pre>

<p>Dockerfile</p>

<pre><code>+ COPY req.txt .
+ RUN pip install -r req.txt
</code></pre>

<p>Also I would like to perform line between 5 and 28 in a bash script. </p>

<blockquote>
  <p>An Important Information; My manager don't want comment line in a Dockerfile. She wants to understand when she read it. She wants to simple and readable docker file. :) She is a wiser. You should keep simple your dockerfile and it should be understand whitout any comment lines. </p>
</blockquote>
