<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Riverfunt</title>
    <description>The latest articles on DEV Community by Riverfunt (@riverfount).</description>
    <link>https://dev.to/riverfount</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F36482%2Ff1f0bb8f-3b75-4551-90bc-fd3d71b17980.png</url>
      <title>DEV Community: Riverfunt</title>
      <link>https://dev.to/riverfount</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/riverfount"/>
    <language>en</language>
    <item>
      <title>Muito além do que 4 PRs</title>
      <dc:creator>Riverfunt</dc:creator>
      <pubDate>Thu, 19 Oct 2023 14:15:20 +0000</pubDate>
      <link>https://dev.to/riverfount/muito-alem-do-que-4-prs-4i3a</link>
      <guid>https://dev.to/riverfount/muito-alem-do-que-4-prs-4i3a</guid>
      <description>&lt;p&gt;Poder ter o privilégio de contribuir em projetos de código aberto é algo inenarrável. Ter projetos, mesmo que pessoais e de aprendizado, é também uma algo que não se pode traduzir em palavras. É algo que quero, em poucas palavras, tentar exprimir aqui&lt;/p&gt;

&lt;p&gt;Para mim uma das melhoras coisas que compreendo ter sido realizada durante a Hacktoberfest foi o contato com os/as desenvolvedore/as, pois mais que contribuir e enviar PRs para os repositórios participantes é o contato com a galera, a troca de ideias e conhecimentos. Por isso, não tenho dúvidas em dizer que a experiência proporcionada vai muito além do que 4 PRs e os prêmios que alcaçamos por tais contribuições, pois está no âmbito da construção contínua de uma rede de relacioinamentos e amizades sem iguais.&lt;/p&gt;

&lt;p&gt;Uma experiência que nos auxilia no crescimento das habilidades técnicas e, também, nas chamadas soft skills, pois, como já mecionei acima, vai além de termos novos conhecimentos na linguagem de programação que utilizamos, vai além da compreensão da arquitetura de software que temos. Vai além, pois a rede de relacionaments que eu tinha antes de ter me envolvido na Hacktoberfest transoformou-se de uma forma que eu não imaginava que poderia. Crescimento profissional? Sim, mas principalmente crescimento pessoal, entendendo que contribuir com algo que possa fazer com que outras pessoas tenham suas vidas melhoradas ao utilizar um ou outro projeto de código aberto não tem palavras que descreva!&lt;/p&gt;

&lt;p&gt;O link dos 4 PRs que enviei:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://github.com/Riverfount/todo-project/pull/62" rel="noopener noreferrer"&gt;https://github.com/Riverfount/todo-project/pull/62&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Riverfount/vmcotacoes/pull/181" rel="noopener noreferrer"&gt;https://github.com/Riverfount/vmcotacoes/pull/181&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Riverfount/vmcotacoes/pull/184" rel="noopener noreferrer"&gt;https://github.com/Riverfount/vmcotacoes/pull/184&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Riverfount/vmcotacoes/pull/186" rel="noopener noreferrer"&gt;https://github.com/Riverfount/vmcotacoes/pull/186&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>hack23contributor</category>
      <category>hacktoberfest23</category>
      <category>hacktoberfest</category>
    </item>
    <item>
      <title>Minha experiência na Hacktoberfest</title>
      <dc:creator>Riverfunt</dc:creator>
      <pubDate>Thu, 19 Oct 2023 13:23:22 +0000</pubDate>
      <link>https://dev.to/riverfount/minha-experiencia-na-hacktoberfest-4m8m</link>
      <guid>https://dev.to/riverfount/minha-experiencia-na-hacktoberfest-4m8m</guid>
      <description>&lt;p&gt;É extremamente gratificante participar de uma programa como a Hacktoberfest. Poder contribuir com projetos de código aberto é uma experiência fora do comum. Aprender com os mantenedores e os demais desenvolvedores que estão vinculados ao projeto não tem igual.&lt;/p&gt;

&lt;p&gt;Além do fato de eu também manter pequenos projetos pessoais e de código aberto que me permitem, também, aprender sobre o processo de desenovlvimento, bem como de ter contato com outros desenvolvedores que contribuem com sua expertise para que os projetos sejam sempre melhorados a ponto de serem algo muito além do que fora planejado no início.&lt;/p&gt;

