From 84222b055a7bb3cccd897a7e46e12952474f195d Mon Sep 17 00:00:00 2001 From: AnouckColson Date: Mon, 25 Sep 2023 18:00:16 +0200 Subject: [PATCH 1/4] Vendorize section except submodules --- shared/data/regions.yaml | 64 +++++++++---------- sites/friday/.yaml | 21 +++--- sites/friday/config/_default/config.yaml | 5 ++ sites/friday/config/_default/params.yaml | 1 + sites/friday/package-lock.json | 4 +- sites/platform/config/_default/params.yaml | 1 + .../platform/src/add-services/mysql/_index.md | 2 +- sites/platform/src/development/email.md | 6 ++ .../platform/src/development/file-transfer.md | 2 +- .../platform/src/development/local/_index.md | 21 ++++-- sites/platform/src/development/local/ddev.md | 16 ++++- .../src/development/local/tethered.md | 4 +- .../sanitize-db/postgresql-symfony.md | 8 +-- sites/platform/src/development/ssh/_index.md | 27 +++----- .../platform/src/development/ssh/ssh-keys.md | 12 +++- .../src/development/ssh/troubleshoot-ssh.md | 14 ++-- .../platform/src/development/troubleshoot.md | 6 +- .../src/development/variables/_index.md | 3 + .../development/variables/set-variables.md | 7 ++ .../development/variables/use-variables.md | 47 +++++++------- .../platform/src/learn/tutorials/migrating.md | 10 +++ .../local-dev/local-dev-onboarding.sh | 2 +- .../shortcodes/local-dev/next-steps-end.md | 2 +- .../psh-docs/layouts/shortcodes/regions.html | 4 +- .../shortcodes/sanitize-dbs/requirements.md | 3 + .../layouts/shortcodes/vendor/alt-name.html | 1 + 26 files changed, 179 insertions(+), 114 deletions(-) create mode 100644 themes/psh-docs/layouts/shortcodes/vendor/alt-name.html diff --git a/shared/data/regions.yaml b/shared/data/regions.yaml index e3386a2304..f48f1f6b37 100644 --- a/shared/data/regions.yaml +++ b/shared/data/regions.yaml @@ -1,122 +1,122 @@ europe: eu: name: Ireland (eu) - label: eu.platform.sh + label: eu provider: AWS available: true outbound_ips: - "54.72.94.105" - "54.76.137.67" - "54.76.137.94" - inbound_location: gw.eu.platformsh.site + inbound_location: gw.eu inbound_ips: - "54.76.137.79" - "54.76.136.188" - "54.76.137.151" eu-2: name: Ireland (eu-2) - label: eu-2.platform.sh + label: eu-2 provider: AWS available: false outbound_ips: - "52.208.123.9" - "52.214.63.84" - "52.30.200.164" - inbound_location: gw.eu-2.platformsh.site + inbound_location: gw.eu-2 inbound_ips: - "34.248.104.12" - "34.241.191.143" - "52.210.208.94" eu-4: name: Ireland (eu-4) - label: eu-4.platform.sh + label: eu-4 provider: AWS available: false outbound_ips: - "18.200.158.188" - "18.200.157.200" - "18.200.184.206" - inbound_location: gw.eu-4.platformsh.site + inbound_location: gw.eu-4 inbound_ips: - "52.215.88.119" - "52.208.179.40" - "18.200.179.139" eu-5: name: Sweden (eu-5) - label: eu-5.platform.sh + label: eu-5 provider: AWS available: true outbound_ips: - "13.48.116.14" - "13.51.46.87" - "13.48.202.56" - inbound_location: gw.eu-5.platformsh.site + inbound_location: gw.eu-5 inbound_ips: - "13.51.62.86" de-2: name: Germany (de-2) - label: de-2.platform.sh + label: de-2 provider: Google Cloud Platform available: true outbound_ips: - "35.246.248.138" - "35.246.184.45" - "35.242.229.239" - inbound_location: gw.de-2.platformsh.site + inbound_location: gw.de-2 inbound_ips: - "35.246.248.138" - "35.246.184.45" - "35.242.229.239" fr-1: name: France (fr-1) - label: fr-1.platform.sh + label: fr-1 provider: Orange available: false outbound_ips: - "90.84.46.222" - "90.84.47.148" - "90.84.46.40" - inbound_location: gw.fr-1.platformsh.site + inbound_location: gw.fr-1 inbound_ips: - "90.84.46.40" - "90.84.47.148" - "90.84.46.222" fr-3: name: France (fr-3) - label: fr-3.platform.sh + label: fr-3 provider: OVHcloud available: true outbound_ips: - "135.125.91.125" - "135.125.89.47" - "135.125.90.255" - inbound_location: gw.fr-3.platformsh.site + inbound_location: gw.fr-3 inbound_ips: - "94.23.123.122" fr-4: name: France (fr-4) - label: fr-4.platform.sh + label: fr-4 provider: Azure available: true outbound_ips: - "20.74.41.190" - "20.74.41.218" - "20.74.42.30" - inbound_location: gw.fr-4.platformsh.site + inbound_location: gw.fr-4 inbound_ips: - "20.74.41.190" - "20.74.41.218" - "20.74.42.30" uk-1: name: United Kingdom (uk-1) - label: uk-1.platform.sh + label: uk-1 provider: Google Cloud Platform available: true outbound_ips: - "35.242.142.110" - "35.189.126.202" - "35.242.183.249" - inbound_location: gw.uk-1.platformsh.site + inbound_location: gw.uk-1 inbound_ips: - "35.242.142.110" - "35.189.126.202" @@ -124,56 +124,56 @@ europe: us: us: name: East (us) - label: us.platform.sh + label: us provider: AWS available: true outbound_ips: - "54.88.149.31" - "54.209.114.37" - "54.210.53.51" - inbound_location: gw.us.platformsh.site + inbound_location: gw.us inbound_ips: - "54.88.119.241" - "18.213.180.11" - "54.163.149.158" us-2: name: East (us-2) - label: us-2.platform.sh + label: us-2 provider: AWS available: true outbound_ips: - "34.238.64.193" - "52.4.246.137" - "54.157.66.30" - inbound_location: gw.us-2.platformsh.site + inbound_location: gw.us-2 inbound_ips: - "34.226.46.235" - "34.238.11.122" - "54.89.106.200" us-3: name: West (us-3) - label: us-3.platform.sh + label: us-3 provider: Azure available: true outbound_ips: - "52.137.90.183" - "52.156.93.30" - "51.143.107.76" - inbound_location: gw.us-3.platformsh.site + inbound_location: gw.us-3 inbound_ips: - "52.137.90.183" - "52.156.93.30" - "51.143.107.76" us-4: name: East (us-4) - label: us-4.platform.sh + label: us-4 provider: Google Cloud Platform available: true outbound_ips: - "34.73.189.215" - "34.74.8.155" - "34.75.104.115" - inbound_location: gw.us-4.platformsh.site + inbound_location: gw.us-4 inbound_ips: - "34.73.189.215" - "34.74.8.155" @@ -182,14 +182,14 @@ canada: ca-1: name: Canada (ca-1) location_guarantee: false - label: ca-1.platform.sh + label: ca-1 provider: AWS available: true outbound_ips: - "35.182.24.224" - "52.60.213.255" - "35.182.220.113" - inbound_location: gw.ca-1.platformsh.site + inbound_location: gw.ca-1 inbound_ips: - "35.182.174.169" - "35.182.59.77" @@ -197,28 +197,28 @@ canada: australia: au: name: Australia (au) - label: au.platform.sh + label: au provider: AWS available: true outbound_ips: - "13.55.135.0" - "13.54.121.225" - "13.55.215.151" - inbound_location: gw.au.platformsh.site + inbound_location: gw.au inbound_ips: - "13.54.88.239" - "13.55.140.143" - "13.54.222.56" au-2: name: Australia (au-2) - label: au-2.platform.sh + label: au-2 provider: Azure available: true outbound_ips: - "20.92.240.74" - "20.191.224.199" - "20.92.240.236" - inbound_location: gw.au-2.platformsh.site + inbound_location: gw.au-2 inbound_ips: - "20.92.240.74" - "20.191.224.199" diff --git a/sites/friday/.yaml b/sites/friday/.yaml index 8f9da39de9..5a880caeca 100644 --- a/sites/friday/.yaml +++ b/sites/friday/.yaml @@ -167,6 +167,7 @@ elixir: - '1.10' - '1.9' supported: + - '1.15' - '1.14' - '1.13' - '1.12' @@ -550,6 +551,7 @@ nodejs: - '4.7' - '0.12' supported: + - '20' - '18' - '16' versions-dedicated-gen-2: @@ -585,7 +587,6 @@ opensearch: deprecated: [] supported: - '2.5' - - '2.4' - '1.2' versions-dedicated-gen-3: deprecated: [] @@ -952,9 +953,10 @@ varnish: endpoint: http+stats min_disk_size: null configuration: |2- - vcl: !include - type: string - path: config.vcl + configuration: + vcl: !include + type: string + path: config.vcl service_relationships: 'application: ''app:http''' name: Varnish runtime: false @@ -978,11 +980,12 @@ vault-kms: endpoint: manage_keys min_disk_size: 512 configuration: |2- - endpoints: - : - - policy: - key: - type: + configuration: + endpoints: + : + - policy: + key: + type: name: Vault KMS repo_name: vault-kms runtime: false diff --git a/sites/friday/config/_default/config.yaml b/sites/friday/config/_default/config.yaml index feeb07a8a2..bc1352cec9 100644 --- a/sites/friday/config/_default/config.yaml +++ b/sites/friday/config/_default/config.yaml @@ -61,6 +61,11 @@ module: - "increase-observability/logs/forward-fastly-logs.md" - "increase-observability/metrics/dedicated.md" - "increase-observability/metrics/dedicated-generation-3.md" + - "development/templates.md" + - "development/local/docksal.md" + - "development/local/lando.md" + - "development/deploy-button.md" + - "development/sanitize-db/mariadb.md" - "domains/cdn/managed-fastly.md" - "domains/security/web-application-firewall/fastly.md" - "domains/steps/custom-domains-preview-environments.md" diff --git a/sites/friday/config/_default/params.yaml b/sites/friday/config/_default/params.yaml index 2a5d74d685..9a02fa9c89 100644 --- a/sites/friday/config/_default/params.yaml +++ b/sites/friday/config/_default/params.yaml @@ -16,6 +16,7 @@ theme: vendor: name: Upsun cli: upsun + altname: upsun env_prefix: PLATFORM recruit: active: true diff --git a/sites/friday/package-lock.json b/sites/friday/package-lock.json index 28c080f4ce..9173671e97 100644 --- a/sites/friday/package-lock.json +++ b/sites/friday/package-lock.json @@ -1,11 +1,11 @@ { - "name": "platformsh-docs", + "name": "platformsh-docs-whitelabel", "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "platformsh-docs", + "name": "platformsh-docs-whitelabel", "version": "1.0.0", "license": "CC-BY-NC-SA-4.0", "workspaces": [ diff --git a/sites/platform/config/_default/params.yaml b/sites/platform/config/_default/params.yaml index bbc4a28553..11a43ca6e2 100644 --- a/sites/platform/config/_default/params.yaml +++ b/sites/platform/config/_default/params.yaml @@ -13,6 +13,7 @@ editPageButton: true vendor: name: Platform.sh cli: platform + altname: platformsh env_prefix: PLATFORM recruit: active: true diff --git a/sites/platform/src/add-services/mysql/_index.md b/sites/platform/src/add-services/mysql/_index.md index de1c970938..a054ba47b2 100644 --- a/sites/platform/src/add-services/mysql/_index.md +++ b/sites/platform/src/add-services/mysql/_index.md @@ -561,7 +561,7 @@ If not, make a backup or do a database export before importing. ## Sanitizing data To ensure people who review code changes can't access personally identifiable information stored in your database, -[sanitize your preview environments](../../development/sanitize-db/mariadb.md). +[sanitize your preview environments](../../development/sanitize-db/_index.md). ## Replication diff --git a/sites/platform/src/development/email.md b/sites/platform/src/development/email.md index 033238461f..dc40136c50 100644 --- a/sites/platform/src/development/email.md +++ b/sites/platform/src/development/email.md @@ -66,10 +66,16 @@ v=spf1 include:sendgrid.net -all ## 3. (Optional) Validate your email +{{% version/specific %}} + {{< premium-features/tiered "Enterprise and Elite" >}} If you're on an Enterprise or Elite plan, you can request for DomainKeys Identified Mail (DKIM) to be enabled on your domain. +<---> + +You can request for DomainKeys Identified Mail (DKIM) to be enabled on your domain. +{{% /version/specific %}} DKIM improves your delivery rate as an email sender. Learn more about [how DKIM works](https://docs.sendgrid.com/glossary/dkim). diff --git a/sites/platform/src/development/file-transfer.md b/sites/platform/src/development/file-transfer.md index 0d4fe9ffa3..ef6683388d 100644 --- a/sites/platform/src/development/file-transfer.md +++ b/sites/platform/src/development/file-transfer.md @@ -32,7 +32,7 @@ To do so, run the following command: The output is similar to the following: ```bash -Mounts on abcdefgh1234567-main-abcd123--app@ssh.eu.platform.sh: +Mounts on abcdefgh1234567-main-abcd123--app@ssh.eu.{{< vendor/urlraw "host" >}}: +-------------------------+----------------------+ | Mount path | Definition | +-------------------------+----------------------+ diff --git a/sites/platform/src/development/local/_index.md b/sites/platform/src/development/local/_index.md index c9350444a6..d14fb8b931 100644 --- a/sites/platform/src/development/local/_index.md +++ b/sites/platform/src/development/local/_index.md @@ -17,21 +17,32 @@ the various dependencies, certificates, and connections your app needs to run. The **recommended tool** for local development with {{< vendor/name >}} is **[DDEV](./ddev.md)**. The integration with DDEV is maintained by {{< vendor/name >}} to ensure it works smoothly. -Other Docker-based tools are also supported, such as [Docksal](./docksal.md) and [Lando](./lando.md). +{{% version/specific %}} + +Other Docker-based tools are also supported, such as [Docksal](./docksal.md) and [Lando](./lando.md). If you choose to use a Docker-based tool, follow the steps on its page. +<---> + +If you choose to use DDEV, follow the steps [on its page](./ddev.md). +{{% /version/specific %}} Otherwise, follow these steps to run your app on your computer. ## Before you begin You need to have: - +{{% version/specific %}} + - A {{< vendor/name >}} account: new users can sign up for a [free trial account](https://auth.api.platform.sh/register) -- A working project, - either started from a [template](../../development/templates.md) - or with your own code pushed to {{< vendor/name >}} + +<---> + +- A {{< vendor/name >}} account: + new users can [register here](https://upsun.com/register/) +{{% /version/specific %}} +- A working project - [Git](https://git-scm.com/downloads) - The [{{< vendor/name >}} CLI](../../administration/cli/_index.md) diff --git a/sites/platform/src/development/local/ddev.md b/sites/platform/src/development/local/ddev.md index f2f2ba7d95..d993cc5e14 100644 --- a/sites/platform/src/development/local/ddev.md +++ b/sites/platform/src/development/local/ddev.md @@ -11,8 +11,16 @@ keywords: {{% ddev/definition %}} This guide assumes you have a project already running with {{< vendor/name >}} and you have the code on your computer. + +{{% version/specific %}} + If you're starting from scratch, first [create a project from a PHP template]({{% create-project-link template=true %}}). +<---> + +If you're starting from scratch, first [create a project](/get-started/). +{{% /version/specific %}} + ## Before you begin {{% ddev/requirements %}} @@ -28,11 +36,17 @@ Get basic configuration set up for your project by running the following command ```bash ddev config ``` - +{{% version/specific %}} + If you started with a Drupal template, your repository already had DDEV configuration files. Otherwise, you have to answer a couple of questions about what your repository is so the correct files are added. +<---> + +Follow the prompts to add the correct DDEV configuration files to your repository. +{{% /version/specific %}} + ## 3. Add an API token {{% ddev/token %}} diff --git a/sites/platform/src/development/local/tethered.md b/sites/platform/src/development/local/tethered.md index d69dcca2ed..8058300e6c 100644 --- a/sites/platform/src/development/local/tethered.md +++ b/sites/platform/src/development/local/tethered.md @@ -23,7 +23,7 @@ Because it replies on a local web server, it's also less consistent across your make sure to mock those variables as well. Your options for running the app depend on the language and configuration. - You can use the serve for your language, install a copy of Nginx, + You can use the server for your language, install a copy of Nginx, or use a virtual machine or Docker image. {{% tethered-dev/steps-end %}} @@ -59,7 +59,7 @@ You can use the information returned to connect to the remote database as if it For example, the following command would connect to a MySQL database running through a tethered connection: ```bash -mysql --host=127.0.0.1 --port={{ variable "PORT" }} --user='{{ variable "USERNAME" }}' --password='{{ variable "PASSWORD" }}' --database='{{ variable "PATH" }}' +mysql --host=127.0.0.1 --port={{< variable "PORT" >}} --user={{< variable "USERNAME" >}} --password={{< variable "PASSWORD" >}} --database={{< variable "PATH" >}} ``` {{% local-dev/next-steps-start %}} diff --git a/sites/platform/src/development/sanitize-db/postgresql-symfony.md b/sites/platform/src/development/sanitize-db/postgresql-symfony.md index b0a41c0611..47074ab7c5 100644 --- a/sites/platform/src/development/sanitize-db/postgresql-symfony.md +++ b/sites/platform/src/development/sanitize-db/postgresql-symfony.md @@ -170,14 +170,14 @@ Set up a script by following these steps: # Utility functions. # list_org_projects: Print list of projects operation will be applied to before starting. - # $1: Organization, as it appears in console.platform.sh. + # $1: Organization, as it appears in console.{{< vendor/urlraw "host" >}}. list_org_projects () { symfony project:list -o $1 --columns="ID, Title" } # get_org_projects: Retrieve an array of project IDs for a given organization. # Note: Makes array variable PROJECTS available to subsequent scripts. - # $1: Organization, as it appears in console.platform.sh. + # $1: Organization, as it appears in console.{{< vendor/urlraw "host" >}}. get_org_projects () { PROJECTS_LIST=$(symfony project:list -o $1 --pipe) PROJECTS=($PROJECTS_LIST) @@ -185,14 +185,14 @@ Set up a script by following these steps: # get_project_envs: Retrieve an array of envs IDs for a project. # Note: Makes array variable ENVS available to subsequent scripts. - # $1: ProjectId, as it appears in console.platform.sh. + # $1: ProjectId, as it appears in console.{{< vendor/urlraw "host" >}}. get_project_envs () { ENV_LIST=$(symfony environment:list -p $1 --pipe) ENVS=($ENV_LIST) } # list_project_envs: Print list of envs operation will be applied to before starting. - # $1: ProjectId, as it appears in console.platform.sh. + # $1: ProjectId, as it appears in console.{{< vendor/urlraw "host" >}}. list_project_envs () { symfony environment:list -p $1 } diff --git a/sites/platform/src/development/ssh/_index.md b/sites/platform/src/development/ssh/_index.md index 11eff81047..aea888297a 100644 --- a/sites/platform/src/development/ssh/_index.md +++ b/sites/platform/src/development/ssh/_index.md @@ -31,7 +31,7 @@ To authenticate with the CLI: 1. Install the [{{< vendor/name >}} CLI](/administration/cli/_index.md). 2. Run `{{% vendor/cli %}} login`. 3. In the open browser window, log in with your {{< vendor/name >}} account credentials. - (This webpage is encrypted with HTTPS [HTTP over TLS], making it secure.) + (This webpage is encrypted with [HTTPS](/define-routes/https.md), making it secure.) 4. Authorize the CLI to use your account. A certificate gets stored in your local SSH configuration. @@ -56,21 +56,7 @@ navigate to the environment you want to access and click **SSH** in the top righ Alternatively, just run `{{% vendor/cli %}} ssh` and select the values from each list presented to you. -Once you've connected, you get a response like this: - -```bash - ___ _ _ __ - | _ \ |__ _| |_ / _|___ _ _ _ __ - | _/ / _` | _| _/ _ \ '_| ' \ - |_| |_\__,_|\__|_| \___/_| |_|_|_| - - Welcome to Platform. - - This is environment main - of project wk5fqz6qoo123. - -web@wk5fqz6qoo123-main--php:~$ -``` +Once you've connected, you get a welcome message detailing which environment you're connected to. Now you can interact with the environment as you want. Note that your app's file system is read-only, @@ -138,7 +124,7 @@ Run the following command: You get output similar to the following: ```bash -jyu7waly36ncj-main-7rqtwti--app@ssh.us.platform.sh +jyu7waly36ncj-main-7rqtwti--app@ssh.us.{{< vendor/urlraw "host" >}} ``` <---> @@ -150,12 +136,12 @@ title=In the Console 1. Navigate to the environment you want to connect to. 2. Click **SSH** in the top right-hand corner. 3. You get output similar to the following:
- `jyu7waly36ncj-main-7rqtwti--app@ssh.us.platform.sh` + `jyu7waly36ncj-main-7rqtwti--app@ssh.us.{{< vendor/urlraw "host" >}}` {{< /codetabs >}} The host is everything after the `@` and the username is what's before it. -In this case, the host is `ssh.us.platform.sh` and the username is `jyu7waly36ncj-main-7rqtwti--app`. +In this case, the host is `ssh.us.{{< vendor/urlraw "host" >}}` and the username is `jyu7waly36ncj-main-7rqtwti--app`. The host is the same for the entire project, while the username varies by environment. To connect to a service, fill in the details with the rest of your [service credentials](../../add-services/_index.md#connect-to-a-service). @@ -178,6 +164,8 @@ There are three basic ways to authenticate with {{< vendor/name >}}: * Good for letting automation tools use the CLI. * Requires you to regularly change the tokens to maintain security. +{{% version/only "1" %}} + ## Multifactor authentication (MFA) over SSH {{< premium-features/tiered "Enterprise and Elite" >}} @@ -188,3 +176,4 @@ to run Git commands or to SSH in an environment. To enable this feature, open a support ticket and request for MFA over SSH to be enforced within your organization. If you have trouble accessing an environment with MFA enabled, see how to [add a second factor](./troubleshoot-ssh.md#add-a-second-authentication-factor). +{{% /version/only %}} \ No newline at end of file diff --git a/sites/platform/src/development/ssh/ssh-keys.md b/sites/platform/src/development/ssh/ssh-keys.md index c73253df04..30782bc381 100644 --- a/sites/platform/src/development/ssh/ssh-keys.md +++ b/sites/platform/src/development/ssh/ssh-keys.md @@ -89,8 +89,14 @@ in a terminal run the following command (replacing `{{< variable "PATH_TO_YOUR_K {{% vendor/cli %}} ssh-key:add '{{< variable "PATH_TO_YOUR_KEY" >}}' ``` +{{% version/specific %}} + You can also add it in the Console, similar to this [video](https://docs.platform.sh/videos/management-console/add-ssh-mc.mp4). +<---> + +You can also add it in the Console. +{{% /version/specific %}} Now you are ready to use the key to [connect to an environment](./_index.md#2-connect-to-an-app-with-ssh). @@ -103,7 +109,7 @@ To connect to a server using SSH keys, find the details in the Console: 1. In the **Environment** dropdown, select the environment you want to access. 1. Click the **SSH** dropdown. 1. Copy the ssh command for where you want access. - (Example: `ssh abcdefghi5k-main-7rqtwti--app@ssh.us-2.platform.sh`) + (Example: `ssh abcdefghi5k-main-7rqtwti--app@ssh.us-2.{{< vendor/urlraw "host" >}}`) 1. Enter the command into a terminal. Note that if you have just added your SSH key, @@ -115,9 +121,9 @@ It may be helpful to set your SSH client to always forward keys to {{< vendor/na To do so, include a block in your local `~/.ssh/config` file like so: ```text -Host *.us.platform.sh +Host *.us.{{< vendor/urlraw "host" >}} ForwardAgent yes -Host *.eu.platform.sh +Host *.eu.{{< vendor/urlraw "host" >}} ForwardAgent yes ``` diff --git a/sites/platform/src/development/ssh/troubleshoot-ssh.md b/sites/platform/src/development/ssh/troubleshoot-ssh.md index 6ec16aa116..6235c93983 100644 --- a/sites/platform/src/development/ssh/troubleshoot-ssh.md +++ b/sites/platform/src/development/ssh/troubleshoot-ssh.md @@ -66,10 +66,10 @@ you may have to append a specification like the one below so that the SSH softwa ```bash Host platform.sh -IdentityFile ~/.ssh/id_platformsh +IdentityFile ~/.ssh/id_{{% vendor/alt-name %}} ``` -Be aware that, above, `platform.sh` stands for a hostname. +Be aware that, above, `{{% vendor/alt-name %}}` stands for a hostname. Each different hostname you connect to {{< vendor/name >}} at may have to be specified in the host line, separated by spaces. ## Check your git integrations @@ -83,15 +83,15 @@ If your organization has [multifactor authentication set up](./_index.md#multifa you may get an error like the following when trying to log into your environment with SSH keys: ```bash -Hello (UUID: ), you successfully authenticated, but could not connect to service --app +Hello {{< variable "NAME" >}} (UUID: {{< variable "USER_ID" >}}), you successfully authenticated, but could not connect to service {{< variable "USER_ID" >}} --app (reason: access requires MFA) -@ssh..platform.sh: Permission denied (publickey) +{{< variable "ENVIRONMENT_ID" >}}@ssh.{{< variable "REGION" >}}.{{< vendor/urlraw "host" >}}: Permission denied (publickey) ``` If you are using just `ssh` and not `{{% vendor/cli %}} ssh`, you may see only the second half of the error: ```bash -@ssh..platform.sh: Permission denied (publickey) +{{< variable "ENVIRONMENT_ID" >}}@ssh.{{< variable "REGION" >}}.{{< vendor/urlraw "host" >}}: Permission denied (publickey) ``` To resolve this: @@ -134,7 +134,7 @@ You get output similar to the following: ```bash OpenSSH_6.7.8, OpenSSL 1.2.3 1 Sep 2014 -debug1: Connecting to ssh.eu.platform.sh [54.32.10.98] port 22. +debug1: Connecting to ssh.eu.{{< vendor/urlraw "host" >}} [54.32.10.98] port 22. debug1: Connection established. debug1: identity file /Users/your_username/.ssh/id_rsa type 1 ...(many more lines of this light reading)... @@ -156,4 +156,4 @@ You can use this information to make one last check of the private key file. {{% troubleshoot %}} -If you're still stuck, [submit a support ticket and provide the full SSH debug information](https://console.platform.sh/-/users/:user/tickets). +If you're still stuck, [submit a support ticket and provide the full SSH debug information](https://console.platform.sh/-/users/:user/tickets). \ No newline at end of file diff --git a/sites/platform/src/development/troubleshoot.md b/sites/platform/src/development/troubleshoot.md index 93d93c0194..ad2ec0bad4 100644 --- a/sites/platform/src/development/troubleshoot.md +++ b/sites/platform/src/development/troubleshoot.md @@ -118,7 +118,9 @@ Typical causes and potential solutions include: - Check your `web.commands.start` entry or your `passthru` configuration. - The amount of traffic coming to your site exceeds the processing power of your application. - You may want to [check if bots are overwhelming your site](https://community.platform.sh/t/diagnosing-and-resolving-issues-with-excessive-bot-access/792). + {{% version/only "1" %}} - Alternatively, you may need to [increase your plan size](../administration/pricing/_index.md). + {{% /version/only %}} - Certain code paths in your application are too slow and timing out. - Check your code is running smoothly. - Consider adding an [observability solution](../increase-observability/integrate-observability/_index.md) to get a better view of your application. @@ -206,9 +208,9 @@ Or [declare mounts](../create-apps/app-reference.md#mounts), which are writable even during and after deploy. They can be used for your data: file uploads, logs, and temporary files. -### Git push fails due to lack of disk space +### {{% vendor/name %}} push fails due to lack of disk space -You might see the following message when attempting to run `git push`: +You might see the following message when attempting to run `{{% vendor/cli %}} push`: `There isn't enough free space to complete the push` This usually indicates that large files are present in the repository (where they shouldn't be). diff --git a/sites/platform/src/development/variables/_index.md b/sites/platform/src/development/variables/_index.md index eaabeb6d63..ab7e192076 100644 --- a/sites/platform/src/development/variables/_index.md +++ b/sites/platform/src/development/variables/_index.md @@ -3,6 +3,7 @@ title: Variables overview weight: 5 description: | Variables give you control over your project's build process and runtime environment. You can set them in your code to make changes across your project or independent of the code for environment-specific settings. +layout: single keywords: - environment variables --- @@ -190,6 +191,7 @@ For specific frameworks, you can implement logic to override global configuratio So you can use the same codebase and settings for all your environments, but still adapt the behavior to each environment. +{{% version/only "1" %}} #### Implementation example The [Drupal 9 template](https://github.com/platformsh-templates/drupal9/) shows an example of @@ -217,3 +219,4 @@ You need to name your {{< vendor/name >}} variables to match the ones used in yo Make sure that the {{< vendor/name >}} variables start with a string present in your `switch` statement. You can apply similar logic for [other frameworks and languages](../../development/variables/use-variables.md#access-variables-in-your-app). +{{% /version/only %}} \ No newline at end of file diff --git a/sites/platform/src/development/variables/set-variables.md b/sites/platform/src/development/variables/set-variables.md index b1b8639a3d..9b55c529df 100644 --- a/sites/platform/src/development/variables/set-variables.md +++ b/sites/platform/src/development/variables/set-variables.md @@ -242,9 +242,16 @@ To solve the issue, remove the printed output from your `.environment` file. ## Map variables +{{% version/specific %}} + If your app needs different names for environment variable than those set by {{< vendor/name >}}, which is common for database connections, map the {{< vendor/name >}}'s variable names to those required by the application. Do this in the app with the help of the [Config Reader library](./use-variables.md#access-variables-in-your-app) or via a shell script. +<---> + +If your app needs different names for environment variable than those set by {{< vendor/name >}}, which is common for database connections, +map the {{< vendor/name >}}'s variable names to those required by the application via a shell script. +{{% /version/specific %}} For example, the following [`.environment` script](#set-variables-via-script) exports variables that are visible to the application. It uses the `jq` library, which is included in all app containers for this purpose. diff --git a/sites/platform/src/development/variables/use-variables.md b/sites/platform/src/development/variables/use-variables.md index 530d1d82b0..45499e24c8 100644 --- a/sites/platform/src/development/variables/use-variables.md +++ b/sites/platform/src/development/variables/use-variables.md @@ -55,6 +55,8 @@ Variables available during builds can be accessed in `build` hooks and those ava ## Access variables in your app +{{% version/specific %}} + To access environment variables in your app, you can use the {{< vendor/name >}} Config Reader for the given language: * [PHP](https://github.com/platformsh/config-reader-php) @@ -65,13 +67,17 @@ To access environment variables in your app, you can use the {{< vendor/name >}} * [Ruby](https://github.com/platformsh/platformsh-ruby-helper) * [Elixir](https://github.com/platformsh/config-reader-elixir) -Alternative, use a built-in method for the given language. - +Alternatively, use a built-in method for the given language. +<---> + +To access environment variables in your app, use a built-in method for the given language. + * PHP: The [`getenv()` function](https://www.php.net/manual/en/function.getenv.php) * Python: The [`os.environ` object](https://docs.python.org/3/library/os.html#os.environ) * Node.js: The [`process.env` object](https://nodejs.org/api/process.html#process_process_env) * Ruby: The [`ENV` accessor](https://ruby-doc.org/current/ENV.html) * Java: The [`System.getenv()` method](https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#getenv-java.lang.String-) +{{% /version/specific %}} {{< codetabs >}} @@ -190,7 +196,7 @@ variables: "milk": "1 liter" "cookies": "1 kg" stuff: - STEPS: ['un', 'deux', 'trois'] + STEPS: ['one', 'two', 'three'] COLORS: red: '#FF0000' green: '#00FF00' @@ -214,9 +220,9 @@ echo $QUANTITIES {"cookies": "1 kg", "milk": "1 liter"} echo "$PLATFORM_VARIABLES" | base64 --decode | jq '."stuff:STEPS"' [ - "un", - "deux", - "trois" + "one", + "two", + "three" ] echo "$PLATFORM_VARIABLES" | base64 --decode | jq '."stuff:COLORS"' { @@ -248,11 +254,11 @@ print_r($variables['stuff:STEPS']); /* array(3) { [0]=> - string(2) "un" + string(2) "one" [1]=> - string(4) "deux" + string(4) "two" [2]=> - string(5) "trois" + string(5) "three" } */ @@ -291,7 +297,7 @@ print os.getenv('QUANTITIES') variables = json.loads(base64.b64decode(os.getenv('PLATFORM_VARIABLES')).decode('utf-8')) print variables['stuff:STEPS'] -# [u'un', u'deux', u'trois'] +# [u'one', u'two', u'three'] print variables['stuff:COLORS'] # {u'blue': u'#0000FF', u'green': u'#00FF00', u'red': u'#FF0000'} ``` @@ -315,7 +321,7 @@ console.log(INGREDIENTS); console.log(QUANTITIES); // {"cookies": "1 kg", "milk": "1 liter"} console.log(stuffSteps); -// [ 'un', 'deux', 'trois' ] +// [ 'one', 'two', 'three' ] console.log(stuffColors); // { blue: '#0000FF', green: '#00FF00', red: '#FF0000' } ``` @@ -404,21 +410,18 @@ But the specific attributes it contains differ in each case. Each environment's build is associated with a configuration ID that identifies it uniquely so builds can be reused. The ID is a product of your app code and some of its [configuration for {{< vendor/name >}}](../../create-apps/_index.md). -Not every attribute your app configuration is relevant to the build. +Not every attribute inyour app configuration is relevant to the build. Only those attributes that are relevant to builds are accessible at build time from `PLATFORM_APPLICATION`. Attributes that are **not** available in `PLATFORM_APPLICATION` during builds: -* Everything under `resources` -* `size` -* `disk` -* Everything under `access` -* Everything under `relationship` -* Everything under `firewall` -* `hooks.deploy` and `hooks.post_deploy` -* Everything under `crons` -* Everything under `web`, except `web.mounts` -* Everything under `workers`, except `workers.mounts` +- Everything under `access` +- Everything under `relationship` +- Everything under `firewall` +- `hooks.deploy` and `hooks.post_deploy` +- Everything under `crons` +- Everything under `web`, except `web.mounts` +- Everything under `workers`, except `workers.mounts` These attributes aren't visible during build because they aren't included as a part of the configuration component of the build slug. So modifying these values in your [app configuration](../../create-apps/_index.md) doesn't trigger an app rebuild, only a redeploy. diff --git a/sites/platform/src/learn/tutorials/migrating.md b/sites/platform/src/learn/tutorials/migrating.md index a944e3cfc4..b2ce154776 100644 --- a/sites/platform/src/learn/tutorials/migrating.md +++ b/sites/platform/src/learn/tutorials/migrating.md @@ -14,7 +14,14 @@ You need: - An app that works and is ready to be built - Code in Git +{{% version/specific %}} + - A {{< vendor/name >}} account -- if you don't already have one, [start a trial](https://auth.api.platform.sh/register?trial_type=general) + +<---> + +- A {{< vendor/name >}} account -- if you don't already have one, [register](https://upsun.com/register/). +{{% /version/specific %}} - Optional: the [{{< vendor/name >}} CLI](/administration/cli/_index.md) ## 1. Export from previous system @@ -61,8 +68,11 @@ You likely want to configure three areas: - [Services](/add-services/_index.md) - [Routes](/define-routes/_index.md) +{{% version/only "1" %}} + You can also take guidance from the [project templates](/development/templates.md), which are starting points for various technology stacks with working configuration examples. +{{% /version/only %}} When you've added your configuration, make sure to commit it to Git. diff --git a/themes/psh-docs/layouts/shortcodes/local-dev/local-dev-onboarding.sh b/themes/psh-docs/layouts/shortcodes/local-dev/local-dev-onboarding.sh index 4696623739..51ab873a72 100644 --- a/themes/psh-docs/layouts/shortcodes/local-dev/local-dev-onboarding.sh +++ b/themes/psh-docs/layouts/shortcodes/local-dev/local-dev-onboarding.sh @@ -10,7 +10,7 @@ PARENT=$2 {{ `{{< vendor/cli >}}` | .Page.RenderString }} tunnel:open --no-interaction # Mock {{ `{{< vendor/name >}}` | .Page.RenderString }} environment variables -export PLATFORM_RELATIONSHIPS="$(platform tunnel:info --encode)" +export PLATFORM_RELATIONSHIPS="$({{ `{{< vendor/cli >}}` | .Page.RenderString }} tunnel:info --encode)" # Add any other variables you need # If necessary, install dependencies here diff --git a/themes/psh-docs/layouts/shortcodes/local-dev/next-steps-end.md b/themes/psh-docs/layouts/shortcodes/local-dev/next-steps-end.md index f352d074d2..a625605a06 100644 --- a/themes/psh-docs/layouts/shortcodes/local-dev/next-steps-end.md +++ b/themes/psh-docs/layouts/shortcodes/local-dev/next-steps-end.md @@ -1,7 +1,7 @@ 1. To commit and push the revisions, run the following command: ```bash - git add . && git commit -m "Add local configuration" && git push platform local-config + git add . && git commit -m "Add local configuration" && git push {{ `{{< vendor/cli >}}` | .Page.RenderString }} local-config ``` 1. Merge the change into production. diff --git a/themes/psh-docs/layouts/shortcodes/regions.html b/themes/psh-docs/layouts/shortcodes/regions.html index df1c6b9021..35ba6e9850 100644 --- a/themes/psh-docs/layouts/shortcodes/regions.html +++ b/themes/psh-docs/layouts/shortcodes/regions.html @@ -24,7 +24,7 @@

{{ .name }}

- {{ .label }} + {{ printf "%s.%s" .label $.Site.Params.vendor.urls.host }} @@ -47,7 +47,7 @@

Inbound ips - {{ .inbound_location }} + {{ printf "%s.%s" .inbound_location $.Site.Params.vendor.urls.hostname }}
    {{ range .inbound_ips }} diff --git a/themes/psh-docs/layouts/shortcodes/sanitize-dbs/requirements.md b/themes/psh-docs/layouts/shortcodes/sanitize-dbs/requirements.md index 99436e4114..424463c595 100644 --- a/themes/psh-docs/layouts/shortcodes/sanitize-dbs/requirements.md +++ b/themes/psh-docs/layouts/shortcodes/sanitize-dbs/requirements.md @@ -9,6 +9,9 @@ {{ $cli = "[Drush](https://www.drush.org/latest/install/)" }} {{ end }} {{ $cliLink := "[Platform CLI](../../administration/cli/_index.md)" }} +{{ if eq $.Site.Params.vendor.config.version 2 }} + {{ $cliLink = "[Upsun CLI](../../administration/cli/_index.md)" }} +{{ end }} {{ if eq $framework "Symfony" }} {{ $cliLink = "[Symfony CLI](https://symfony.com/download)" }} {{ end }} diff --git a/themes/psh-docs/layouts/shortcodes/vendor/alt-name.html b/themes/psh-docs/layouts/shortcodes/vendor/alt-name.html new file mode 100644 index 0000000000..3222d9b345 --- /dev/null +++ b/themes/psh-docs/layouts/shortcodes/vendor/alt-name.html @@ -0,0 +1 @@ +{{ .Site.Params.vendor.altname }} \ No newline at end of file From da4dfa2cbb1091e68cdffa55ad7f31553cd3865a Mon Sep 17 00:00:00 2001 From: AnouckColson Date: Tue, 26 Sep 2023 16:27:16 +0200 Subject: [PATCH 2/4] Git submodules and last conf examples --- sites/friday/config/_default/config.yaml | 1 - .../src/development/private-repository.md | 13 ++ sites/platform/src/development/submodules.md | 111 ++++++++++++++---- .../src/development/variables/_index.md | 12 +- .../development/variables/use-variables.md | 70 ++++++++--- .../shortcodes/local-dev/next-steps-end.md | 6 +- .../sanitize-dbs/sanitize-manually.md | 36 +++--- 7 files changed, 187 insertions(+), 62 deletions(-) diff --git a/sites/friday/config/_default/config.yaml b/sites/friday/config/_default/config.yaml index bc1352cec9..164daaf35a 100644 --- a/sites/friday/config/_default/config.yaml +++ b/sites/friday/config/_default/config.yaml @@ -65,7 +65,6 @@ module: - "development/local/docksal.md" - "development/local/lando.md" - "development/deploy-button.md" - - "development/sanitize-db/mariadb.md" - "domains/cdn/managed-fastly.md" - "domains/security/web-application-firewall/fastly.md" - "domains/steps/custom-domains-preview-environments.md" diff --git a/sites/platform/src/development/private-repository.md b/sites/platform/src/development/private-repository.md index a007a236c5..c0d9f2c9fc 100644 --- a/sites/platform/src/development/private-repository.md +++ b/sites/platform/src/development/private-repository.md @@ -35,12 +35,25 @@ This means you can access the private repository through links like: git@{{% variable "GIT_PROVIDER" %}}:{{% variable "PATH_OR_USERNAME" %}}/{{% variable "REPOSITORY" %}}.git. For example, you can clone a repository in your [`build` hook](../create-apps/hooks/_index.md): +{{% version/specific %}} + ```yaml {configFile="app"} hooks: build: | set -e git clone git@bitbucket.org:username/module.git ``` +<---> + +```yaml {configFile="app"} +applications: + {{< variable "APP_NAME" >}}: + hooks: + build: | + set -e + git clone git@bitbucket.org:username/module.git +``` +{{% /version/specific %}} You can also use [private repositories as submodules](./submodules.md#use-private-git-repositories). diff --git a/sites/platform/src/development/submodules.md b/sites/platform/src/development/submodules.md index ebe83e3a09..f769c96d1e 100644 --- a/sites/platform/src/development/submodules.md +++ b/sites/platform/src/development/submodules.md @@ -10,6 +10,8 @@ sidebarTitle: "Git submodules" They're usually listed in a `.gitmodules` file at the root of your Git repository. When you push via Git, {{% vendor/name %}} tries to clone them automatically. +{{% version/specific %}} + The following example is based on [a Bigfoot multi-app project](https://github.com/platformsh-templates/bigfoot-multiapp/tree/multiapp-subfolders-applications) which uses the following submodules: - A [BigFoot app](https://github.com/platformsh-templates/bigfoot-multiapp-api/tree/without-platform-app-yaml) @@ -18,18 +20,28 @@ The following example is based on [a Bigfoot multi-app project](https://github.c - A [Mercure Rocks server](https://github.com/platformsh-templates/bigfoot-multiapp-mercure/tree/without-platform-app-yaml) ![Diagram of a project containing multiple apps](/images/config-diagrams/multiple-app.png "0.5") +<---> + +Say you have a multi-app project that includes the following submodules: + +- A BigFoot app +- An API Platform v3, Admin component +- A Gatsby frontend +- A Mercure Rocks server + +{{% /version/specific %}} To import all the submodules, run the following commands from your multiple application project's root folder: ```bash -$ touch .gitmodules -$ git submodule add --name admin https://github.com/platformsh-templates/bigfoot-multiapp-admin.git admin -$ git submodule add --name api https://github.com/platformsh-templates/bigfoot-multiapp-api.git api -$ git submodule add --name gatsby https://github.com/platformsh-templates/bigfoot-multiapp-gatsby.git gatsby -$ git submodule add --name mercure https://github.com/platformsh-templates/bigfoot-multiapp-mercure.git mercure -$ git add . -$ git commit -m "Adding submodules for Bigfoot App, API Platform Admin, Gatsby frontend and Mercure Rocks server" -$ git push +touch .gitmodules +git submodule add --name admin https://github.com/platformsh-templates/bigfoot-multiapp-admin.git admin +git submodule add --name api https://github.com/platformsh-templates/bigfoot-multiapp-api.git api +git submodule add --name gatsby https://github.com/platformsh-templates/bigfoot-multiapp-gatsby.git gatsby +git submodule add --name mercure https://github.com/platformsh-templates/bigfoot-multiapp-mercure.git mercure +git add . +git commit -m "Adding submodules for Bigfoot App, API Platform Admin, Gatsby frontend and Mercure Rocks server" +git push ``` Here is an example of a `.gitmodules` file: @@ -82,11 +94,11 @@ When you amend your submodules' code, make sure your changes are applied by runn before redeploying: ```bash -$ git submodule update --remote [submodule] - Submodule path 'admin': checked out 'a020894cf94de6e79748890c942206bc7af752af' - Submodule path 'api': checked out 'dce6617cc2db159c1a871112909e9ea4121135ec' - Submodule path 'gatsby': checked out '012ab16b05f474278ad0f9916e1cb94fc9df5ba4' - Submodule path 'mercure': checked out '94ccae5055983004aa8ab2c17b1daabd0c0a4927' +git submodule update --remote [submodule] +Submodule path 'admin': checked out 'a020894cf94de6e79748890c942206bc7af752af' +Submodule path 'api': checked out 'dce6617cc2db159c1a871112909e9ea4121135ec' +Submodule path 'gatsby': checked out '012ab16b05f474278ad0f9916e1cb94fc9df5ba4' +Submodule path 'mercure': checked out '94ccae5055983004aa8ab2c17b1daabd0c0a4927' ``` {{< note >}} @@ -114,7 +126,10 @@ To do so, follow these steps: 1. Define a source operation.
    Add the following configuration to your `{{< vendor/configfile "apps" >}}` (or `{{< vendor/configfile "app" >}}`) file: - ```yaml + {{% version/specific %}} + + + ```yaml {configFile="app"} app: ... source: @@ -129,6 +144,26 @@ To do so, follow these steps: git commit -m "Updating submodules admin, api, gatsby and mercure" fi ``` + + <---> + + ```yaml {configFile="app"} + applications: + {{< variable "APP_NAME" >}}: + ... + source: + operations: + rebuild: + command: | + set -e + git submodule update --init --recursive + git submodule update --remote --checkout + git add admin api gatsby mercure + if ! git diff-index --quiet HEAD; then + git commit -m "Updating submodules admin, api, gatsby and mercure" + fi + ``` + {{% /version/specific %}} For multiple app projects, make sure you define your source operation in the configuration of an app whose source code **is not** in a submodule. @@ -137,6 +172,8 @@ To do so, follow these steps: Don't define routes so your app isn't exposed to the web. To define a source operation, add the following configuration to your [app configuration](/create-apps/app-reference): + {{% version/specific %}} + ```yaml {configFile="apps"} update-submodule: # The type of the application to build. @@ -164,6 +201,38 @@ To do so, follow these steps: fi # "git push" is automatic at the end of this command ``` + <---> + + ```yaml {configFile="app"} + applications: + {{< variable "APP_NAME" >}}: + update-submodule: + # The type of the application to build. + type: "nodejs:18" + + # The web key configures the web server running in front of your app. + web: + # Commands are run once after deployment to start the application process. + commands: + # The command to launch your app. If it terminates, it’s restarted immediately. + # As this app will handle source operation only, no need to keep it alive (sleep) + start: | + sleep infinity + # Information on the app's source code and operations that can be run on it. + source: + operations: + update-submodules: + command: | + set -e + git submodule update --init --recursive + git submodule update --remote --checkout + git add . + if ! git diff-index --quiet HEAD; then + git commit -m "Updating submodules" + fi + # "git push" is automatic at the end of this command + ``` + {{% /version/specific %}} 2. Run your source operation.
    @@ -253,34 +322,34 @@ These steps aren't specific to {{% vendor/name %}}, but kept as a reference for 1. In your `.gitmodules` and `.git/config` files, delete the information related to the submodule you want to remove. ```bash - $ git submodule deinit -f path_to_submodule - ``` + git submodule deinit -f path_to_submodule + ``` 2. Stage changes to `.gitmodules`: ```bash - $ git add .gitmodules + git add .gitmodules ``` 3. Remove the submodule from the repository (without trailing slash): ```bash - $ git rm --cached path_to_submodule + git rm --cached path_to_submodule ``` 4. Remove the submodule files in `.git` from the repository (without trailing slash): ```bash - $ rm -rf .git/modules/path_to_submodule + rm -rf .git/modules/path_to_submodule ``` 5. Commit the changes: ```bash - $ git commit -m "Removed submodule." + git commit -m "Removed submodule." ``` 6. Remove the submodule code locally, now no longer tracked: ```bash - $ rm -rf path_to_submodule + rm -rf path_to_submodule ``` diff --git a/sites/platform/src/development/variables/_index.md b/sites/platform/src/development/variables/_index.md index af1fd43ede..4800f7947d 100644 --- a/sites/platform/src/development/variables/_index.md +++ b/sites/platform/src/development/variables/_index.md @@ -71,7 +71,7 @@ For an example of how the different levels work, suppose you have the following inheritable variables defined for the `main` environment: ```sh -$ {{% vendor/cli %}} var -e main +{{% vendor/cli %}} var -e main Variables on the project Example (abcdef123456), environment main: +----------------+-------------+--------+---------+ | Name | Level | Value | Enabled | @@ -86,7 +86,7 @@ Variables on the project Example (abcdef123456), environment main: And the following variables defined for the `feature-x` environment, a child environment of `main`: ```sh -$ {{% vendor/cli %}} var -e feature-x +{{% vendor/cli %}} var -e feature-x Variables on the project Example (abcdef123456), environment feature-x: +----------------+-------------+--------+---------+ | Name | Level | Value | Enabled | @@ -180,9 +180,11 @@ To use variables across environments, set them in your [app configuration](../.. For example, to change the PHP memory limit for all environments, use the following configuration: ```yaml {configFile="app"} -variables: - php: - memory_limit: "256M" +applications: + {{< variable "APP_NAME" >}}: + variables: + php: + memory_limit: "256M" ``` ### Framework-specific variables diff --git a/sites/platform/src/development/variables/use-variables.md b/sites/platform/src/development/variables/use-variables.md index e314e5d96d..36854599e1 100644 --- a/sites/platform/src/development/variables/use-variables.md +++ b/sites/platform/src/development/variables/use-variables.md @@ -185,7 +185,9 @@ public class App { Variables can have nested structures. The following example shows nested structures in an [app configuration](../../create-apps/app-reference.md#variables): -```yaml +{{% version/specific %}} + +```yaml {configFile="app"} variables: env: BASIC: "a string" @@ -202,6 +204,28 @@ variables: green: '#00FF00' blue: '#0000FF' ``` +<---> + +```yaml {configFile="app"} +applications: + {{< variable "APP_NAME" >}}: + variables: + env: + BASIC: "a string" + INGREDIENTS: + - 'peanut butter' + - 'jelly' + QUANTITIES: + "milk": "1 liter" + "cookies": "1 kg" + stuff: + STEPS: ['one', 'two', 'three'] + COLORS: + red: '#FF0000' + green: '#00FF00' + blue: '#0000FF' +``` +{{% /version/specific %}} You can access these nested variables as follows: @@ -409,13 +433,8 @@ The `PLATFORM_APPLICATION` variable is available both at build time and in the r But the specific attributes it contains differ in each case. Each environment's build is associated with a configuration ID that identifies it uniquely so builds can be reused. -<<<<<<< HEAD -The ID is a product of your app code and some of its [configuration for {{< vendor/name >}}](../../create-apps/_index.md). -Not every attribute inyour app configuration is relevant to the build. -======= The ID is a product of your app code and some of its [configuration for {{% vendor/name %}}](../../create-apps/_index.md). Not every attribute your app configuration is relevant to the build. ->>>>>>> origin/main Only those attributes that are relevant to builds are accessible at build time from `PLATFORM_APPLICATION`. Attributes that are **not** available in `PLATFORM_APPLICATION` during builds: @@ -447,15 +466,27 @@ One workaround is to create a symbolic link to a writable location and then writ The following example shows the process, though you have to modify it to fit your needs. 1. Create a mount that isn't accessible to the web in your [app configuration](../../create-apps/_index.md): - - ```yaml + {{% version/specific %}} + + ```yaml {configFile="app"} mounts: /config: source: local source_path: config ``` + <---> + + ```yaml {configFile="app"} + applications: + {{< variable "APP_NAME" >}} + mounts: + /config: + source: local + source_path: config + ``` + {{% /version/specific %}} -1. Create a symbolic link from the config file the application wants to a location in that mount: +2. Create a symbolic link from the config file the application wants to a location in that mount: ```bash # From the application root... @@ -464,8 +495,8 @@ The following example shows the process, though you have to modify it to fit you ``` This example assumes the app wants a `db.yaml` file in its root for configuration. -1. Commit the symbolic link and an empty `config` directory to Git. -1. Configure a script to read from environment variables and write to `config/db.yaml`. +3. Commit the symbolic link and an empty `config` directory to Git. +4. Configure a script to read from environment variables and write to `config/db.yaml`. Create a file with a shell script similar to this: ```bash {location="export-config.sh"} @@ -481,13 +512,24 @@ The following example shows the process, though you have to modify it to fit you printf "user: %s\n" $(echo $PLATFORM_RELATIONSHIPS | base64 --decode | jq -r ".database[0].username") >> config/db.yaml ``` -1. Call the script from the `deploy` hook your [app configuration](../../create-apps/_index.md): - - ```yaml +5. Call the script from the `deploy` hook your [app configuration](../../create-apps/_index.md): + {{% version/specific %}} + + ```yaml {configFile="app"} hooks: deploy: | bash export-config.sh ``` + <---> + + ```yaml {configFile="app"} + applications: + {{< variable "APP_NAME" >}} + hooks: + deploy: | + bash export-config.sh + ``` + {{% /version/specific %}} Now, when your app starts and attempts to parse `db.yaml`, the symbolic link redirects it to `config/db.yaml`. Your script writes to that file on each deploy with updated information. diff --git a/themes/psh-docs/layouts/shortcodes/local-dev/next-steps-end.md b/themes/psh-docs/layouts/shortcodes/local-dev/next-steps-end.md index a625605a06..10a42ff58c 100644 --- a/themes/psh-docs/layouts/shortcodes/local-dev/next-steps-end.md +++ b/themes/psh-docs/layouts/shortcodes/local-dev/next-steps-end.md @@ -10,7 +10,7 @@ any user can set up their local environment by running the following commands: ```bash - {{ `$ {{< vendor/cli >}} {{< variable "PROJECT_ID" >}}` | .Page.RenderString }} - {{ `$ cd {{< variable "PROJECT_NAME" >}}` | .Page.RenderString }} - {{ `$ ./init-local.sh {{< variable "PROJECT_ID" >}} another-new-feature {{< variable "PRODUCTION_ENVIRONMENT_NAME" >}}` | .Page.RenderString }} + {{ `{{< vendor/cli >}} {{< variable "PROJECT_ID" >}}` | .Page.RenderString }} + {{ `cd {{< variable "PROJECT_NAME" >}}` | .Page.RenderString }} + {{ `./init-local.sh {{< variable "PROJECT_ID" >}} another-new-feature {{< variable "PRODUCTION_ENVIRONMENT_NAME" >}}` | .Page.RenderString }} ``` diff --git a/themes/psh-docs/layouts/shortcodes/sanitize-dbs/sanitize-manually.md b/themes/psh-docs/layouts/shortcodes/sanitize-dbs/sanitize-manually.md index ec233393ae..73f7250132 100644 --- a/themes/psh-docs/layouts/shortcodes/sanitize-dbs/sanitize-manually.md +++ b/themes/psh-docs/layouts/shortcodes/sanitize-dbs/sanitize-manually.md @@ -25,7 +25,7 @@ Assumptions: Run the following query: ```sql - $ {{ $query }} + {{ $query }} ``` You see output like the following: @@ -51,6 +51,8 @@ Assumptions: You can create a script to automate the sanitization process to be run automatically on each new deployment. Once you have a working script, add your script to sanitize the database to [a `deploy` hook](../../create-apps/hooks/hooks-comparison.md#deploy-hook): +{{ if eq .Page.Site.Params.vendor.config.version 1 }} + ```yaml {configFile="app"} hooks: deploy: | @@ -63,23 +65,21 @@ Assumptions: fi ``` - To sanitize only on the initial deploy and not all future deploys, - on sanitization create a file on a [mount](/create-apps/app-reference.md#mounts). - Then add a check for the file as in the following example: +{{ else }} ```yaml {configFile="app"} - hooks: - deploy: | - cd /app/public - if [ "$PLATFORM_ENVIRONMENT_TYPE" = production ]; then - # Do whatever you want on the production site. - else - # Check if the database has been sanitized yet - if [ ! -f {{ `{{< variable "MOUNT_PATH" >}}/is_sanitized` | .Page.RenderString }} ]; then - # Sanitize your database here - sanitize_the_database.sh - # Create a record that sanitization has happened - touch {{ `{{< variable "MOUNT_PATH" >}}/is_sanitized` | .Page.RenderString }} - fi - fi + applications: + myapp: + ... + hooks: + deploy: | + cd /app/public + if [ "$PLATFORM_ENVIRONMENT_TYPE" = production ]; then + # Do whatever you want on the production site. + else + # The sanitization of the database should happen here (since it's non-production) + sanitize_the_database.sh + fi ``` + +{{ end }} \ No newline at end of file From 22b4632c85914fb029f418ba1a13f8b646b9c0de Mon Sep 17 00:00:00 2001 From: chadcarlson Date: Tue, 26 Sep 2023 11:35:40 -0400 Subject: [PATCH 3/4] Fix submodule codetab formatting. --- sites/platform/src/development/submodules.md | 143 ++++++------------- 1 file changed, 43 insertions(+), 100 deletions(-) diff --git a/sites/platform/src/development/submodules.md b/sites/platform/src/development/submodules.md index f769c96d1e..4bc10a0962 100644 --- a/sites/platform/src/development/submodules.md +++ b/sites/platform/src/development/submodules.md @@ -126,45 +126,22 @@ To do so, follow these steps: 1. Define a source operation.
    Add the following configuration to your `{{< vendor/configfile "apps" >}}` (or `{{< vendor/configfile "app" >}}`) file: - {{% version/specific %}} - - - ```yaml {configFile="app"} - app: - ... - source: - operations: - rebuild: - command: | - set -e - git submodule update --init --recursive - git submodule update --remote --checkout - git add admin api gatsby mercure - if ! git diff-index --quiet HEAD; then - git commit -m "Updating submodules admin, api, gatsby and mercure" - fi - ``` - - <---> - - ```yaml {configFile="app"} - applications: - {{< variable "APP_NAME" >}}: - ... - source: - operations: - rebuild: - command: | - set -e - git submodule update --init --recursive - git submodule update --remote --checkout - git add admin api gatsby mercure - if ! git diff-index --quiet HEAD; then - git commit -m "Updating submodules admin, api, gatsby and mercure" - fi - ``` - {{% /version/specific %}} - +```yaml {configFile="app"} +{{< snippet name="myapp" config="app" root="false" >}} +source: + operations: + rebuild: + command: | + set -e + git submodule update --init --recursive + git submodule update --remote --checkout + git add admin api gatsby mercure + if ! git diff-index --quiet HEAD; then + git commit -m "Updating submodules admin, api, gatsby and mercure" + fi +{{< /snippet >}} +``` + For multiple app projects, make sure you define your source operation in the configuration of an app whose source code **is not** in a submodule. @@ -172,67 +149,33 @@ To do so, follow these steps: Don't define routes so your app isn't exposed to the web. To define a source operation, add the following configuration to your [app configuration](/create-apps/app-reference): - {{% version/specific %}} - - ```yaml {configFile="apps"} - update-submodule: - # The type of the application to build. - type: "nodejs:18" - - # The web key configures the web server running in front of your app. - web: - # Commands are run once after deployment to start the application process. - commands: - # The command to launch your app. If it terminates, it’s restarted immediately. - # As this app will handle source operation only, no need to keep it alive (sleep) - start: | - sleep infinity - # Information on the app's source code and operations that can be run on it. - source: - operations: - update-submodules: - command: | - set -e - git submodule update --init --recursive - git submodule update --remote --checkout - git add . - if ! git diff-index --quiet HEAD; then - git commit -m "Updating submodules" - fi - # "git push" is automatic at the end of this command - ``` - <---> - - ```yaml {configFile="app"} - applications: - {{< variable "APP_NAME" >}}: - update-submodule: - # The type of the application to build. - type: "nodejs:18" - - # The web key configures the web server running in front of your app. - web: - # Commands are run once after deployment to start the application process. - commands: - # The command to launch your app. If it terminates, it’s restarted immediately. - # As this app will handle source operation only, no need to keep it alive (sleep) - start: | - sleep infinity - # Information on the app's source code and operations that can be run on it. - source: - operations: - update-submodules: - command: | - set -e - git submodule update --init --recursive - git submodule update --remote --checkout - git add . - if ! git diff-index --quiet HEAD; then - git commit -m "Updating submodules" - fi - # "git push" is automatic at the end of this command - ``` - {{% /version/specific %}} +```yaml {configFile="app"} +{{< snippet name="update-submodule" config="app" root="false" >}} +# The type of the application to build. +type: 'nodejs:{{% latest "nodejs" %}}' + +# The web key configures the web server running in front of your app. +web: + # Commands are run once after deployment to start the application process. + commands: + # The command to launch your app. If it terminates, it’s restarted immediately. + # As this app will handle source operation only, no need to keep it alive (sleep) + start: | + sleep infinity +source: + operations: + update-submodules: + command: | + set -e + git submodule update --init --recursive + git submodule update --remote --checkout + git add . + if ! git diff-index --quiet HEAD; then + git commit -m "Updating submodules" + fi + # "git push" is automatic at the end of this command +{{< /snippet >}} +``` 2. Run your source operation.
    From 81c76d1bfb32aed0d94d0dfed65ae88f1a88855e Mon Sep 17 00:00:00 2001 From: chadcarlson Date: Tue, 26 Sep 2023 11:41:40 -0400 Subject: [PATCH 4/4] Review feedback. --- sites/platform/src/development/local/docksal.md | 3 +-- sites/platform/src/development/local/lando.md | 2 +- sites/platform/src/development/local/tethered.md | 1 + sites/platform/src/development/ssh/troubleshoot-ssh.md | 2 +- sites/platform/src/development/submodules.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sites/platform/src/development/local/docksal.md b/sites/platform/src/development/local/docksal.md index 9207f22ae1..92f35e7158 100644 --- a/sites/platform/src/development/local/docksal.md +++ b/sites/platform/src/development/local/docksal.md @@ -1,8 +1,7 @@ --- title: Use Docksal for local development sidebarTitle: Docksal -weight: 1 -sectionBefore: Supported environments +weight: 3 --- [Docksal](https://docksal.io) is a Docker-based local development tool that plays nicely with {{% vendor/name %}}. diff --git a/sites/platform/src/development/local/lando.md b/sites/platform/src/development/local/lando.md index 42a57a1a46..061185256c 100644 --- a/sites/platform/src/development/local/lando.md +++ b/sites/platform/src/development/local/lando.md @@ -2,7 +2,7 @@ title: Use Lando for local development sidebarTitle: "Lando" description: Find out how to include Lando in your local development workflow. -weight: 1 +weight: 3 --- [Lando](https://docs.lando.dev) is a third-party local development tool for which several stacks are available (LAMP, LEMP, MEAN). diff --git a/sites/platform/src/development/local/tethered.md b/sites/platform/src/development/local/tethered.md index 688098c7e4..02481b7c98 100644 --- a/sites/platform/src/development/local/tethered.md +++ b/sites/platform/src/development/local/tethered.md @@ -1,6 +1,7 @@ --- title: Tethered local development sidebarTitle: Tethered +sectionBefore: Supported environments weight: 2 --- diff --git a/sites/platform/src/development/ssh/troubleshoot-ssh.md b/sites/platform/src/development/ssh/troubleshoot-ssh.md index e5e344c2ce..20a7aa9063 100644 --- a/sites/platform/src/development/ssh/troubleshoot-ssh.md +++ b/sites/platform/src/development/ssh/troubleshoot-ssh.md @@ -156,4 +156,4 @@ You can use this information to make one last check of the private key file. {{% troubleshoot %}} -If you're still stuck, [submit a support ticket and provide the full SSH debug information](https://console.platform.sh/-/users/:user/tickets). \ No newline at end of file +If you're still stuck, [submit a support ticket and provide the full SSH debug information](https://console.{{% vendor/urlraw "host" %}}/-/users/:user/tickets). diff --git a/sites/platform/src/development/submodules.md b/sites/platform/src/development/submodules.md index 4bc10a0962..1492b96a8c 100644 --- a/sites/platform/src/development/submodules.md +++ b/sites/platform/src/development/submodules.md @@ -124,7 +124,7 @@ Automate your submodule updates using a [source operation](create-apps/source-op To do so, follow these steps: 1. Define a source operation.
    - Add the following configuration to your `{{< vendor/configfile "apps" >}}` (or `{{< vendor/configfile "app" >}}`) file: + Add the following configuration to your `{{< vendor/configfile "app" >}}` file: ```yaml {configFile="app"} {{< snippet name="myapp" config="app" root="false" >}}