.. meta:: :description: Find our how-to guide to deploying your application to Divio. Follow this step by step guide, including how to create a new app, connecting to cloud, and more. .. _deploy: Deploy your application to `Divio `_ =========================================================== The steps outlined here assume that you have already: * built a suitable application in Docker and prepared it for deployment (see :ref:`Configure an existing web application for deployment ` or :ref:`Create a new application `) * set up the :ref:`local development environment ` .. _deploy-create-new-project: Create a new application on Divio -------------------------------------------- The first step is to create an application on the Divio Control Panel, with your application repository. There are two ways of doing this: * *New application*, in which you will push your local Git code to Divio's Git server * *Import application*, in which your new Divio application will be created from existing Git repository .. image:: /images/new-project.png :alt: 'New application options' :width: 222 Creating a new application ~~~~~~~~~~~~~~~~~~~~~~~~~~ In the Divio Control Panel, add a `New application `_. Select the *Build your own* option. Importing an application from a Git repository ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In the Divio Control Panel, `Import an application `_. Once you have supplied the Git repository URL, you will need to use the public key provided to create a Deploy Key on the repository. You should also :ref:`add a webhook `, so that when new commits are pushed to the repository, it will send a signal to update the Divio Control Panel. .. admonition:: Limitations Some limitations apply to the current version of this functionality. At the time of import: * you will need to enable write access on the repository's deploy key Once imported, you can remove the write access. Connect your local application to the cloud application ------------------------------------------------------------------ Connecting a local application to a Divio application on the cloud allows you to interact with and manage the cloud application from your command-line. The cloud application has a *slug*, based on the name you gave it when you created it. Run: .. code-block:: bash divio app list -g to get your application's slug. You can also get the slug from the Control Panel: .. image:: /images/intro-slug.png :alt: 'Application slug' :width: 483 Run: .. code-block:: bash divio app configure and provide the slug. (``divio app configure`` creates a new file in the application at ``.divio/config.json``, containing the configuration data.) Configure Git (if required) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you are using Divio's own Git server for this application rather than an external Git provider, add the application's Git repository as a remote, for example: .. code-block:: bash git remote add divio git@git.divio.com:my-divio-application.git The Git URL is provided by the ``divio app configure`` command above, and in the *Repository* view of the Control Panel. Add database and media services -------------------------------------------- The new Divio application does not include any :ref:`additional services `. If your application requires a database or media store, they must be added manually using the Divio Control Panel as required. Use the *Services* menu to add the services your application needs. Add release commands ---------------------- If your application needs to perform operations each time it is deployed, for example start-up health tests or database migrations, these should be applied as :ref:`release commands `. Add additional environment variables -------------------------------------------- Your application may require additional environment variables in production. Apply any environment variables using the Divio Control Panel or CLI. Push local database/media content -------------------------------------------- If you have local database or media content, push them to the Test environment: .. code-block:: bash divio app push db divio app push media See also :ref:`Divio CLI usage examples `. Push your code -------------- Push your code to the Git repository, whether on Divio's own Git server or hosted with an external Git provider. Set the Git branch appropriately for each of your :ref:`cloud environments `. Deploy the Test server ---------------------- Deploy with: .. code-block:: bash divio app deploy (or use the **Deploy** button in the Control Panel). Once deployed, your application will be accessible via the URLs shown in the Control Panel for each environment. See our :ref:`go-live checklist ` for a production deployment.