&lt;p&gt;Contribuir para projetos de código aberto vai muito além da programação, e não falo de poder contribuir com outras partes importantes do projeto, como documentação etc, mas sim do fato de ser uma forma saudável e muito bacanda de fazer amigos e amigas e construir uma rede de relacionamentos que vai, como já disse, muito além da programação.&lt;/p&gt;

</description>
      <category>hacktoberfest23</category>
      <category>hacktoberfest</category>
      <category>python</category>
    </item>
    <item>
      <title>Hacktoberfest completed</title>
      <dc:creator>Riverfunt</dc:creator>
      <pubDate>Wed, 18 Oct 2023 10:44:18 +0000</pubDate>
      <link>https://dev.to/riverfount/hacktoberfest-completed-2645</link>
      <guid>https://dev.to/riverfount/hacktoberfest-completed-2645</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi2xyz1l0f9yn04ergven.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi2xyz1l0f9yn04ergven.png" alt="Image description" width="800" height="477"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>hacktoberfest23</category>
      <category>hacktoberfest</category>
    </item>
    <item>
      <title>Access the PostgreSQL in Docker Container</title>
      <dc:creator>Riverfunt</dc:creator>
      <pubDate>Sun, 03 Nov 2019 21:16:17 +0000</pubDate>
      <link>https://dev.to/riverfount/acess-the-postgresql-in-docker-container-1n9l</link>
      <guid>https://dev.to/riverfount/acess-the-postgresql-in-docker-container-1n9l</guid>
      <description>&lt;p&gt;The use of Docker containers made our lives so easy. Not only the work of the sysadmin but work of the developer too.&lt;/p&gt;

&lt;p&gt;However, these days I had to access the PostgreSQL that runs in a Docker container and had a bit of trouble, by inexperience and lack of knowledge until then.&lt;/p&gt;

&lt;p&gt;Well, all is hard when we don't have the knowledge to do it. And to access the PostgreSQL in a Docker container is a piece of cake.&lt;/p&gt;

&lt;p&gt;Firstly, we need to check if the container is up! We can do it with the following command line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker container ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The answer to this command is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES

56fa1b0f91d7        ba5ab22916de        &lt;span class="s2"&gt;"docker-entrypoint.s…"&lt;/span&gt;   24 hours ago        Up 5 minutes        0.0.0.0:5442-&amp;gt;5432/tcp   my_database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the container running, as shown above, it is enough to run the following command line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; my_database bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where &lt;code&gt;my_database&lt;/code&gt;, in this case, is the Docker container NAME. We cuold use the container ID instead of the container NAME. In this context, we enter the container as the root user and now we can run the following command line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;psql &lt;span class="nt"&gt;-U&lt;/span&gt; postgres
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ready! We are in PostgreSQL and we can create users, databases, tables and all we need to do our work. This fact is demonstrated by the change of the prompt to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;postgres&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="c"&gt;#&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope this small tip helps another person the same way it helped me as well.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>postgres</category>
    </item>
    <item>
      <title>Dockerize a Flask App</title>
      <dc:creator>Riverfunt</dc:creator>
      <pubDate>Fri, 11 Oct 2019 22:54:49 +0000</pubDate>
      <link>https://dev.to/riverfount/dockerize-a-flask-app-17ag</link>
      <guid>https://dev.to/riverfount/dockerize-a-flask-app-17ag</guid>
      <description>&lt;p&gt;&lt;a href="http://www.vicentemarcal.com/wp-content/uploads/2019/03/flask-docker.png" rel="noopener noreferrer"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YbP0L4nK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/http://www.vicentemarcal.com/wp-content/uploads/2019/03/flask-docker.png" alt="Logomarcas Flask e Docker" width="700" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Last week I was challenged to start a simple "Hello World" Flask application, but it needed to run into Docker container. In this article, I will show you how was my approach to solve this challenge!&lt;/p&gt;

&lt;h1&gt;The Flask Architecture and Dependencies&lt;/h1&gt;

