-
-
Notifications
You must be signed in to change notification settings - Fork 4
Add support for bootstrapping Sulu projects #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
chirimoya
wants to merge
2
commits into
symfonycorp:master
Choose a base branch
from
chirimoya:feature/sulu-upsun-template
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,207 @@ | ||
requirements: | ||
- type: file_exists | ||
value: composer.json | ||
- type: has_composer_package | ||
value: sulu/sulu | ||
|
||
template: | | ||
{{- $varnishServiceName := "" -}} | ||
{{- $hasRedisSession := false -}} | ||
{{- range $service := $.Services -}} | ||
{{- if eq $service.Type "varnish" -}} | ||
{{- $varnishServiceName = $service.Name -}} | ||
{{- end -}} | ||
{{- if eq $service.Name "redissession" -}} | ||
{{- $hasRedisSession = true -}} | ||
{{- end -}} | ||
{{- end -}} | ||
routes: | ||
{{- if $varnishServiceName }} | ||
"https://{all}/admin": { type: upstream, upstream: "{{.Slug}}:http", cache: { enabled: false } } | ||
"https://{all}/": { type: upstream, upstream: "{{ $varnishServiceName }}:http", cache: { enabled: false } } | ||
{{- else }} | ||
"https://{all}/": { type: upstream, upstream: "{{.Slug}}:http", cache: { enabled: false } } | ||
{{- end }} | ||
"http://{all}/": { type: redirect, to: "https://{all}/" } | ||
|
||
services: {{- if not $.Services }} {}{{ end }} | ||
{{- range $service := $.Services }} | ||
{{ $service.Name }}: | ||
type: {{ $service.Type }}{{ if $service.Version }}:{{ $service.Version }}{{ end }} | ||
{{- if eq $service.Type "varnish" }} | ||
relationships: | ||
application: "{{$.Slug}}:http" | ||
configuration: | ||
vcl: !include | ||
type: string | ||
path: varnish.vcl | ||
{{- end }} | ||
{{- end }} | ||
|
||
applications: | ||
{{.Slug}}: | ||
source: | ||
root: "/" | ||
|
||
type: php:{{.PhpVersion}} | ||
|
||
runtime: | ||
extensions: | ||
{{- range $ext := $.PHPExtensions }} | ||
{{- if php_extension_available $ext $.PhpVersion }} | ||
- {{ $ext }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
variables: | ||
php: | ||
{{- if php_at_least "7.4" }} | ||
opcache.preload: config/preload.php | ||
{{- end }} | ||
{{- if $hasRedisSession }} | ||
session.save_handler: redis | ||
session.save_path: "tcp://${REDISSESSION_HOST}:${REDISSESSION_PORT}" | ||
{{- end }} | ||
|
||
build: | ||
flavor: none | ||
|
||
web: | ||
locations: | ||
"/": | ||
root: "{{.PublicDirectory}}" | ||
passthru: "/{{.FrontController}}" | ||
"/uploads": | ||
root: "{{.PublicDirectory}}" | ||
passthru: "/{{.FrontController}}" | ||
expires: 30d | ||
scripts: false | ||
allow: true | ||
|
||
mounts: | ||
"/var/cache": { source: instance, source_path: var/cache } | ||
"/var/cache/common/prod/pools/app": { source: storage, source_path: var/cache/common/prod/pools/app } | ||
"/var/storage": { source: storage, source_path: var/storage } | ||
"/var/indexes": { source: storage, source_path: var/indexes } | ||
"/public/uploads": { source: storage, source_path: public/uploads } | ||
|
||
{{ if $.Services -}} | ||
relationships: | ||
{{- range $service := $.Services }} | ||
{{- if ne $service.Type "varnish" }} | ||
{{ $service.Name }}: "{{ $service.Name }}:{{ with $service.Endpoint }}{{ . }}{{ else }}{{ $service.Type }}{{ end }}" | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{ end -}} | ||
|
||
hooks: | ||
build: | | ||
set -x -e | ||
|
||
curl -fs https://get.symfony.com/cloud/configurator | bash | ||
{{ range $ext := $.PHPExtensions -}} | ||
{{- if not (php_extension_available $ext $.PhpVersion) -}} | ||
# php-ext-install {{ $ext }} X.Y.Z | ||
{{ end -}} | ||
{{- end }} | ||
NODE_VERSION=22 symfony-build | ||
|
||
deploy: | | ||
set -x -e | ||
|
||
symfony-deploy | ||
|
||
crons: | ||
security-check: | ||
# Check that no security issues have been found for PHP packages deployed in production | ||
spec: '50 23 * * *' | ||
cmd: if [ "$PLATFORM_ENVIRONMENT_TYPE" = "production" ]; then croncape COMPOSER_ROOT_VERSION=1.0.0 COMPOSER_AUDIT_ABANDONED=ignore composer audit --no-cache; fi | ||
clean-expired-sessions: | ||
spec: '17,47 * * * *' | ||
cmd: croncape php-session-clean | ||
|
||
{{ if has_composer_package "symfony/messenger" -}} | ||
workers: | ||
messenger: | ||
commands: | ||
# Consume "async" messages (as configured in the routing section of config/packages/messenger.yaml) | ||
start: symfony console --time-limit=3600 --memory-limit=64M messenger:consume async | ||
{{- end }} | ||
|
||
extra_files: | ||
".upsun/varnish.vcl": | | ||
# Varnish configuration for Sulu CMS on upsun | ||
# This configuration handles cache invalidation and Sulu-specific requirements | ||
|
||
import std; | ||
import xkey; | ||
|
||
acl invalidators { | ||
"localhost"; | ||
# TODO add outbound IPs for the your region | ||
} | ||
|
||
sub vcl_recv { | ||
# Define the backend | ||
set req.backend_hint = application.backend(); | ||
|
||
if (req.method == "PURGE") { | ||
if (!std.ip(req.http.X-Client-IP, "0.0.0.0") ~ invalidators) { | ||
return (synth(405, "Not allowed")); | ||
} | ||
|
||
return (purge); | ||
} | ||
|
||
if (req.method == "PURGEKEYS") { | ||
if (!std.ip(req.http.X-Client-IP, "0.0.0.0") ~ invalidators) { | ||
return (synth(405, "Not allowed")); | ||
} | ||
|
||
# If neither of the headers are provided we return 400 to simplify detecting wrong configuration | ||
if (!req.http.xkey-purge && !req.http.xkey-softpurge) { | ||
return (synth(400, "Neither header XKey-Purge or XKey-SoftPurge set")); | ||
} | ||
|
||
# Based on provided header invalidate (purge) and/or expire (softpurge) the tagged content | ||
set req.http.n-gone = 0; | ||
set req.http.n-softgone = 0; | ||
if (req.http.xkey-purge) { | ||
set req.http.n-gone = xkey.purge(req.http.xkey-purge); | ||
} | ||
|
||
if (req.http.xkey-softpurge) { | ||
set req.http.n-softgone = xkey.softpurge(req.http.xkey-softpurge); | ||
} | ||
|
||
return (synth(200, "Purged " + req.http.n-gone + " objects, expired " + req.http.n-softgone + " objects")); | ||
} | ||
} | ||
|
||
sub vcl_backend_response { | ||
# Set grace period | ||
set beresp.grace = 2m; | ||
set beresp.keep = 8m; | ||
|
||
if (beresp.http.X-Reverse-Proxy-TTL) { | ||
set beresp.ttl = std.duration(beresp.http.X-Reverse-Proxy-TTL + "s", 0s); | ||
} | ||
} | ||
|
||
sub vcl_deliver { | ||
# Add debug headers in development | ||
if (resp.http.X-Cache-Debug) { | ||
if (obj.hits > 0) { | ||
set resp.http.X-Cache = "HIT"; | ||
} else { | ||
set resp.http.X-Cache = "MISS"; | ||
} | ||
} | ||
|
||
if (!resp.http.X-Cache-Debug) { | ||
# Remove tag headers when delivering to non debug client | ||
unset resp.http.xkey; | ||
unset resp.http.X-Reverse-Proxy-TTL; | ||
} | ||
} |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.