Skip to content

Latest commit

 

History

History
116 lines (88 loc) · 4.99 KB

platform-sh-deployment.md

File metadata and controls

116 lines (88 loc) · 4.99 KB

Platform.sh Deployment

Overview

Platform.sh is a powerful hosting provider for your infrastructure that's quite easy to use.

Keep in mind though, that this is not the only way to go for Apps! You can of course use different services, providers or host everything on a dedicated machine. In this guide, we'd like to let you know what we'd do to get started hosting an App on Platform.sh.

Read more about why this kind of hosting could be useful here or in there official documentation.

Getting started

To deploy your app on Platform.sh, just follow those instructions:

Most important steps

  1. Configure your Source Integrations (Optional, but highly recommended!)
  2. Install the Platform.sh CLI
  3. Authenticate using your Platform.sh account
  4. Create required config files. Also, if you create a new project, Platform.sh shows you a checklist where you can generate the code for these files
  5. Push your changes to your Git Repo
  6. After it's been deployed, migrate the database by connecting via SSH to your project and running the command vendor/bin/doctrine-migrations migrations:migrate
  7. That's it!

Your project should now be running at https://console.platform.sh, and you can start developing your own app!

Good to know

Automatic TLS certificates based on Branch / Pull Request

Platform.sh automatically creates a URL and TLS certificate using Let's Encrypt based on your routes.yaml file for every active environment.

You should be aware though that the URL will be built in a specific way. If your branch name gets too long, Let's Encrypt won't be able to generate a certificate.

To avoid this you should configure your Source Integrations to use the name of your Pull Request instead of the Branch Name.

Read more about this topic here: https://docs.platform.sh/configuration/routes/https.html#lets-encrypt-limits-errors-and-branch-names.

Hook commands

You can place commands like the database migration mentioned above inside your .platform.app.yaml under hooks. This way your commands will be executed every time it creates a new build.

{% code title=".platform.app.yaml" %}

hooks:
    build: |
        set -e
        php vendor/bin/doctrine-migrations migrations:migrate --no-interaction
    deploy: |
        set -e
        php vendor/bin/doctrine-migrations migrations:migrate --no-interaction

{% endcode %}

Useful Platform.sh commands

In order to use the following commands you need to have the Platform.sh CLI installed.

List all Platform.sh CLI commands

platform list

Set Platform.sh as new remote host

This step is needed if you want to get more information about the project using the Platform.sh CLI.

Documentation: https://docs.platform.sh/gettingstarted/introduction/own-code/create-project.html

platform project:set-remote <Project ID>

Push single branch to Platform.sh and activate it

Documentation: https://docs.platform.sh/gettingstarted/developing/dev-environments/create-environment.html

# Push to Platform.sh
git push -u platform <Branch Name>

# Activate branch
platform environment:activate <Branch Name>

Get available URLs for the current project

Documentation: https://docs.platform.sh/development/access-site.html#visiting-the-site-on-the-web

platform url 

SSH into your project

Documentation: https://docs.platform.sh/development/ssh.html

platform ssh

Connect to the database using SSH tunneling

Documentation: https://docs.platform.sh/development/local/tethered.html#ssh-tunneling

# List all possible commands
platform tunnel:list

# Open tunnel for all services
platform tunnel:open

# Connect to the remote database normally, as if it were local.
mysql --host=127.0.0.1 --port=30001 --user='user' --password='' --database='main'

Accessing log files

Documentation: https://docs.platform.sh/development/logs.html

platform log --help