&lt;p&gt;Even though a simple "Hello World" I worked with the best practices of architecture to it. I had the following directory structure:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;.
├── backend
│   ├── app.py
│   ├── blueprints
│   │   ├── core
│   │   │   ├── bp.py
│   │   │   ├── __init__.py
│   │   │   ├── routes.py
│   │   │   └── tests
│   │   │       └── test_bp_core.py
│   │   └── __init__.py
│   └── __init__.py
├── conftest.py
├── Dockerfile
├── .dockerignore
├── .gitignore
├── Pipfile
├── Pipfile.lock
├── pytest.ini
└── README.md
&lt;/code&gt;&lt;/pre&gt;
The &lt;code&gt;.&lt;/code&gt; (dot) is the root of project. In the &lt;code&gt;backend&lt;/code&gt; I have Flask application properly. I used the factory pattern for the architecture. So, in the &lt;code&gt;app.py&lt;/code&gt; I have this:
&lt;pre&gt;&lt;code&gt;from flask import Flask


def create_app():
    app = Flask(__name__)
    app.config['SECRET_KEY'] = 'My_Top_Secert_Key'

    # Blueprint

    from backend.blueprints.core import bp as bp_core
    bp_core.config(app)

    return app
&lt;/code&gt;&lt;/pre&gt;
This code is responsible to create my Flask app. The focus of this article isn't to explain about Flask and so on. But, how to construct an app and run it into a Docker container.

In the &lt;code&gt;backend/bluprints/core&lt;/code&gt; I have my blueprint (see de &lt;a href="http://flask.pocoo.org/docs/1.0/blueprints/" rel="noopener noreferrer"&gt;documentation to know more about blueprints&lt;/a&gt;), the code is in bp.py and route.py, both configure my &lt;strong&gt;core blueprint&lt;/strong&gt;. The first have this code:
&lt;pre&gt;&lt;code&gt;from flask import Blueprint


bp = Blueprint('core', __name__)


def config(app):
    from backend.blueprints.core import routes # noqa
    app.register_blueprint(bp)
&lt;/code&gt;&lt;/pre&gt;
And the second has this code:
&lt;pre&gt;&lt;code&gt;from backend.blueprints.core.bp import bp


@bp.route('/')
def home():
    return "Hello World"
&lt;/code&gt;&lt;/pre&gt;
In the &lt;code&gt;backend/blueprint/core/tests&lt;/code&gt; I have my tests of this blueprint. It's a simple test, and its code is:
&lt;pre&gt;import pytest

from flask import url_for


@pytest.fixture
def resp(client):
    return client.get(url_for('core.home'))


def test_bp_home_status_code_ok(resp):
    assert resp.status_code == 200

&lt;/pre&gt;

&lt;p&gt;Again, the focus of this article isn't to explain detailed of the Flask application, so if you have questions about how to test Flask apps please see &lt;a href="http://flask.pocoo.org/docs/1.0/testing/" rel="noopener noreferrer"&gt;the documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Back to the root of the application, I have some files that are interesting to see!&lt;/p&gt;

&lt;p&gt;One is the &lt;code&gt;conftest.py&lt;/code&gt;. This file is responsible for set up &lt;code&gt;pytest&lt;/code&gt; to run all tests in the application. Its code is:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;import pytest

from backend.app import create_app


@pytest.fixture
def app():
    app = create_app()
    return app


@pytest.fixture
def client(app):
    with app.test_client() as c:
        yield c
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Other is the &lt;code&gt;pytest.ini&lt;/code&gt; a simple file that inform to &lt;code&gt;pytest&lt;/code&gt; the pattern of the files tests names, in our case the &lt;code&gt;pytest.ini&lt;/code&gt; code is:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[pytest]
python_files=test*.py *tests.py
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Two other files are &lt;code&gt;Pipfile&lt;/code&gt; and &lt;code&gt;Pipfile.lock&lt;/code&gt;. These files are created or updated by the command &lt;code&gt;pipenv install [package]&lt;/code&gt;. As we are going to see later, the most important in our case is the &lt;code&gt;Pipfile.lock&lt;/code&gt; because it locks the versions of all dependencies and allows a deterministic installation of these dependencies in our environment.&lt;/p&gt;

&lt;p&gt;And we have &lt;code&gt;Dockerfile&lt;/code&gt;, too. This file is responsible for the Docker Image creation. This Image will be used to up the container with the Flask Application. Its code is:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;FROM python:3.7.1

