Skip to content

Commit

Permalink
feat: simplify paas config
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Oct 21, 2024
1 parent 1d5ecf3 commit bf3f172
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 164 deletions.
119 changes: 25 additions & 94 deletions shopware/paas-meta/6.6/.platform/applications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,21 @@
flavor: composer
dependencies:
php:
composer/composer: "2.7"
composer/composer: "2.8"
variables:
env:
# Tell Shopware to always install in production-mode.
APP_ENV: prod
# Instance ID is empty by default, change to something unique in your project
INSTANCE_ID: ""
# Enable HTTP Cache to get cache-control headers
SHOPWARE_HTTP_CACHE_ENABLED: 1
# NVM and Node.js versions to install
NVM_VERSION: v0.39.0
NODE_VERSION: v20
# Use different redis dbs for cache and sessions
REDIS_CACHE_DATABASE: 0
REDIS_SESSION_DATABASE: 2
# Improve admin build speed
DISABLE_ADMIN_COMPILATION_TYPECHECK: 1
# Only build extension. Shopware assets are pre built in the tags
SHOPWARE_ADMIN_BUILD_ONLY_EXTENSIONS: 1
NODE_VERSION: v20.18.0
SHOPWARE_CLI_VERSION: 0.4.55
# Elasticsearch, see https://developer.shopware.com/docs/guides/hosting/infrastructure/elasticsearch#activating-and-first-time-indexing
SHOPWARE_ES_ENABLED: 0
SHOPWARE_ES_INDEXING_ENABLED: 0
SHOPWARE_ES_INDEX_PREFIX: "sw6"
# Disables the Shopware web installer
SHOPWARE_SKIP_WEBINSTALLER: 1
# Dont compile the theme during build
SHOPWARE_SKIP_THEME_COMPILE: 1
# Performance optimization
COMPOSER_ROOT_VERSION: 1.0.0
php:
upload_max_filesize: 32M
Expand Down Expand Up @@ -60,42 +48,23 @@
hooks:
build: |
set -e
echo "==================================================="
echo "START BUILD SCRIPT"
echo "Beginning with the NVM and NodeJS setup"
echo "==================================================="
# install nvm
unset NPM_CONFIG_PREFIX
export NVM_DIR="$PLATFORM_APP_DIR/.nvm"
export APP_CACHE_DIR=$PLATFORM_APP_DIR/localCache
echo "Install Node and shopware-cli"
# install.sh will automatically install NodeJS based on the presence of $NODE_VERSION
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/$NVM_VERSION/install.sh | bash
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
mkdir -p /tmp/tools
# have nvm available and load the correct node version in your ssh session
echo 'unset NPM_CONFIG_PREFIX' >> .bash_profile
echo 'export NO_UPDATE_NOTIFIER=1' >> .bash_profile
echo 'export NVM_DIR="$PLATFORM_APP_DIR/.nvm"' >> .bash_profile
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> .bash_profile
curl -qL -o node.tar.xz "https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64.tar.xz"
tar xf node.tar.xz -C /tmp/tools --strip-components=1
curl -qL -o shopware-cli.tar.gz https://github.com/FriendsOfShopware/shopware-cli/releases/download/${SHOPWARE_CLI_VERSION}/shopware-cli_Linux_x86_64.tar.gz
tar xf shopware-cli.tar.gz -C /tmp/tools shopware-cli
mv /tmp/tools/shopware-cli /tmp/tools/bin
echo "==================================================="
echo "REMOVE FASTLY WHEN NOT A PRODUCTION OR STAGE ENV"
echo "==================================================="
echo "The Environment has the following type: $PROJECT_ENVIRONMENT_TYPE"
if [ "$PROJECT_ENVIRONMENT_TYPE" = development ]; then
echo "remove fastly.yaml on environment type development"
rm -f config/packages/fastly.yaml
fi
echo "Fastly setup step done"
rm node.tar.xz shopware-cli.tar.gz
echo "==================================================="
echo "COPY THEME AND RUN JS BUILD"
echo "==================================================="
# compile theme and save config for later (will be moved to mount).
# warnings can be ignored (the process is trying to access Redis which is not yet available)
export CI=true
./bin/build-js.sh
export PATH="/tmp/tools/bin:$PATH"
export APP_CACHE_DIR=$PLATFORM_APP_DIR/localCache
shopware-cli project ci .
# Moving files of the mounts to avoid warnings
mv $APP_CACHE_DIR ./RO-localCache
Expand All @@ -104,11 +73,11 @@
deploy: |
set -e
# Syncing files created during the build in the mounts
echo "Syncing files created during the build in the mounts"
rsync -av "${PLATFORM_APP_DIR}/RO-localCache/" "${APP_CACHE_DIR}/"
rsync -av "${PLATFORM_APP_DIR}/RO-var/" "${PLATFORM_APP_DIR}/var/"
# Create Dompdf working directories and sync fonts from the vendor folder
echo "Create Dompdf working directories and sync fonts from the vendor folder"
if [ ! -d "${PLATFORM_APP_DIR}/var/dompdf/tempDir" ]; then
mkdir -p "${PLATFORM_APP_DIR}/var/dompdf/tempDir"
fi
Expand All @@ -117,59 +86,21 @@
fi
rsync -av "${PLATFORM_APP_DIR}/vendor/dompdf/dompdf/lib/fonts" "${PLATFORM_APP_DIR}/var/dompdf/fontDir"
echo "==================================================="
echo "INITIALIZE SHOPWARE'S SITE DATA IF NOT ALREADY INSTALLED"
echo "==================================================="
# Initialize the Shopware site's data set if it's not already installed.
# (This is only for demo/first install and can be removed once Shopware is initialized)
if ! bin/console system:is-installed; then
# setup the environment
# create database with a basic setup (admin user and storefront sales channel).
# this will try to run theme:compile which cannot be disabled, so it will throw a bunch of warnings
# that can be ignored (we use stateless build anyway, so this is done already at this point)
echo "Running system:install (Warnings for theme:compile can be ignored)"
bin/console system:install --create-database --basic-setup --force --skip-assets-install
# Disable FRW
bin/console system:config:set core.frw.completedAt '2019-10-07T10:46:23+00:00'
fi;
echo "==================================================="
echo "UPDATE SALES CHANNEL DOMAIN IF ENVIRONMENT TYPE IS NOT PRODUCTION"
echo "==================================================="
# Configure the sales channel domains automatically for non-production environments
php vendor/bin/shopware-deployment-helper run --skip-theme-compile --skip-asset-install

