title: How to test dockerized flask app using Pytest?
body: <p>I've built the flask app that designed to run inside docker container. It will
  accept POST HTTP Methods and return appropriate JSON response if the header key matched with the key that I put inside <a href="https://docs.docker.com/compose/environment-variables/" rel="nofollow noreferrer">docker-compose <code>environment</code></a>.</p>
  
  <pre><code>...
      environment:
        - SECRET_KEY=fakekey123
  ...
  </code></pre>
  
  <p>The problem is: when it comes to testing. The <code>app</code> or the <code>client</code> fixture of
  flask (pytest) of course can't find the docker-compose <code>environment</code>. Cause the app didn't start from docker-compose but from pytest.</p>
  
  <pre class="lang-py prettyprint-override"><code>secret_key = os.environ.get("SECRET_KEY") 
  # ^^ the key loaded to OS env by docker-compose
  post_key = headers.get("X-Secret-Key")
  ...
  
  if post_key == secret_key:
      RETURN APPROPRIATE RESPONSE
         .....
  </code></pre>
  
  <p>What is the (best/recommended) approach to this problem?</p>
  
  <p>I find some plugins
  <a href="https://github.com/pytest-docker-compose/pytest-docker-compose" rel="nofollow noreferrer">one</a>,
  <a href="https://github.com/AndreLouisCaron/pytest-docker" rel="nofollow noreferrer">two</a>,
  <a href="https://github.com/lovelysystems/lovely-pytest-docker" rel="nofollow noreferrer">three</a> to do this. But I asked here if there is any more "simple"/"common" approach. Cause I also want to automate this test using CI/CD tools.</p>