LABEL Author="Vicente Marçal"
LABEL E-mail="vicente.marcal@gmail.com"
LABEL version="0.0.1b"

ENV PYTHONDONTWRITEBYTECODE 1
ENV FLASK_APP "backend/app.py"
ENV FLASK_ENV "development"
ENV FLASK_DEBUG True

RUN mkdir /app
WORKDIR /app

COPY Pip* /app/

RUN pip install --upgrade pip &amp;amp;&amp;amp; \
    pip install pipenv &amp;amp;&amp;amp; \
    pipenv install --dev --system --deploy --ignore-pipfile

ADD . /app

EXPOSE 5000

CMD flask run --host=0.0.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;A brief explanaton about it:&lt;/p&gt;

&lt;dl&gt;
    &lt;dt&gt;
&lt;pre&gt;&lt;code&gt;FROM python:3.7.1&lt;/code&gt;&lt;/pre&gt;
&lt;/dt&gt;
    &lt;dd&gt;The &lt;code&gt;FROM&lt;/code&gt; define the base image that will be used to create my image. In this case, I use the base image of &lt;code&gt;pyton:3.7.1&lt;/code&gt;.&lt;/dd&gt;
    &lt;dt&gt;
&lt;pre&gt;&lt;code&gt;LABEL Author="Vicente Marçal"&lt;/code&gt;&lt;/pre&gt;
&lt;/dt&gt;
    &lt;dd&gt;The &lt;code&gt;LABEL&lt;/code&gt;'s are the way to put some information like the author's name, e-mail to contact and the version of the Dockerfile&lt;/dd&gt;
    &lt;dt&gt;
&lt;pre&gt;&lt;code&gt;RUN mkdir /app&lt;/code&gt;&lt;/pre&gt;
&lt;/dt&gt;
    &lt;dd&gt;The &lt;code&gt;RUN&lt;/code&gt; is responsible to execute commands, in this case the &lt;code&gt;mkdir /app&lt;/code&gt; that create a direcotyr called app into the root.&lt;/dd&gt;
    &lt;dt&gt;
&lt;pre&gt;&lt;code&gt;WORKDIR /app&lt;/code&gt;&lt;/pre&gt;
&lt;/dt&gt;
    &lt;dd&gt;The &lt;code&gt;WORKDIR&lt;/code&gt; defines the work directory, in this case my &lt;code&gt;/app&lt;/code&gt; created previosly in the &lt;code&gt;RUN&lt;/code&gt; clause.&lt;/dd&gt;
    &lt;dt&gt;
&lt;pre&gt;&lt;code&gt;COPY Pip* /app/&lt;/code&gt;&lt;/pre&gt;
&lt;/dt&gt;
    &lt;dd&gt;The &lt;code&gt;COPY&lt;/code&gt; is resposible to copy files from the host to the container, in this case with the &lt;code&gt;*&lt;/code&gt; inform to Docker to copy all files start whit &lt;code&gt;Pip&lt;/code&gt; to &lt;code&gt;/app/&lt;/code&gt;. Pay attention: it is very important to finalize the path of the director with &lt;code&gt;/&lt;/code&gt;
&lt;/dd&gt;
    &lt;dt&gt;
&lt;pre&gt;&lt;code&gt;RUN pip install --upgrade pip &amp;amp;&amp;amp; \
    pip install pipenv &amp;amp;&amp;amp; \
    pipenv install --dev --system --deploy --ignore-pipfile&lt;/code&gt;&lt;/pre&gt;
&lt;/dt&gt;
    &lt;dd&gt;This &lt;code&gt;RUN&lt;/code&gt; clause does the upgrade of &lt;code&gt;pip&lt;/code&gt;, install &lt;code&gt;pipenv&lt;/code&gt; and install the Flask App dependencies. To intall Flask dependencies was used &lt;code&gt;pipenv install&lt;/code&gt; with some flags:&lt;/dd&gt;
&lt;/dl&gt;