Check failure on line 90 in shopware/paas-meta/6.6/.platform/applications.yaml

View workflow job for this annotation

GitHub Actions / call-qa / Run checks

Indendation must be a multiple of 4 spaces
if [ "$PLATFORM_ENVIRONMENT_TYPE" != production ]; then
echo "==================================================="
echo "UPDATE SALES CHANNEL DOMAIN IF ENVIRONMENT TYPE IS NOT PRODUCTION"
echo "==================================================="
export FRONTEND_URL=`echo $PLATFORM_ROUTES | base64 --decode | jq -r 'to_entries[] | select(.value.id=="shopware") | .key'`
export FRONTEND_DOMAIN=`php -r 'echo parse_url($_SERVER["FRONTEND_URL"], PHP_URL_HOST);'`
bin/console sales-channel:update:domain "$FRONTEND_DOMAIN"
fi
echo "==================================================="
echo "RUN MIGRATIONS"
echo "==================================================="
# optional: run migration automatically with deploy
bin/console database:migrate --all # Run Shopware core migrations
COMPOSER_HOME="$COMPOSER_HOME/composer/composer" php bin/console plugin:refresh
list_plugins_not_installed=$(php bin/console plugin:list --json | jq 'map(select(.installedAt == null)) | .[].name' -r)
for plugin in $list_plugins_not_installed; do
echo "Installing Plugin $plugin ..."
php bin/console plugin:install --activate --skip-asset-build $plugin
done
list_with_updates=$(php bin/console plugin:list --json | jq 'map(select(.upgradeVersion != null)) | .[].name' -r)
for plugin in $list_with_updates; do
echo "Updating Plugin $plugin ..."
php bin/console plugin:update --skip-asset-build $plugin
done
echo "==================================================="
echo "CLEAR CACHES"
echo "==================================================="
# run cache clear commands, on grid environments this should run in the deploy hook,
# on dedicated generation 2, it will run as part of the pre_start hook (to be set up by Platform.sh support)
if [ -z "$PLATFORM_REGISTRY_NUMBER" ]; then
sh bin/prestart_cacheclear.sh
Expand Down
3 changes: 2 additions & 1 deletion shopware/paas-meta/6.6/bin/prestart_cacheclear.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ set -e

echo "removing ${APP_CACHE_DIR}/var/cache/${APP_ENV}_*/*.*"
rm -Rf ${APP_CACHE_DIR}/var/cache/${APP_ENV}_*/*.*
php bin/console cache:clear

echo "clearing application cache"
php bin/console cache:clear


echo "done executing pre_start cache clear"
19 changes: 0 additions & 19 deletions shopware/paas-meta/6.6/config/packages/dev/monolog.yaml

This file was deleted.

41 changes: 21 additions & 20 deletions shopware/paas-meta/6.6/config/packages/paas.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/shopware/shopware/refs/heads/trunk/config-schema.json
# This file contains all default configuration or PaaS

framework:
session:
handler_id: "%env(CACHE_URL)%/%env(int:default:default_redis_database:REDIS_SESSION_DATABASE)%"
handler_id: "%env(CACHE_URL)%/2"
cache:
app: cache.adapter.redis
system: cache.adapter.redis
default_redis_provider: "%env(CACHE_URL)%/%env(int:default:default_redis_database:REDIS_CACHE_DATABASE)%"
default_redis_provider: "%env(CACHE_URL)%/0"

shopware:
api:
jwt_key:
use_app_secret: true
admin_worker:
enable_admin_worker: false
enable_queue_stats_worker: false
deployment:
cluster_setup: true
dompdf:
Expand All @@ -22,24 +24,23 @@ shopware:
fontDir: '%kernel.project_dir%/var/dompdf/fontDir'
fontCache: '%kernel.project_dir%/var/dompdf/fontCache'

when@prod:
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_http_codes: [404, 405]
buffer_size: 50 # How many messages should be saved? Prevent memory leaks
nested:
type: stream
path: php://stderr
level: debug
formatter: monolog.formatter.json
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine"]
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_http_codes: [404, 405]
buffer_size: 50
nested:
type: stream
path: php://stderr
level: debug
formatter: monolog.formatter.json
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine"]

elasticsearch:
index_settings:
Expand Down
18 changes: 0 additions & 18 deletions shopware/paas-meta/6.6/config/packages/prod/monolog.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions shopware/paas-meta/6.6/config/packages/test/monolog.yaml

This file was deleted.

0 comments on commit bf3f172

Please sign in to comment.