An open API service indexing awesome lists of open source software.

https://github.com/upsun/snippets


https://github.com/upsun/snippets

Last synced: over 1 year ago
JSON representation

Awesome Lists containing this project

README

          





logo




Upsun Template Snippets


Contribute to the Upsun knowledge base, or check out our resources




Join our Discord community&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
Blog&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
Documentation&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp



Upsun maintains a list of scripts that may be used within the template to ease its fine-tuning.

## Contents:
* [`raw.githubusercontent.com rate limit`](#rawgithubusercontentcom-rate-limit)
* [`Install FrankenPHP`](#install-frankenphp)

[//]: # (* [`Install a specific version of Node on non-Node JS container`](#Install-a-specific-version-of-Node-on-non-Node-JS-container))

[//]: # (* [`Upsunify script`](#upsunify-script))

[//]: # (* [`Install Swoole`](#install-swoole))

### raw.githubusercontent.com rate limit

On rare occasion, the rate limit on `raw.githubusercontent.com` my be hit. It can
then be recommended to use a [Personal Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) to benefit
from a much higher rate limit.

```
curl -H "Authorization: Bearer PERSONAL_TOKEN" -fsS https://raw.githubusercontent.com/upsun/snippets/main/src/script.sh | { bash /dev/fd/3 PARAMETERS; } 3<&0
```

[//]: # (### Install a specific version of Node on non-Node JS container)

[//]: # ()
[//]: # (The [documentation](https://docs.upsun.com/get-started/here/configure/nodejs.html) describes how)

[//]: # (to specify the Node version to use and/or how to add Yarn to the NodeJS container.)

[//]: # ()
[//]: # (For other containers, such as the PHP one, it may be needed to rely on a specific)

[//]: # (version of NodeJS, and use Yarn as well.)

[//]: # ()
[//]: # (#### Install the LTS version of node)

[//]: # (```)

[//]: # (export N_PREFIX=$HOME/.n)

[//]: # (export PATH=$N_PREFIX/bin:$PATH)

[//]: # (curl -fsS https://raw.githubusercontent.com/upsun/snippets/main/src/install_node.sh | { bash /dev/fd/3 -v lts; } 3<&0)

[//]: # (```)

[//]: # ()
[//]: # (#### Install the 17.5 version of node with Yarn)

[//]: # (```)

[//]: # (export N_PREFIX=$HOME/.n)

[//]: # (export PATH=$N_PREFIX/bin:$PATH)

[//]: # (curl -fsS https://raw.githubusercontent.com/upsun/snippets/main/src/install_node.sh | { bash /dev/fd/3 -v 17.5 -y; } 3<&0)

[//]: # (```)

[//]: # ()
[//]: # (#### Use)

[//]: # ()
[//]: # (An example build hook is listed below. If using this snippet, do not add `corepack` as a [build dependency as outlined in the Upsun documentation](https://docs.upsun.com/get-started/here/configure/nodejs.html#use-yarn-as-a-package-manager), as it is already done for you. With the `-y` flag, the hook below will install Node.js 14.19.0 along with Yarn, afterwhich yarn commands can be run through corepack.)

[//]: # ()
[//]: # (```yaml)

[//]: # (name: app)

[//]: # (type: php:8.0)

[//]: # (dependencies:)

[//]: # ( php:)

[//]: # ( composer/composer: '^2')

[//]: # (variables:)

[//]: # ( env:)

[//]: # ( NODE_VERSION: v14.19.0)

[//]: # (build:)

[//]: # ( flavor: none)

[//]: # (hooks:)

[//]: # ( build: |)

[//]: # ( set -e )

[//]: # ( composer install)

[//]: # ( )
[//]: # ( export N_PREFIX=$HOME/.n)

[//]: # ( export PATH=$N_PREFIX/bin:$PATH)

[//]: # ( curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/install_node.sh | { bash /dev/fd/3 -v $NODE_VERSION -y; } 3<&0)

[//]: # ( )
[//]: # ( PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 corepack yarn install)

[//]: # ( PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 corepack yarn packages:build)

[//]: # ( corepack yarn run less)

[//]: # ( corepack yarn run webpack)

[//]: # (```)

[//]: # ()
[//]: # (> **Note:**)

[//]: # (>)

[//]: # (> By default, `n` will try and install to `/usr/local/n`, which is not allowed on Platform.sh. You can instead specify the install location using the [variable `N_PREFIX` and then adding to `PATH`](https://github.com/tj/n#optional-environment-variables). If you will also need `n` outside of the build hook, add the two `export` lines to `.environment` as well. )

[//]: # (### Upsunify script)

[//]: # ()
[//]: # (The `upsunify` script will generate the `.upsun/config.yaml` file and all the)

[//]: # (files needed to run a specific project on Upsun.)

[//]: # ()
[//]: # (To platformify a Laravel project:)

[//]: # (```)

[//]: # (curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/platformify.sh | { bash /dev/fd/3 -t laravel ; } 3<&0)

[//]: # (```)

[//]: # ()
[//]: # (To platformify a Laravel project and a speficic folder:)

[//]: # (```)

[//]: # (curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/platformify.sh | { bash /dev/fd/3 -t laravel -p path/to/dir ; } 3<&0)

[//]: # (```)

[//]: # ()
[//]: # (When ran on an empty folder, the script will clone the full template.)

[//]: # ()
[//]: # (### Install Swoole)

[//]: # ()
[//]: # (The `install_swoole` script will install and enable the Swoole or Open Swoole extension in a PHP container.)

[//]: # ()
[//]: # (To install Open Swoole v4.11.0:)

[//]: # (```)

[//]: # (curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/install_swoole.sh | { bash /dev/fd/3 openswoole 4.11.0 ; } 3<&0)

[//]: # (```)

[//]: # ()
[//]: # (To install Swoole v4.8.10:)

[//]: # (```)

[//]: # (curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/install_swoole.sh | { bash /dev/fd/3 swoole 4.8.10 ; } 3<&0)

[//]: # (```)

[//]: # ()
[//]: # (### Install Relay (Redis))

[//]: # ()
[//]: # (The `install-relay` script will install and enable the [Relay](https://relay.so) extension in a PHP container.)

[//]: # ()
[//]: # (To install Relay v0.6.0:)

[//]: # (Note the version should be prefixed with `v` (**v**0.6.0))

[//]: # (```)

[//]: # (curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/install-relay.sh | { bash /dev/fd/3 v0.6.0 ; } 3<&0)

[//]: # (```)

[//]: # ()
[//]: # (To install Relay @dev:)

[//]: # (```)

[//]: # (curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/install-relay.sh | { bash /dev/fd/3 dev ; } 3<&0)

[//]: # (```)

[//]: # ()
[//]: # (### Install PhpRedis (Redis))

[//]: # ()
[//]: # (The `install-phpredis` script will install and enable the [PhpRedis](https://github.com/phpredis/phpredis) extension in a PHP container.)

[//]: # ()
[//]: # (To install PhpRedis v5.1.1:)

[//]: # (```)

[//]: # (curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/install-phpredis.sh | { bash /dev/fd/3 5.1.1 ; } 3<&0)

[//]: # (```)

### Install FrankenPHP
To install FrankenPHP only once on your project:
```shell
curl -fsS https://raw.githubusercontent.com/upsun/snippets/main/src/install-frankenphp.sh | { bash /dev/fd/3 5.1.1 ; } 3<&0
```

### Blackfire notifier (Activity script)
This [activity script](src/blackfire-notifier.js) creates an event Marker on Blackfire side.
This script is meant to be integrated with your Upsun project.