&lt;dl&gt;
    &lt;dt&gt;&lt;code&gt;--dev&lt;/code&gt;&lt;/dt&gt;
    &lt;dd&gt;that indicates to install development dependencies, too;&lt;/dd&gt;
    &lt;dt&gt;&lt;code&gt;--system&lt;/code&gt;&lt;/dt&gt;
    &lt;dd&gt;this is very important because in a Docker container we have an isolated environment yet and it is not necessary create a virtualenv, this flag informs &lt;code&gt;pipenv&lt;/code&gt; exactly this;&lt;/dd&gt;
    &lt;dt&gt;
&lt;code&gt;--deploy&lt;/code&gt; with &lt;code&gt;--ignore-pipfile&lt;/code&gt;
&lt;/dt&gt;
    &lt;dd&gt;inform &lt;code&gt;pipenv&lt;/code&gt; to use the &lt;code&gt;Pipfile.lock&lt;/code&gt; to install all dependencies. In the &lt;code&gt;Pipfile.lock&lt;/code&gt; we have all dependencies with your versions locked&lt;/dd&gt;
&lt;/dl&gt;

&lt;dl&gt;
    &lt;dt&gt;
&lt;pre&gt;&lt;code&gt;ADD . /app&lt;/code&gt;&lt;/pre&gt;
&lt;/dt&gt;
    &lt;dd&gt;After installation of all dependencies with clause &lt;code&gt;ADD&lt;/code&gt; added all files of the same directory where is Dockerfile on host to &lt;code&gt;/app&lt;/code&gt; on the container.&lt;/dd&gt;
&lt;/dl&gt;

&lt;dl&gt;
    &lt;dt&gt;Obs:&lt;/dt&gt;
    &lt;dd&gt;In the same directory there is a file called &lt;code&gt;.dockerignore&lt;/code&gt; that like the &lt;code&gt;.gitignore&lt;/code&gt; inform Docker to ignore the files and directories in its content.&lt;/dd&gt;
&lt;/dl&gt;

&lt;dl&gt;
    &lt;dt&gt;
&lt;pre&gt;&lt;code&gt;EXPOSE 5000&lt;/code&gt;&lt;/pre&gt;
&lt;/dt&gt;
    &lt;dd&gt;This clause exposes the port 5000 of the container to the external world.&lt;/dd&gt;
    &lt;dt&gt;
&lt;pre&gt;&lt;code&gt;CMD flask run --host=0.0.0.0&lt;/code&gt;&lt;/pre&gt;
&lt;/dt&gt;
    &lt;dd&gt;Finally, the clause &lt;code&gt;CMD&lt;/code&gt; execute the commands after build and up the container. In this case, the command is a &lt;code&gt;flask run --host=0.0.0.0&lt;/code&gt; that execute the Flask server in the host 0.0.0.0 and servers our Flask application.&lt;/dd&gt;
&lt;/dl&gt;

&lt;dl&gt;
    &lt;dt&gt;Obs:&lt;/dt&gt;
    &lt;dd&gt;Obviously, this is a small test. If you need to use this in production it is recommended to run a WSGI server like a uWSGI or gunicorn instead the Flask Server that is used only in development environment.&lt;/dd&gt;
&lt;/dl&gt;

&lt;p&gt;Some words about the use of &lt;code&gt;COPY&lt;/code&gt; and &lt;code&gt;ADD&lt;/code&gt;:&lt;/p&gt;

&lt;blockquote&gt;Although ADD and COPY are functionally similar, generally speaking, COPY is preferred. That’s because it’s more transparent than ADD. COPY only supports the basic copying of local files into the container, while ADD has some features (like local-only tar extraction and remote URL support) that are not immediately obvious. Consequently, the best use for ADD is local tar file auto-extraction into the image, as in ADD rootfs.tar.xz /.&lt;/blockquote&gt;

&lt;p&gt;Ref.: &lt;a href="https://docs.docker.com/develop/develop-images/dockerfile_best-practices/" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://docs.docker.com/develop/develop-images/dockerfile_best-practices/" rel="noopener noreferrer"&gt;https://docs.docker.com/develop/develop-images/dockerfile_best-practices/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all we need to Dockerize our Flask App. Now we need to build and run our Docker image.&lt;/p&gt;

