You need to install on your machine `Docker <https://docs.docker.com/desktop/>`_ and `docker-compose <https://docs.docker.com/compose/install/>`_
You need to install `Docker <https://docs.docker.com/desktop/>`_ on your computer.
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.
Docker Compose (lately named Compose) is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.
In this use case, Compose is used with only one container but permits to launch shiny-server in order to help you to develop your shiny app under construction.
In this use case, Compose is used with only one container but permits to launch shiny-server in order to help you to develop your shiny app under construction.
Below, the content of ``docker-compose.yaml`` file. This file contains dedicated options to run the docker container with shiny-server service taking into account volume and port options.
Below, the content of ``docker-compose.yaml`` file. This file contains dedicated options to run the docker container with shiny-k8s-toolkit service taking into account volume and port options.
.. tabs:: Docker-compose
.. tabs:: Docker Compose
.. code-tab:: yaml
.. code-tab:: yaml
:caption: R
:caption: R
...
@@ -33,7 +33,7 @@ Below, the content of ``docker-compose.yaml`` file. This file contains dedicated
...
@@ -33,7 +33,7 @@ Below, the content of ``docker-compose.yaml`` file. This file contains dedicated
version: '3.4'
version: '3.4'
services:
services:
shiny-server:
shiny-k8s-toolkit:
build:
build:
context: .
context: .
user: 'shiny:shiny'
user: 'shiny:shiny'
...
@@ -50,7 +50,7 @@ Below, the content of ``docker-compose.yaml`` file. This file contains dedicated
...
@@ -50,7 +50,7 @@ Below, the content of ``docker-compose.yaml`` file. This file contains dedicated
version: '3.4'
version: '3.4'
services:
services:
shiny-server:
shiny-k8s-toolkit:
build:
build:
context: .
context: .
command: [
command: [
...
@@ -71,25 +71,25 @@ Below, the content of ``docker-compose.yaml`` file. This file contains dedicated
...
@@ -71,25 +71,25 @@ Below, the content of ``docker-compose.yaml`` file. This file contains dedicated
- '3838:3838'
- '3838:3838'
.. tabs:: Docker-compose
.. tabs:: Docker Compose
.. tab:: R
.. tab:: R
.. note::
.. note::
Your are free to change/modify folder name. Don't forget to put your name at line 8.
Your are free to change/modify folder name, if so don't forget to put your name at line 8.
.. tab:: Python
.. tab:: Python
.. note::
.. note::
| Your are free to change/modify folder name. Don't forget to put your name at line 8.
| Your are free to change/modify folder name, if so don't forget to put your name at line 18.
| Don't forget also to addapt the file name of you app at line 14. Here, we assume that your app is in the file named ``app.py``
| Don't forget also to addapt the file name of you app at line 14. Here, we assume that your app is in the file named ``app.py``
We described only some options used in the ``docker-compose`` file. If you want to learn more, please see `official documentation <https://docs.docker.com/compose/>`_
We described only some options used in the ``docker-compose.yaml`` file. If you want to learn more, please see `official documentation <https://docs.docker.com/compose/>`_
Volumes
Volumes
...
@@ -125,13 +125,13 @@ This folder have to be writable by the user ``shiny``, so simply allows everyone
...
@@ -125,13 +125,13 @@ This folder have to be writable by the user ``shiny``, so simply allows everyone
Port
Port
*****
*****
Port option permits to specify the ``HOST PORT`` and the ``CONTAINER PORT`` used for teh shiny-server service.
Port option permits to specify the ``HOST PORT`` and the ``CONTAINER PORT`` used for the shiny-k8s-toolkit service.
Here, we use the same port **3838** in the both case.
Here, we use the same port **3838** in the both case.
Command
Command
**********
**********
| **Only for Python**, the file contains also ``command`` instruction (lines 6 at 15) in order to reload the shiny-server after modification in your script.
| **Only for Python**, the file contains also ``command`` instruction (lines 6 at 15) in order to restart the shinyserver after modification in your script.
| The '--reload' option is native by default for R language in the shinyApp function and in shiny-server configuration.
| The '--reload' option is native by default for R language in the shinyApp function and in shiny-server configuration.
...
@@ -154,9 +154,9 @@ One command line is enough.
...
@@ -154,9 +154,9 @@ One command line is enough.
.. code-block:: bash
.. code-block:: bash
docker-compose up --build
dockercompose up --build
| This command line build the docker image in a container, run the container with several parameters like port and volume, who permits to launch teh shiny-server and test your shiny app.
| This command line build the docker image in a container, run the container with several parameters like port and volume, which permits to launch the shiny-k8s-toolkit service and test your shiny app.
| You can modify locally your script in your favorite IDE and see immediately ( after refresh your navigator), the changes in your app.
| You can modify locally your script in your favorite IDE and see immediately ( after refresh your navigator), the changes in your app.
| In order to access to your app, you can launch `0.0.0.0:3838 <http://0.0.0.0:3838>`_ in your navigator.
| In order to access to your app, you can launch `0.0.0.0:3838 <http://0.0.0.0:3838>`_ in your navigator.
...
@@ -171,7 +171,7 @@ One command line is enough.
...
@@ -171,7 +171,7 @@ One command line is enough.
Administrate your container
Administrate your container
------------------------------
------------------------------
By default, the name of the image build by ``docker-compose`` command depends of the project and the service name (Services are built once and then tagged, by default as ``project_service`` .)
By default, the name of the image build by ``docker-compose.yaml`` command depends of the project and the service name (Services are built once and then tagged, by default as ``project_service`` .)
See details `docker compose build <https://docs.docker.com/engine/reference/commandline/compose_build/>`_
See details `docker compose build <https://docs.docker.com/engine/reference/commandline/compose_build/>`_