Skip to content

Commit

Permalink
include source code in p06 and p07
Browse files Browse the repository at this point in the history
  • Loading branch information
rimelek committed Feb 25, 2023
1 parent 10c94ba commit 0f79fcf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
26 changes: 18 additions & 8 deletions pages/projects/p06.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ Navigate to the nginxproxy folder
cd nginxproxy
The compose file is the following:

.. literalinclude:: ../../projects/p06/nginxproxy/docker-compose.yml
:language: yaml

Start the proxy:

.. code:: bash
Expand All @@ -60,17 +65,21 @@ Navigate to the web1 folder:
cd ../web1
At this point you need to have the NIP variable set as :doc:`../../index` refers to it.
Here you will have a compose file:

Alternative option: set the NIP variable in a ".env" file:
.. literalinclude:: ../../projects/p06/web1/docker-compose.yml
:language: yaml

At this point you need to have the NIP variable set as :doc:`../../index` refers to it.
Alternative option: set the NIP variable in a ".env" file.

Start the containers:

.. code:: bash
docker-compose up -d
In case are working in the cloned repository of this tutorial, you can also run the below command to set the variable
In case of working in the cloned repository of this tutorial, you can also run the below command to set the variable

.. code:: bash
Expand All @@ -82,17 +91,18 @@ Navigate to the web2 folder:
cd ../web2
The compose file is similar to the previous one:

.. literalinclude:: ../../projects/p06/web2/docker-compose.yml
:language: yaml

Start the containers:

.. code:: bash
docker compose up -d
In case are working in the cloned repository of this tutorial, you can also run the below command to set the variable

.. code:: bash
NIP=$(../../../system/usr/local/bin/nip.sh) docker compose up -d
Or you can use :code:`nip.sh` as we did in web1.

Both of the services are available on port 80. Example:

Expand Down
26 changes: 22 additions & 4 deletions pages/projects/p07.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,26 @@ Project structure:
├── nginxproxy
│   └── docker-compose.yml
└── web
├── .env
├── docker-compose.yml
└── www
└── index.html
The first step is the same as it was in :doc:`p06`.
The first step is the same as it was in :doc:`p06`. Let's go to :code:`nginxproxy`

.. code-block:: bash
cd nginxproxy
The compose file is:

.. literalinclude:: ../../projects/p07/nginxproxy/docker-compose.yml
:language: yaml

Start the proxy server:

.. code:: bash
cd nginxproxy
docker compose up -d
Go to the web folder:
Expand All @@ -34,13 +44,21 @@ Go to the web folder:
cd ../web
The compose file is

.. literalinclude:: ../../projects/p07/web/docker-compose.yml
:language: yaml

You can simply start a web server protected by HTTP authentication. The name and the password will come from environment variables.
I recommend you to use a more secure way in production. Create the .htpasswd file manually and mount it inside the container.

The htpasswd container will create .htpasswd automatically and exit.

In the ".env" file you can find two variables.
HTTPD_USER and HTTPD_PASS will be used in "docker-compose.yml"

.. literalinclude:: ../../projects/p07/web/.env

The variables will be used in "docker-compose.yml"
by the "htpasswd" service to generate the password file and then the "httpd" service will read it from the common volume.


Expand All @@ -50,7 +68,7 @@ Use the "depends_on" option to control which service starts first.

At this point you need to have the NIP variable set as the :doc:`../../index` refers to it.

Alternative option: set the NIP variable in the ".env" file:
Alternative option: set the NIP variable in the ".env" file.

Start the web server

Expand Down

0 comments on commit 0f79fcf

Please sign in to comment.