&lt;p&gt;To build we use this Docker CLI command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;docker build -t vm_docker_flask .
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The command &lt;code&gt;docker build&lt;/code&gt; will build our image, with the flag &lt;code&gt;-t&lt;/code&gt; it put the tag &lt;strong&gt;vm_docker_flask&lt;/strong&gt; in our image and, finally, the last part of the CLI is &lt;code&gt;.&lt;/code&gt; (dot) that inform to Docker that the Dockerfile is in the current directory.&lt;/p&gt;

&lt;p&gt;This command shows us this result in our terminal:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Sending build context to Docker daemon  29.18kB
Step 1/15 : FROM python:3.7.1
 ---&amp;gt; 1e80caffd59e
Step 2/15 : LABEL Author="Vicente Marçal"
 ---&amp;gt; Running in a7975e93672a
Removing intermediate container a7975e93672a
 ---&amp;gt; 448662ef63d8
Step 3/15 : LABEL E-mail="vicente.marcal@gmail.com"
 ---&amp;gt; Running in 75f6319066de
Removing intermediate container 75f6319066de
 ---&amp;gt; 0898192a03f7
Step 4/15 : LABEL version="0.0.1b"
 ---&amp;gt; Running in defb5aee2083
Removing intermediate container defb5aee2083
 ---&amp;gt; 02042247ded0
Step 5/15 : ENV PYTHONDONTWRITEBYTECODE 1
 ---&amp;gt; Running in 5e9124dfa05c
Removing intermediate container 5e9124dfa05c
 ---&amp;gt; c35cd3ecc42f
Step 6/15 : ENV FLASK_APP "backend/app.py"
 ---&amp;gt; Running in ea58e08644ad
Removing intermediate container ea58e08644ad
 ---&amp;gt; f2fb780d29fc
Step 7/15 : ENV FLASK_ENV "development"
 ---&amp;gt; Running in f72976410ba2
Removing intermediate container f72976410ba2
 ---&amp;gt; bb444664e3b0
Step 8/15 : ENV FLASK_DEBUG True
 ---&amp;gt; Running in e18257443538
Removing intermediate container e18257443538
 ---&amp;gt; a2bbca32f540
Step 9/15 : RUN mkdir /app
 ---&amp;gt; Running in ebbcc284fe40
Removing intermediate container ebbcc284fe40
 ---&amp;gt; 7fb8c7fac9f8
Step 10/15 : WORKDIR /app
 ---&amp;gt; Running in c76604d10578
Removing intermediate container c76604d10578
 ---&amp;gt; 074aa15fee4c
Step 11/15 : COPY Pip* /app/
 ---&amp;gt; 554f403d7b11
Step 12/15 : RUN pip install --upgrade pip &amp;amp;&amp;amp; pip install pipenv &amp;amp;&amp;amp; pipenv install --dev --system --deploy --ignore-pipfile
 ---&amp;gt; Running in 08faec42b7d5
Collecting pip
  Downloading https://files.pythonhosted.org/packages/d8/f3/413bab4ff08e1fc4828dfc59996d721917df8e8583ea85385d51125dceff/pip-19.0.3-py2.py3-none-any.whl (1.4MB)
Installing collected packages: pip
  Found existing installation: pip 18.1
    Uninstalling pip-18.1:
      Successfully uninstalled pip-18.1
Successfully installed pip-19.0.3
Collecting pipenv
  Downloading https://files.pythonhosted.org/packages/13/b4/3ffa55f77161cff9a5220f162670f7c5eb00df52e00939e203f601b0f579/pipenv-2018.11.26-py3-none-any.whl (5.2MB)
Requirement already satisfied: pip&amp;gt;=9.0.1 in /usr/local/lib/python3.7/site-packages (from pipenv) (19.0.3)
Collecting virtualenv-clone&amp;gt;=0.2.5 (from pipenv)
  Downloading https://files.pythonhosted.org/packages/e3/d9/d9c56deb483c4d3289a00b12046e41428be64e8236fa210111a1f57cc42d/virtualenv_clone-0.5.1-py2.py3-none-any.whl
Collecting virtualenv (from pipenv)
  Downloading https://files.pythonhosted.org/packages/33/5d/314c760d4204f64e4a968275182b7751bd5c3249094757b39ba987dcfb5a/virtualenv-16.4.3-py2.py3-none-any.whl (2.0MB)
