-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding platformsh configuration files.
- Loading branch information
1 parent
05fa15d
commit 41a566d
Showing
6 changed files
with
338 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# Complete list of all available properties: https://docs.platform.sh/create-apps/app-reference.html | ||
|
||
# This file describes an application. You can have multiple applications | ||
# in the same project. | ||
|
||
# The name of this app. Must be unique within a project. | ||
- name: api | ||
source: | ||
root: api | ||
|
||
variables: | ||
env: | ||
APP_ENV: 'prod' | ||
|
||
dependencies: | ||
php: | ||
composer/composer: "^2" | ||
|
||
# The type of the application to build. | ||
type: php:8.1 | ||
build: | ||
flavor: composer | ||
|
||
runtime: | ||
extensions: | ||
- apcu | ||
- pdo_pgsql | ||
- sodium | ||
- redis | ||
|
||
# The relationships of the application with services or other applications. | ||
# The left-hand side is the name of the relationship as it will be exposed | ||
# to the application in the PLATFORM_RELATIONSHIPS variable. The right-hand | ||
# side is in the form `<service name>:<endpoint name>`. | ||
relationships: | ||
database: "postgresql:postgresql" | ||
opensearch: "opensearch:opensearch" | ||
redis: "redis:redis" | ||
|
||
# The configuration of app when it is exposed to the web . | ||
web: | ||
locations: | ||
"/": | ||
# The public directory of the app, relative to its root. | ||
root: "public" | ||
# The front-controller script to send non-static requests to. | ||
passthru: "/index.php" | ||
|
||
# The size of the persistent disk of the application (in MB). | ||
disk: 2048 | ||
|
||
# The mounts that will be performed when the package is deployed. | ||
mounts: | ||
"/var/cache": "shared:files/cache" | ||
"/var/log": "shared:files/log" | ||
"/var/sessions": "shared:files/sessions" | ||
|
||
# The hooks that will be performed when the package is deployed. | ||
hooks: | ||
build: | | ||
bin/console lexik:jwt:generate-keypair --skip-if-exists --no-interaction | ||
bin/console --env=prod assets:install --no-debug | ||
deploy: | | ||
bin/console --env=prod cache:clear | ||
bin/console doctrine:migrations:migrate -n --allow-no-migration | ||
# A unique name for the app. Must be lowercase alphanumeric characters. Changing the name destroys data associated | ||
# with the app. | ||
- name: admin | ||
|
||
# Information on the app's source code and operations that can be run on it. | ||
# More information: https://docs.platform.sh/create-apps/app-reference.html#source | ||
source: | ||
root: front | ||
|
||
# The runtime the application uses. | ||
# Complete list of available runtimes: https://docs.platform.sh/create-apps/app-reference.html#types | ||
type: 'nodejs:18' | ||
|
||
# The size of the persistent disk of the application (in MB). Minimum value is 128. | ||
disk: 2048 | ||
|
||
# Mounts define directories that are writable after the build is complete. If set as a local source, disk property is required. | ||
# More information: https://docs.platform.sh/create-apps/app-reference.html#mounts | ||
mounts: | ||
# Next.js will try to cache files, so it must be writeable. | ||
'/.next': | ||
source: local | ||
source_path: 'next' | ||
|
||
# The web key configures the web server running in front of your app. | ||
# More information: https://docs.platform.sh/create-apps/app-reference.html#web | ||
web: | ||
# Commands are run once after deployment to start the application process. | ||
# More information: https://docs.platform.sh/create-apps/app-reference.html#web-commands | ||
commands: | ||
# The command to launch your app. If it terminates, it’s restarted immediately. | ||
#start: npx next start -p $PORT | ||
start: yarn start | ||
|
||
# Specifies a default set of build tasks to run. Flavors are language-specific. | ||
# More information: https://docs.platform.sh/create-apps/app-reference.html#build | ||
build: | ||
flavor: none | ||
|
||
# Installs global dependencies as part of the build process. They’re independent of your app’s dependencies and | ||
# are available in the PATH during the build process and in the runtime environment. They’re installed before | ||
# the build hook runs using a package manager for the language. | ||
# More information: https://docs.platform.sh/create-apps/app-reference.html#dependencies | ||
dependencies: | ||
nodejs: | ||
yarn: "^1.22.0" | ||
|
||
# Hooks allow you to customize your code/environment as the project moves through the build and deploy stages | ||
# More information: https://docs.platform.sh/create-apps/app-reference.html#hooks | ||
hooks: | ||
# The build hook is run after any build flavor. | ||
# More information: https://docs.platform.sh/create-apps/hooks/hooks-comparison.html#build-hook | ||
build: | | ||
yarn | ||
yarn install --frozen-lockfile --network-timeout 120000 | ||
yarn build | ||
# Move committed files in soon-to-be mounts into temp directory. | ||
chmod +x platformsh_handle_mounts.sh | ||
./platformsh_handle_mounts.sh | ||
# The deploy hook is run after the app container has been started, but before it has started accepting requests. | ||
# More information: https://docs.platform.sh/create-apps/hooks/hooks-comparison.html#deploy-hook | ||
deploy: | | ||
# Move committed files from temp directory back into mounts. | ||
./platformsh_handle_mounts.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
https://{default}/: | ||
cache: | ||
cookies: | ||
- '*' | ||
default_ttl: 0 | ||
enabled: true | ||
headers: | ||
- Accept | ||
- Accept-Language | ||
ssi: | ||
enabled: false | ||
type: upstream | ||
upstream: api:http | ||
|
||
https://{default}/admin: | ||
cache: | ||
cookies: | ||
- '*' | ||
default_ttl: 0 | ||
enabled: true | ||
headers: | ||
- Accept | ||
- Accept-Language | ||
ssi: | ||
enabled: false | ||
type: upstream | ||
upstream: admin:http | ||
|
||
https://{default}/login: | ||
cache: | ||
cookies: | ||
- '*' | ||
default_ttl: 0 | ||
enabled: true | ||
headers: | ||
- Accept | ||
- Accept-Language | ||
ssi: | ||
enabled: false | ||
type: upstream | ||
upstream: admin:http | ||
|
||
https://{default}/_next: | ||
cache: | ||
cookies: | ||
- '*' | ||
default_ttl: 0 | ||
enabled: true | ||
headers: | ||
- Accept | ||
- Accept-Language | ||
ssi: | ||
enabled: false | ||
type: upstream | ||
upstream: admin:http | ||
|
||
https://{default}/locales: | ||
cache: | ||
cookies: | ||
- '*' | ||
default_ttl: 0 | ||
enabled: true | ||
headers: | ||
- Accept | ||
- Accept-Language | ||
ssi: | ||
enabled: false | ||
type: upstream | ||
upstream: admin:http | ||
|
||
https://{default}/images: | ||
cache: | ||
cookies: | ||
- '*' | ||
default_ttl: 0 | ||
enabled: true | ||
headers: | ||
- Accept | ||
- Accept-Language | ||
ssi: | ||
enabled: false | ||
type: upstream | ||
upstream: admin:http |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
postgresql: | ||
type: postgresql:13 | ||
disk: 256 | ||
|
||
opensearch: | ||
type: opensearch:2 | ||
disk: 256 | ||
configuration: | ||
plugins: | ||
- analysis-icu | ||
- analysis-phonetic | ||
|
||
redis: | ||
type: redis-persistent:6.2 | ||
disk: 256 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
############################################################################################# | ||
#### Platform.sh environment file. | ||
#### THIS FILE IS USED ONLY WHEN DEPLOYING GALLY ON PLATFORM.SH | ||
############################################################################################# | ||
|
||
# Decode the built-in credentials object variable. | ||
# export RELATIONSHIPS_JSON=$(echo $PLATFORM_RELATIONSHIPS | base64 --decode) | ||
|
||
# Set environment variables for OpenSearch | ||
export ELASTICSEARCH_SCHEME=$(echo $PLATFORM_RELATIONSHIPS | base64 --decode | jq -r ".opensearch[0].scheme") | ||
export ELASTICSEARCH_HOST=$(echo $PLATFORM_RELATIONSHIPS | base64 --decode | jq -r ".opensearch[0].host") | ||
export ELASTICSEARCH_PORT=$(echo $PLATFORM_RELATIONSHIPS | base64 --decode | jq -r ".opensearch[0].port") | ||
|
||
# Surface more common OpenSearch connection string variables for use in app. | ||
export OPENSEARCH_USERNAME=$(echo $PLATFORM_RELATIONSHIPS | base64 --decode | jq -r ".opensearch[0].username") | ||
export OPENSEARCH_PASSWORD=$(echo $PLATFORM_RELATIONSHIPS | base64 --decode | jq -r ".opensearch[0].password") | ||
|
||
export ELASTICSEARCH_URL=$ELASTICSEARCH_SCHEME://$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT | ||
|
||
# Set environment variables for Postgre | ||
# DATABASE_URL="postgresql://api-platform:[email protected]:5432/api?serverVersion=13&charset=utf8" | ||
export DB_SCHEME=$(echo $PLATFORM_RELATIONSHIPS | base64 --decode | jq -r ".database[0].service") | ||
export DB_HOST=$(echo $PLATFORM_RELATIONSHIPS | base64 --decode | jq -r ".database[0].host") | ||
export DB_PORT=$(echo $PLATFORM_RELATIONSHIPS | base64 --decode | jq -r ".database[0].port") | ||
export DB_USERNAME=$(echo $PLATFORM_RELATIONSHIPS | base64 --decode | jq -r ".database[0].username") | ||
export DB_PASSWORD=$(echo $PLATFORM_RELATIONSHIPS | base64 --decode | jq -r ".database[0].password") | ||
|
||
export DATABASE_URL=$DB_SCHEME://$DB_USERNAME:$DB_PASSWORD@$DB_HOST:$DB_PORT/main?serverVersion=13 | ||
|
||
# Set environment variables for Redis | ||
export REDIS_SERVER=$(echo $PLATFORM_RELATIONSHIPS | base64 --decode | jq -r ".redis[0].host") | ||
|
||
export TRUSTED_HOSTS=^$PLATFORM_ENVIRONMENT-$PLATFORM_PROJECT.eu.platformsh.site$ | ||
export SERVER_NAME=$PLATFORM_ENVIRONMENT-$PLATFORM_PROJECT.eu.platformsh.site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
############################################################################################# | ||
#### Platform.sh environment file. | ||
#### THIS FILE IS USED ONLY WHEN DEPLOYING GALLY ON PLATFORM.SH | ||
############################################################################################# | ||
|
||
export SERVER_NAME=api.$PLATFORM_ENVIRONMENT-$PLATFORM_PROJECT.eu.platformsh.site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This is a simple script for handling committed files and mounts on Platform.sh. Some application require write access to certain locations | ||
# at runtime, and must be defined with mounts (https://docs.platform.sh/configuration/app/storage.html#mounts). One consequence of defining a | ||
# location as a mount, however, is that when the location is mounted during the deploy hook, any files that may have been committed or modified | ||
# during the build hook there will be overwritten by whatever exists in persistent storage for that environment. | ||
# | ||
# This script stages those files in a tmp directory (MOUNT_TMP) during the build hook, and then recopies them to their final location during the | ||
# deploy hook to get around this. Call this script as the last line and first line in your build and deploy hooks, respectively. | ||
# | ||
# Limitations: | ||
# - Does not yet handles nested mounts well (i.e. `/.next/cache`), so best to use its parent directory in your mount definition (`/.next`). | ||
|
||
MOUNT_TMP=platformsh-mounts | ||
|
||
# Hidden mounts require a preceding slash (i.e. `/.next`). This function just removes it to make the path work right. | ||
# See: https://docs.platform.sh/configuration/app/storage.html#why-cant-i-mount-a-hidden-folder | ||
clean_mount_defn(){ | ||
MOUNT=$1 | ||
if [[ ${MOUNT:0:1} == "/" ]] ; then echo "${MOUNT:1}"; else echo $MOUNT; fi | ||
} | ||
|
||
# During the build hook, this function moves files committed to the same directory as one defined in `.platform.app.yaml` | ||
# as a mount to the tmp directory MOUNT_TMP. | ||
stage_files() { | ||
MOUNT=`clean_mount_defn $1` | ||
# Create the tmp directory (MOUNT_TMP) on the first pass only. (/app/platformsh-mounts on Platform.sh) | ||
if [ -d $PLATFORM_APP_DIR/$MOUNT_TMP ]; then | ||
mkdir $PLATFORM_APP_DIR/$MOUNT_TMP | ||
fi | ||
# Duplicate the mount directory in MOUNT_TMP. | ||
mkdir -p $PLATFORM_APP_DIR/$MOUNT_TMP/$MOUNT-tmp | ||
# Move its files. | ||
mv $PLATFORM_APP_DIR/$MOUNT/* $PLATFORM_APP_DIR/$MOUNT_TMP/$MOUNT-tmp | ||
} | ||
|
||
# During the deploy hook, this function moves files committed to the same directory as one defined in `.platform.app.yaml` | ||
# away from the tmp directory MOUNT_TMP back into their original location, which is now a mount with write-access at | ||
# deploy time. | ||
restore_files() { | ||
MOUNT=`clean_mount_defn $1` | ||
if [ -d $PLATFORM_APP_DIR/$MOUNT_TMP/$MOUNT-tmp ]; then | ||
# Clean up files in mount so it's up to date with what we're moving over. | ||
rm -r $PLATFORM_APP_DIR/$MOUNT/* | ||
# Restore the directory's files. | ||
cp -r $PLATFORM_APP_DIR/$MOUNT_TMP/$MOUNT-tmp/* $PLATFORM_APP_DIR/$MOUNT | ||
fi | ||
} | ||
|
||
# Main function | ||
run() { | ||
# Use PLATFORM_APPLICATION environment variable and jq to find all user-defined mounts. | ||
MOUNTS=$(echo $PLATFORM_APPLICATION | base64 --decode | jq '.mounts | keys') | ||
for mount in $(echo "${MOUNTS}" | jq -r '.[]'); do | ||
_jq() { | ||
# Build hook. The $PLATFORM_BRANCH environment variable is not available in build containers. | ||
if [ -z "${PLATFORM_BRANCH}" ]; then | ||
stage_files $mount | ||
# Deploy hook. | ||
else | ||
restore_files $mount | ||
fi | ||
} | ||
echo $(_jq) | ||
done | ||
} | ||
|
||
run |