Collecting certifi (from pipenv)
  Downloading https://files.pythonhosted.org/packages/9f/e0/accfc1b56b57e9750eba272e24c4dddeac86852c2bebd1236674d7887e8a/certifi-2018.11.29-py2.py3-none-any.whl (154kB)
Requirement already satisfied: setuptools&amp;gt;=36.2.1 in /usr/local/lib/python3.7/site-packages (from pipenv) (40.6.2)
Installing collected packages: virtualenv-clone, virtualenv, certifi, pipenv
Successfully installed certifi-2018.11.29 pipenv-2018.11.26 virtualenv-16.4.3 virtualenv-clone-0.5.1
Installing dependencies from Pipfile.lock (9a5a3a)…
Removing intermediate container 08faec42b7d5
 ---&amp;gt; 740ed1329305
Step 13/15 : ADD . /app
 ---&amp;gt; 3551608282e2
Step 14/15 : EXPOSE 5000
 ---&amp;gt; Running in 07b57fe6a5e7
Removing intermediate container 07b57fe6a5e7
 ---&amp;gt; 2e07658bbae8
Step 15/15 : CMD flask run --host=0.0.0.0
 ---&amp;gt; Running in bdf7404770f6
Removing intermediate container bdf7404770f6
 ---&amp;gt; cf7d3ee68072
Successfully built cf7d3ee68072
Successfully tagged vm_docker_flask:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;After that, we need to run our container. The follow Docker CLI command makes the magic:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt; docker run -d --name my_container_flask -p 5000:5000 vm_docker_flask
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The command &lt;code&gt;docker run&lt;/code&gt; runs our container, the flag &lt;code&gt;-d&lt;/code&gt; inform to Docker that is running in background, the flag &lt;code&gt;--name&lt;/code&gt; put the &lt;strong&gt;my_container_flask&lt;/strong&gt; to our container, the flag &lt;code&gt;-p&lt;/code&gt; bind the port 5000 of container to port 5000 of host and, at the end, is the name of our image built in the &lt;code&gt;docker build&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;This command shows us this result in our terminal (or similar, because this command returns the container id):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;33169f573b7bdf078ef8d55741ec037f2914aa78343ad96c8277854c3bcdf6b2
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now we can do our first test, see if our container is running, for that we execute Docker CLI command like that:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;pythonprojects/docker_flask_app [ docker container ps        ] 
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
880a5b59f2aa        vm_docker_flask     "/bin/sh -c 'flask r…"   15 minutes ago      Up 15 minutes       0.0.0.0:5000-&amp;gt;5000/tcp   my_container_flask
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This Docker CLI command shows us if our which containers are running and their info like Container ID, Image, Command and so on. In our case only &lt;strong&gt;my_container_flask&lt;/strong&gt; how you can see above.&lt;/p&gt;

&lt;p&gt;Another test that we can do is a simple HTTP request. I use &lt;a href="https://httpie.org/" rel="noopener noreferrer"&gt;httpie application&lt;/a&gt; in this test. See the terminal result:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;pythonprojects/docker_flask_app [ http 0.0.0.0:5000         ]
HTTP/1.0 200 OK
Content-Length: 11
Content-Type: text/html; charset=utf-8
Date: Tue, 05 Mar 2019 18:17:24 GMT
Server: Werkzeug/0.14.1 Python/3.7.1

Hello World
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now the most important test. We execute the pytest into our container to run tests against our Flask application. The test is just simple only assert if the status code returned by the Flask App is 200 Ok!&lt;/p&gt;

&lt;p&gt;To do it we execute the follow Docker CLI command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt; docker exec my_container_flask pytest 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This docker CLI command runs pytest against my_container_flask and if all it is ok we have this terminal result:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;=========================== test session starts ============================
platform linux -- Python 3.7.1, pytest-4.3.0, py-1.8.0, pluggy-0.9.0
rootdir: /app, inifile: pytest.ini
plugins: sugar-0.9.2, flask-0.14.0
collected 1 item

backend/blueprints/core/tests/test_bp_core.py .                      [100%]

========================= 1 passed in 0.06 seconds =========================
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;That's all folks!!&lt;/h2&gt;

</description>
      <category>docker</category>
      <category>flask</category>
      <category>python</category>
    </item>
  </channel>
</rss>
