4 |
5 |
6 |
7 |
11 |
12 |
13 |
22 | API Platform Admin
23 |
24 |
25 |
28 |
29 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/admin/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "API Platform Admin",
3 | "name": "Admin",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "192x192",
8 | "type": "image/png"
9 | }
10 | ],
11 | "start_url": "./index.html",
12 | "display": "standalone",
13 | "theme_color": "#000000",
14 | "background_color": "#ffffff"
15 | }
16 |
--------------------------------------------------------------------------------
/admin/src/App.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { HydraAdmin } from '@api-platform/admin';
3 |
4 | export default () => ;
5 |
--------------------------------------------------------------------------------
/admin/src/App.test.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import App from './App';
4 |
5 | it('renders without crashing', () => {
6 | const div = document.createElement('div');
7 | ReactDOM.render(, div);
8 | ReactDOM.unmountComponentAtNode(div);
9 | });
10 |
--------------------------------------------------------------------------------
/admin/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import App from './App';
4 | import * as serviceWorker from './serviceWorker';
5 |
6 | ReactDOM.render(, document.getElementById('root'));
7 |
8 | // If you want your app to work offline and load faster, you can change
9 | // unregister() to register() below. Note this comes with some pitfalls.
10 | // Learn more about service workers: http://bit.ly/CRA-PWA
11 | serviceWorker.unregister();
12 |
--------------------------------------------------------------------------------
/admin/src/serviceWorker.js:
--------------------------------------------------------------------------------
1 | // This optional code is used to register a service worker.
2 | // register() is not called by default.
3 |
4 | // This lets the app load faster on subsequent visits in production, and gives
5 | // it offline capabilities. However, it also means that developers (and users)
6 | // will only see deployed updates on subsequent visits to a page, after all the
7 | // existing tabs open on the page have been closed, since previously cached
8 | // resources are updated in the background.
9 |
10 | // To learn more about the benefits of this model and instructions on how to
11 | // opt-in, read http://bit.ly/CRA-PWA
12 |
13 | const isLocalhost = Boolean(
14 | window.location.hostname === 'localhost' ||
15 | // [::1] is the IPv6 localhost address.
16 | window.location.hostname === '[::1]' ||
17 | // 127.0.0.1/8 is considered localhost for IPv4.
18 | window.location.hostname.match(
19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
20 | )
21 | );
22 |
23 | export function register(config) {
24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
25 | // The URL constructor is available in all browsers that support SW.
26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
27 | if (publicUrl.origin !== window.location.origin) {
28 | // Our service worker won't work if PUBLIC_URL is on a different origin
29 | // from what our page is served on. This might happen if a CDN is used to
30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374
31 | return;
32 | }
33 |
34 | window.addEventListener('load', () => {
35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
36 |
37 | if (isLocalhost) {
38 | // This is running on localhost. Let's check if a service worker still exists or not.
39 | checkValidServiceWorker(swUrl, config);
40 |
41 | // Add some additional logging to localhost, pointing developers to the
42 | // service worker/PWA documentation.
43 | navigator.serviceWorker.ready.then(() => {
44 | console.log(
45 | 'This web app is being served cache-first by a service ' +
46 | 'worker. To learn more, visit http://bit.ly/CRA-PWA'
47 | );
48 | });
49 | } else {
50 | // Is not localhost. Just register service worker
51 | registerValidSW(swUrl, config);
52 | }
53 | });
54 | }
55 | }
56 |
57 | function registerValidSW(swUrl, config) {
58 | navigator.serviceWorker
59 | .register(swUrl)
60 | .then(registration => {
61 | registration.onupdatefound = () => {
62 | const installingWorker = registration.installing;
63 | if (installingWorker == null) {
64 | return;
65 | }
66 | installingWorker.onstatechange = () => {
67 | if (installingWorker.state === 'installed') {
68 | if (navigator.serviceWorker.controller) {
69 | // At this point, the updated precached content has been fetched,
70 | // but the previous service worker will still serve the older
71 | // content until all client tabs are closed.
72 | console.log(
73 | 'New content is available and will be used when all ' +
74 | 'tabs for this page are closed. See http://bit.ly/CRA-PWA.'
75 | );
76 |
77 | // Execute callback
78 | if (config && config.onUpdate) {
79 | config.onUpdate(registration);
80 | }
81 | } else {
82 | // At this point, everything has been precached.
83 | // It's the perfect time to display a
84 | // "Content is cached for offline use." message.
85 | console.log('Content is cached for offline use.');
86 |
87 | // Execute callback
88 | if (config && config.onSuccess) {
89 | config.onSuccess(registration);
90 | }
91 | }
92 | }
93 | };
94 | };
95 | })
96 | .catch(error => {
97 | console.error('Error during service worker registration:', error);
98 | });
99 | }
100 |
101 | function checkValidServiceWorker(swUrl, config) {
102 | // Check if the service worker can be found. If it can't reload the page.
103 | fetch(swUrl)
104 | .then(response => {
105 | // Ensure service worker exists, and that we really are getting a JS file.
106 | const contentType = response.headers.get('content-type');
107 | if (
108 | response.status === 404 ||
109 | (contentType != null && contentType.indexOf('javascript') === -1)
110 | ) {
111 | // No service worker found. Probably a different app. Reload the page.
112 | navigator.serviceWorker.ready.then(registration => {
113 | registration.unregister().then(() => {
114 | window.location.reload();
115 | });
116 | });
117 | } else {
118 | // Service worker found. Proceed as normal.
119 | registerValidSW(swUrl, config);
120 | }
121 | })
122 | .catch(() => {
123 | console.log(
124 | 'No internet connection found. App is running in offline mode.'
125 | );
126 | });
127 | }
128 |
129 | export function unregister() {
130 | if ('serviceWorker' in navigator) {
131 | navigator.serviceWorker.ready.then(registration => {
132 | registration.unregister();
133 | });
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/api/.dockerignore:
--------------------------------------------------------------------------------
1 | **/*.log
2 | **/*.md
3 | **/*.php~
4 | **/._*
5 | **/.dockerignore
6 | **/.DS_Store
7 | **/.git/
8 | **/.gitattributes
9 | **/.gitignore
10 | **/.gitmodules
11 | **/docker-compose.*.yaml
12 | **/docker-compose.*.yml
13 | **/docker-compose.yaml
14 | **/docker-compose.yml
15 | **/Dockerfile
16 | **/Thumbs.db
17 | .editorconfig
18 | .env.*.local
19 | .env.local
20 | .env.local.php
21 | .php_cs.cache
22 | bin/*
23 | !bin/console
24 | build/
25 | docker/db/data/
26 | helm/
27 | public/bundles/
28 | var/
29 | vendor/
30 |
--------------------------------------------------------------------------------
/api/.env:
--------------------------------------------------------------------------------
1 | # In all environments, the following files are loaded if they exist,
2 | # the latter taking precedence over the former:
3 | #
4 | # * .env contains default values for the environment variables needed by the app
5 | # * .env.local uncommitted file with local overrides
6 | # * .env.$APP_ENV committed environment-specific defaults
7 | # * .env.$APP_ENV.local uncommitted environment-specific overrides
8 | #
9 | # Real environment variables win over .env files.
10 | #
11 | # DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
12 | #
13 | # Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
14 | # https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
15 |
16 | ###> doctrine/doctrine-bundle ###
17 | # Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
18 | # For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
19 | # For a MySQL database, use: "mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7"
20 | # IMPORTANT: You MUST configure your db driver and server version, either here or in config/packages/doctrine.yaml
21 | DATABASE_URL=postgres://api-platform:!ChangeMe!@db/api?server_version=12
22 | ###< doctrine/doctrine-bundle ###
23 |
24 | ###> nelmio/cors-bundle ###
25 | CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$
26 | ###< nelmio/cors-bundle ###
27 |
28 | ###> symfony/mercure-bundle ###
29 | # See https://symfony.com/doc/current/mercure.html#configuration
30 | MERCURE_PUBLISH_URL=http://mercure/.well-known/mercure
31 | # The default token is signed with the secret key: !ChangeMe!
32 | MERCURE_JWT_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjdXJlIjp7InB1Ymxpc2giOltdfX0.Oo0yg7y4yMa1vr_bziltxuTCqb8JVHKxp-f_FwwOim0
33 | ###< symfony/mercure-bundle ###
34 |
35 | ###> symfony/framework-bundle ###
36 | APP_ENV=dev
37 | APP_SECRET=!ChangeMe!
38 | TRUSTED_PROXIES=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
39 | TRUSTED_HOSTS='^localhost|api$'
40 | ###< symfony/framework-bundle ###
41 |
42 | # API Platform distribution
43 | MERCURE_SUBSCRIBE_URL=https://localhost:1337/.well-known/mercure
44 | VARNISH_URL=http://cache-proxy
45 |
--------------------------------------------------------------------------------
/api/.gitignore:
--------------------------------------------------------------------------------
1 | /docker/db/data
2 | /helm/api/charts
3 |
4 | ###> symfony/framework-bundle ###
5 | /.env.local
6 | /.env.local.php
7 | /.env.*.local
8 | /public/bundles/
9 | /var/
10 | /vendor/
11 | ###< symfony/framework-bundle ###
12 |
13 | ###> friendsofphp/php-cs-fixer ###
14 | /.php_cs
15 | /.php_cs.cache
16 | ###< friendsofphp/php-cs-fixer ###
17 |
--------------------------------------------------------------------------------
/api/.php_cs.dist:
--------------------------------------------------------------------------------
1 | in(__DIR__)
5 | ->exclude('var')
6 | ;
7 |
8 | return PhpCsFixer\Config::create()
9 | ->setRules([
10 | '@Symfony' => true,
11 | 'array_syntax' => ['syntax' => 'short'],
12 | ])
13 | ->setFinder($finder)
14 | ;
15 |
--------------------------------------------------------------------------------
/api/Dockerfile:
--------------------------------------------------------------------------------
1 | # the different stages of this Dockerfile are meant to be built into separate images
2 | # https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage
3 | # https://docs.docker.com/compose/compose-file/#target
4 |
5 |
6 | # https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
7 | ARG PHP_VERSION=7.3
8 | ARG NGINX_VERSION=1.17
9 | ARG VARNISH_VERSION=6.3
10 |
11 |
12 | # "php" stage
13 | FROM php:${PHP_VERSION}-fpm-alpine AS api_platform_php
14 |
15 | # persistent / runtime deps
16 | RUN apk add --no-cache \
17 | acl \
18 | file \
19 | gettext \
20 | git \
21 | ;
22 |
23 | ARG APCU_VERSION=5.1.18
24 | RUN set -eux; \
25 | apk add --no-cache --virtual .build-deps \
26 | $PHPIZE_DEPS \
27 | icu-dev \
28 | libzip-dev \
29 | postgresql-dev \
30 | zlib-dev \
31 | ; \
32 | \
33 | docker-php-ext-configure zip --with-libzip; \
34 | docker-php-ext-install -j$(nproc) \
35 | intl \
36 | pdo_pgsql \
37 | zip \
38 | ; \
39 | pecl install \
40 | apcu-${APCU_VERSION} \
41 | ; \
42 | pecl clear-cache; \
43 | docker-php-ext-enable \
44 | apcu \
45 | opcache \
46 | ; \
47 | \
48 | runDeps="$( \
49 | scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
50 | | tr ',' '\n' \
51 | | sort -u \
52 | | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
53 | )"; \
54 | apk add --no-cache --virtual .api-phpexts-rundeps $runDeps; \
55 | \
56 | apk del .build-deps
57 |
58 | COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
59 | RUN ln -s $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini
60 | COPY docker/php/conf.d/api-platform.prod.ini $PHP_INI_DIR/conf.d/api-platform.ini
61 |
62 | # Workaround to allow using PHPUnit 8 with Symfony 4.3
63 | ENV SYMFONY_PHPUNIT_VERSION=8.3
64 |
65 | # https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
66 | ENV COMPOSER_ALLOW_SUPERUSER=1
67 | # install Symfony Flex globally to speed up download of Composer packages (parallelized prefetching)
68 | RUN set -eux; \
69 | composer global require "symfony/flex" --prefer-dist --no-progress --no-suggest --classmap-authoritative; \
70 | composer clear-cache
71 | ENV PATH="${PATH}:/root/.composer/vendor/bin"
72 |
73 | WORKDIR /srv/api
74 |
75 | # build for production
76 | ARG APP_ENV=prod
77 |
78 | # prevent the reinstallation of vendors at every changes in the source code
79 | COPY composer.json composer.lock symfony.lock ./
80 | RUN set -eux; \
81 | composer install --prefer-dist --no-dev --no-scripts --no-progress --no-suggest; \
82 | composer clear-cache
83 |
84 | # do not use .env files in production
85 | COPY .env ./
86 | RUN composer dump-env prod; \
87 | rm .env
88 |
89 | # copy only specifically what we need
90 | COPY bin bin/
91 | COPY config config/
92 | COPY public public/
93 | COPY src src/
94 |
95 | RUN set -eux; \
96 | mkdir -p var/cache var/log; \
97 | composer dump-autoload --classmap-authoritative --no-dev; \
98 | composer run-script --no-dev post-install-cmd; \
99 | chmod +x bin/console; sync
100 | VOLUME /srv/api/var
101 |
102 | COPY docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
103 | RUN chmod +x /usr/local/bin/docker-entrypoint
104 |
105 | ENTRYPOINT ["docker-entrypoint"]
106 | CMD ["php-fpm"]
107 |
108 |
109 | # "nginx" stage
110 | # depends on the "php" stage above
111 | FROM nginx:${NGINX_VERSION}-alpine AS api_platform_nginx
112 |
113 | COPY docker/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
114 |
115 | WORKDIR /srv/api/public
116 |
117 | COPY --from=api_platform_php /srv/api/public ./
118 |
119 |
120 | # "varnish" stage
121 | # does not depend on any of the above stages, but placed here to keep everything in one Dockerfile
122 | FROM varnish:${VARNISH_VERSION} AS api_platform_varnish
123 |
124 | COPY docker/varnish/conf/default.vcl /etc/varnish/default.vcl
125 |
126 | CMD ["varnishd", "-F", "-f", "/etc/varnish/default.vcl", "-p", "http_resp_hdr_len=65536", "-p", "http_resp_size=98304"]
127 |
--------------------------------------------------------------------------------
/api/bin/console:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | getParameterOption(['--env', '-e'], null, true)) {
23 | putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
24 | }
25 |
26 | if ($input->hasParameterOption('--no-debug', true)) {
27 | putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
28 | }
29 |
30 | require dirname(__DIR__).'/config/bootstrap.php';
31 |
32 | if ($_SERVER['APP_DEBUG']) {
33 | umask(0000);
34 |
35 | if (class_exists(Debug::class)) {
36 | Debug::enable();
37 | }
38 | }
39 |
40 | $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
41 | $application = new Application($kernel);
42 | $application->run($input);
43 |
--------------------------------------------------------------------------------
/api/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "license": "MIT",
3 | "require": {
4 | "php": "^7.1.3",
5 | "ext-ctype": "*",
6 | "ext-iconv": "*",
7 | "api-platform/api-pack": "^1.1",
8 | "api-platform/core": "dev-master",
9 | "doctrine/doctrine-migrations-bundle": "^2.0",
10 | "guzzlehttp/guzzle": "^6.3",
11 | "symfony/console": "4.3.*",
12 | "symfony/dotenv": "4.3.*",
13 | "symfony/flex": "^1.1",
14 | "symfony/framework-bundle": "4.3.*",
15 | "symfony/mercure-bundle": "^0.2",
16 | "symfony/yaml": "4.3.*"
17 | },
18 | "require-dev": {
19 | "api-platform/schema-generator": "^2.1",
20 | "hautelook/alice-bundle": "^2.5",
21 | "symfony/maker-bundle": "^1.11",
22 | "symfony/profiler-pack": "^1.0"
23 | },
24 | "conflict": {
25 | "symfony/symfony": "*"
26 | },
27 | "replace": {
28 | "paragonie/random_compat": "2.*",
29 | "symfony/polyfill-ctype": "*",
30 | "symfony/polyfill-iconv": "*",
31 | "symfony/polyfill-php56": "*",
32 | "symfony/polyfill-php70": "*",
33 | "symfony/polyfill-php71": "*"
34 | },
35 | "autoload": {
36 | "psr-4": {
37 | "App\\": "src/"
38 | }
39 | },
40 | "autoload-dev": {
41 | "psr-4": {
42 | "App\\Tests\\": "tests/"
43 | }
44 | },
45 | "config": {
46 | "preferred-install": {
47 | "*": "dist"
48 | },
49 | "sort-packages": true
50 | },
51 | "scripts": {
52 | "auto-scripts": {
53 | "cache:clear": "symfony-cmd",
54 | "assets:install %PUBLIC_DIR%": "symfony-cmd"
55 | },
56 | "post-install-cmd": [
57 | "@auto-scripts"
58 | ],
59 | "post-update-cmd": [
60 | "@auto-scripts"
61 | ]
62 | },
63 | "extra": {
64 | "symfony": {
65 | "allow-contrib": false,
66 | "require": "4.3.*"
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/api/config/bootstrap.php:
--------------------------------------------------------------------------------
1 | =1.2)
9 | if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV']) {
10 | foreach ($env as $k => $v) {
11 | $_ENV[$k] = $_ENV[$k] ?? (isset($_SERVER[$k]) && 0 !== strpos($k, 'HTTP_') ? $_SERVER[$k] : $v);
12 | }
13 | } elseif (!class_exists(Dotenv::class)) {
14 | throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
15 | } else {
16 | // load all the .env files
17 | (new Dotenv(false))->loadEnv(dirname(__DIR__).'/.env');
18 | }
19 |
20 | $_SERVER += $_ENV;
21 | $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
22 | $_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
23 | $_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
24 |
--------------------------------------------------------------------------------
/api/config/bundles.php:
--------------------------------------------------------------------------------
1 | ['all' => true],
5 | Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
6 | Symfony\Bundle\MercureBundle\MercureBundle::class => ['all' => true],
7 | Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
8 | Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
9 | Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
10 | ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
11 | Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
12 | Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
13 | Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
14 | Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
15 | Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['dev' => true, 'test' => true],
16 | Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['dev' => true, 'test' => true],
17 | Hautelook\AliceBundle\HautelookAliceBundle::class => ['dev' => true, 'test' => true],
18 | ];
19 |
--------------------------------------------------------------------------------
/api/config/packages/api_platform.yaml:
--------------------------------------------------------------------------------
1 | api_platform:
2 | title: Hello API Platform
3 | version: 1.0.0
4 | mapping:
5 | paths: ['%kernel.project_dir%/src/Entity']
6 | patch_formats:
7 | json: ['application/merge-patch+json']
8 | swagger:
9 | versions: [3]
10 | # Mercure integration, remove if unwanted
11 | mercure:
12 | hub_url: '%env(MERCURE_SUBSCRIBE_URL)%'
13 | defaults:
14 | normalization_context:
15 | iri_only: true
16 | #itemOperations: [get]
17 | #collectionOperations: [get]
18 |
--------------------------------------------------------------------------------
/api/config/packages/cache.yaml:
--------------------------------------------------------------------------------
1 | framework:
2 | cache:
3 | # Put the unique name of your app here: the prefix seed
4 | # is used to compute stable namespaces for cache keys.
5 | #prefix_seed: your_vendor_name/app_name
6 |
7 | # The app cache caches to the filesystem by default.
8 | # Other options include:
9 |
10 | # Redis
11 | #app: cache.adapter.redis
12 | #default_redis_provider: redis://localhost
13 |
14 | # APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
15 | #app: cache.adapter.apcu
16 |
17 | # Namespaced pools use the above "app" backend by default
18 | #pools:
19 | #my.dedicated.cache: null
20 |
--------------------------------------------------------------------------------
/api/config/packages/dev/hautelook_alice.yaml:
--------------------------------------------------------------------------------
1 | hautelook_alice:
2 | fixtures_path: fixtures
3 |
--------------------------------------------------------------------------------
/api/config/packages/dev/nelmio_alice.yaml:
--------------------------------------------------------------------------------
1 | nelmio_alice:
2 | functions_blacklist:
3 | - 'current'
4 | - 'shuffle'
5 | - 'date'
6 | - 'time'
7 | - 'file'
8 | - 'md5'
9 | - 'sha1'
10 |
--------------------------------------------------------------------------------
/api/config/packages/dev/routing.yaml:
--------------------------------------------------------------------------------
1 | framework:
2 | router:
3 | strict_requirements: true
4 |
--------------------------------------------------------------------------------
/api/config/packages/dev/web_profiler.yaml:
--------------------------------------------------------------------------------
1 | web_profiler:
2 | toolbar: true
3 | intercept_redirects: false
4 |
5 | framework:
6 | profiler: { only_exceptions: false }
7 |
--------------------------------------------------------------------------------
/api/config/packages/doctrine.yaml:
--------------------------------------------------------------------------------
1 | doctrine:
2 | dbal:
3 | url: '%env(resolve:DATABASE_URL)%'
4 |
5 | # IMPORTANT: You MUST configure your db driver and server version,
6 | # either here or in the DATABASE_URL env var (see .env file)
7 | driver: 'postgresql'
8 | server_version: '12'
9 | orm:
10 | auto_generate_proxy_classes: true
11 | naming_strategy: doctrine.orm.naming_strategy.underscore
12 | auto_mapping: true
13 | mappings:
14 | App:
15 | is_bundle: false
16 | type: annotation
17 | dir: '%kernel.project_dir%/src/Entity'
18 | prefix: 'App\Entity'
19 | alias: App
20 |
--------------------------------------------------------------------------------
/api/config/packages/doctrine_migrations.yaml:
--------------------------------------------------------------------------------
1 | doctrine_migrations:
2 | dir_name: '%kernel.project_dir%/src/Migrations'
3 | # namespace is arbitrary but should be different from App\Migrations
4 | # as migrations classes should NOT be autoloaded
5 | namespace: DoctrineMigrations
6 |
--------------------------------------------------------------------------------
/api/config/packages/framework.yaml:
--------------------------------------------------------------------------------
1 | framework:
2 | secret: '%env(APP_SECRET)%'
3 | #csrf_protection: true
4 | #http_method_override: true
5 |
6 | # Enables session support. Note that the session will ONLY be started if you read or write from it.
7 | # Remove or comment this section to explicitly disable session support.
8 | session:
9 | handler_id: null
10 | cookie_secure: auto
11 | cookie_samesite: lax
12 |
13 | #esi: true
14 | #fragments: true
15 | php_errors:
16 | log: true
17 |
--------------------------------------------------------------------------------
/api/config/packages/mercure.yaml:
--------------------------------------------------------------------------------
1 | mercure:
2 | enable_profiler: '%kernel.debug%'
3 | hubs:
4 | default:
5 | url: '%env(MERCURE_PUBLISH_URL)%'
6 | jwt: '%env(MERCURE_JWT_TOKEN)%'
7 |
--------------------------------------------------------------------------------
/api/config/packages/nelmio_cors.yaml:
--------------------------------------------------------------------------------
1 | nelmio_cors:
2 | defaults:
3 | origin_regex: true
4 | allow_origin: ['%env(CORS_ALLOW_ORIGIN)%']
5 | allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
6 | allow_headers: ['Content-Type', 'Authorization']
7 | expose_headers: ['Link']
8 | max_age: 3600
9 | paths:
10 | '^/': null
11 |
--------------------------------------------------------------------------------
/api/config/packages/prod/api_platform.yaml:
--------------------------------------------------------------------------------
1 | api_platform:
2 | # Varnish integration, remove if unwanted
3 | http_cache:
4 | invalidation:
5 | enabled: true
6 | varnish_urls: ['%env(VARNISH_URL)%']
7 | max_age: 0
8 | shared_max_age: 3600
9 | vary: ['Content-Type', 'Authorization', 'Origin']
10 | public: true
11 |
--------------------------------------------------------------------------------
/api/config/packages/prod/doctrine.yaml:
--------------------------------------------------------------------------------
1 | doctrine:
2 | orm:
3 | auto_generate_proxy_classes: false
4 | metadata_cache_driver:
5 | type: service
6 | id: doctrine.system_cache_provider
7 | query_cache_driver:
8 | type: service
9 | id: doctrine.system_cache_provider
10 | result_cache_driver:
11 | type: service
12 | id: doctrine.result_cache_provider
13 |
14 | services:
15 | doctrine.result_cache_provider:
16 | class: Symfony\Component\Cache\DoctrineProvider
17 | public: false
18 | arguments:
19 | - '@doctrine.result_cache_pool'
20 | doctrine.system_cache_provider:
21 | class: Symfony\Component\Cache\DoctrineProvider
22 | public: false
23 | arguments:
24 | - '@doctrine.system_cache_pool'
25 |
26 | framework:
27 | cache:
28 | pools:
29 | doctrine.result_cache_pool:
30 | adapter: cache.app
31 | doctrine.system_cache_pool:
32 | adapter: cache.system
33 |
--------------------------------------------------------------------------------
/api/config/packages/prod/routing.yaml:
--------------------------------------------------------------------------------
1 | framework:
2 | router:
3 | strict_requirements: null
4 |
--------------------------------------------------------------------------------
/api/config/packages/routing.yaml:
--------------------------------------------------------------------------------
1 | framework:
2 | router:
3 | utf8: true
4 |
--------------------------------------------------------------------------------
/api/config/packages/security.yaml:
--------------------------------------------------------------------------------
1 | security:
2 | # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
3 | providers:
4 | in_memory: { memory: null }
5 | firewalls:
6 | dev:
7 | pattern: ^/(_(profiler|wdt)|css|images|js)/
8 | security: false
9 | main:
10 | anonymous: true
11 |
12 | # activate different ways to authenticate
13 | # https://symfony.com/doc/current/security.html#firewalls-authentication
14 |
15 | # https://symfony.com/doc/current/security/impersonating_user.html
16 | # switch_user: true
17 |
18 | # Easy way to control access for large sections of your site
19 | # Note: Only the *first* access control that matches will be used
20 | access_control:
21 | # - { path: ^/admin, roles: ROLE_ADMIN }
22 | # - { path: ^/profile, roles: ROLE_USER }
23 |
--------------------------------------------------------------------------------
/api/config/packages/test/framework.yaml:
--------------------------------------------------------------------------------
1 | framework:
2 | test: true
3 | session:
4 | storage_id: session.storage.mock_file
5 |
--------------------------------------------------------------------------------
/api/config/packages/test/hautelook_alice.yaml:
--------------------------------------------------------------------------------
1 | imports:
2 | - { resource: ../dev/hautelook_alice.yaml }
3 |
--------------------------------------------------------------------------------
/api/config/packages/test/nelmio_alice.yaml:
--------------------------------------------------------------------------------
1 | imports:
2 | - { resource: ../dev/nelmio_alice.yaml }
3 |
--------------------------------------------------------------------------------
/api/config/packages/test/routing.yaml:
--------------------------------------------------------------------------------
1 | framework:
2 | router:
3 | strict_requirements: true
4 |
--------------------------------------------------------------------------------
/api/config/packages/test/twig.yaml:
--------------------------------------------------------------------------------
1 | twig:
2 | strict_variables: true
3 |
--------------------------------------------------------------------------------
/api/config/packages/test/validator.yaml:
--------------------------------------------------------------------------------
1 | framework:
2 | validation:
3 | not_compromised_password: false
4 |
--------------------------------------------------------------------------------
/api/config/packages/test/web_profiler.yaml:
--------------------------------------------------------------------------------
1 | web_profiler:
2 | toolbar: false
3 | intercept_redirects: false
4 |
5 | framework:
6 | profiler: { collect: false }
7 |
--------------------------------------------------------------------------------
/api/config/packages/twig.yaml:
--------------------------------------------------------------------------------
1 | twig:
2 | default_path: '%kernel.project_dir%/templates'
3 | debug: '%kernel.debug%'
4 | strict_variables: '%kernel.debug%'
5 |
--------------------------------------------------------------------------------
/api/config/packages/validator.yaml:
--------------------------------------------------------------------------------
1 | framework:
2 | validation:
3 | email_validation_mode: html5
4 |
5 | # Enables validator auto-mapping support.
6 | # For instance, basic validation constraints will be inferred from Doctrine's metadata.
7 | #auto_mapping:
8 | # App\Entity\: []
9 |
--------------------------------------------------------------------------------
/api/config/routes.yaml:
--------------------------------------------------------------------------------
1 | #index:
2 | # path: /
3 | # controller: App\Controller\DefaultController::index
4 |
--------------------------------------------------------------------------------
/api/config/routes/annotations.yaml:
--------------------------------------------------------------------------------
1 | controllers:
2 | resource: ../../src/Controller/
3 | type: annotation
4 |
--------------------------------------------------------------------------------
/api/config/routes/api_platform.yaml:
--------------------------------------------------------------------------------
1 | api_platform:
2 | resource: .
3 | type: api_platform
4 |
--------------------------------------------------------------------------------
/api/config/routes/dev/twig.yaml:
--------------------------------------------------------------------------------
1 | _errors:
2 | resource: '@TwigBundle/Resources/config/routing/errors.xml'
3 | prefix: /_error
4 |
--------------------------------------------------------------------------------
/api/config/routes/dev/web_profiler.yaml:
--------------------------------------------------------------------------------
1 | web_profiler_wdt:
2 | resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
3 | prefix: /_wdt
4 |
5 | web_profiler_profiler:
6 | resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
7 | prefix: /_profiler
8 |
--------------------------------------------------------------------------------
/api/config/services.yaml:
--------------------------------------------------------------------------------
1 | # This file is the entry point to configure your own services.
2 | # Files in the packages/ subdirectory configure your dependencies.
3 |
4 | # Put parameters here that don't need to change on each machine where the app is deployed
5 | # https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
6 | parameters:
7 |
8 | services:
9 | # default configuration for services in *this* file
10 | _defaults:
11 | autowire: true # Automatically injects dependencies in your services.
12 | autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
13 |
14 | # makes classes in src/ available to be used as services
15 | # this creates a service per class whose id is the fully-qualified class name
16 | App\:
17 | resource: '../src/*'
18 | exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
19 |
20 | # controllers are imported separately to make sure services can be injected
21 | # as action arguments even if you don't extend any base controller class
22 | App\Controller\:
23 | resource: '../src/Controller'
24 | tags: ['controller.service_arguments']
25 |
26 | # add more service definitions when explicit configuration is needed
27 | # please note that last definitions always *replace* previous ones
28 |
--------------------------------------------------------------------------------
/api/docker/nginx/conf.d/default.conf:
--------------------------------------------------------------------------------
1 | server {
2 | root /srv/api/public;
3 |
4 | location / {
5 | # try to serve file directly, fallback to index.php
6 | try_files $uri /index.php$is_args$args;
7 | }
8 |
9 | location ~ ^/index\.php(/|$) {
10 | # Comment the next line and uncomment the next to enable dynamic resolution (incompatible with Kubernetes)
11 | fastcgi_pass php:9000;
12 | #resolver 127.0.0.11;
13 | #set $upstream_host php;
14 | #fastcgi_pass $upstream_host:9000;
15 |
16 | # Increase the buffer size to handle large cache invalidation headers
17 | fastcgi_buffer_size 32k;
18 | fastcgi_buffers 32 4k;
19 |
20 | fastcgi_split_path_info ^(.+\.php)(/.*)$;
21 | include fastcgi_params;
22 |
23 | # When you are using symlinks to link the document root to the
24 | # current version of your application, you should pass the real
25 | # application path instead of the path to the symlink to PHP
26 | # FPM.
27 | # Otherwise, PHP's OPcache may not properly detect changes to
28 | # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
29 | # for more information).
30 | fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
31 | fastcgi_param DOCUMENT_ROOT $realpath_root;
32 | # Prevents URIs that include the front controller. This will 404:
33 | # http://domain.tld/index.php/some-path
34 | # Remove the internal directive to allow URIs like this
35 | internal;
36 | }
37 |
38 | # return 404 for all other php files not matching the front controller
39 | # this prevents access to other php files you don't want to be accessible.
40 | location ~ \.php$ {
41 | return 404;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/api/docker/php/conf.d/api-platform.dev.ini:
--------------------------------------------------------------------------------
1 | apc.enable_cli = 1
2 | date.timezone = UTC
3 | session.auto_start = Off
4 | short_open_tag = Off
5 |
6 | # https://symfony.com/doc/current/performance.html
7 | opcache.interned_strings_buffer = 16
8 | opcache.max_accelerated_files = 20000
9 | opcache.memory_consumption = 256
10 | realpath_cache_size = 4096K
11 | realpath_cache_ttl = 600
12 |
--------------------------------------------------------------------------------
/api/docker/php/conf.d/api-platform.prod.ini:
--------------------------------------------------------------------------------
1 | apc.enable_cli = 1
2 | date.timezone = UTC
3 | session.auto_start = Off
4 | short_open_tag = Off
5 |
6 | # https://symfony.com/doc/current/performance.html
7 | opcache.interned_strings_buffer = 16
8 | opcache.max_accelerated_files = 20000
9 | opcache.memory_consumption = 256
10 | opcache.validate_timestamps = 0
11 | realpath_cache_size = 4096K
12 | realpath_cache_ttl = 600
13 |
--------------------------------------------------------------------------------
/api/docker/php/docker-entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | # first arg is `-f` or `--some-option`
5 | if [ "${1#-}" != "$1" ]; then
6 | set -- php-fpm "$@"
7 | fi
8 |
9 | if [ "$1" = 'php-fpm' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
10 | PHP_INI_RECOMMENDED="$PHP_INI_DIR/php.ini-production"
11 | if [ "$APP_ENV" != 'prod' ]; then
12 | PHP_INI_RECOMMENDED="$PHP_INI_DIR/php.ini-development"
13 | fi
14 | ln -sf "$PHP_INI_RECOMMENDED" "$PHP_INI_DIR/php.ini"
15 |
16 | mkdir -p var/cache var/log
17 | setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX var
18 | setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX var
19 |
20 | if [ "$APP_ENV" != 'prod' ]; then
21 | composer install --prefer-dist --no-progress --no-suggest --no-interaction
22 | fi
23 |
24 | echo "Waiting for db to be ready..."
25 | until bin/console doctrine:query:sql "SELECT 1" > /dev/null 2>&1; do
26 | sleep 1
27 | done
28 |
29 | if ls -A src/Migrations/*.php > /dev/null 2>&1; then
30 | bin/console doctrine:migrations:migrate --no-interaction
31 | fi
32 | fi
33 |
34 | exec docker-php-entrypoint "$@"
35 |
--------------------------------------------------------------------------------
/api/docker/varnish/conf/default.vcl:
--------------------------------------------------------------------------------
1 | vcl 4.0;
2 |
3 | import std;
4 |
5 | backend default {
6 | .host = "api";
7 | .port = "80";
8 | # Health check
9 | #.probe = {
10 | # .url = "/";
11 | # .timeout = 5s;
12 | # .interval = 10s;
13 | # .window = 5;
14 | # .threshold = 3;
15 | #}
16 | }
17 |
18 | # Hosts allowed to send BAN requests
19 | acl invalidators {
20 | "localhost";
21 | "php";
22 | # local Kubernetes network
23 | "10.0.0.0"/8;
24 | "172.16.0.0"/12;
25 | "192.168.0.0"/16;
26 | }
27 |
28 | sub vcl_recv {
29 | if (req.restarts > 0) {
30 | set req.hash_always_miss = true;
31 | }
32 |
33 | # Remove the "Forwarded" HTTP header if exists (security)
34 | unset req.http.forwarded;
35 | # Remove "Preload" and "Fields" HTTP header to improve Vulcain's performance
36 | unset req.http.preload;
37 | unset req.http.fields;
38 |
39 | # To allow API Platform to ban by cache tags
40 | if (req.method == "BAN") {
41 | if (client.ip !~ invalidators) {
42 | return (synth(405, "Not allowed"));
43 | }
44 |
45 | if (req.http.ApiPlatform-Ban-Regex) {
46 | ban("obj.http.Cache-Tags ~ " + req.http.ApiPlatform-Ban-Regex);
47 |
48 | return (synth(200, "Ban added"));
49 | }
50 |
51 | return (synth(400, "ApiPlatform-Ban-Regex HTTP header must be set."));
52 | }
53 |
54 | # For health checks
55 | if (req.method == "GET" && req.url == "/healthz") {
56 | return (synth(200, "OK"));
57 | }
58 | }
59 |
60 | sub vcl_hit {
61 | if (obj.ttl >= 0s) {
62 | # A pure unadulterated hit, deliver it
63 | return (deliver);
64 | }
65 |
66 | if (std.healthy(req.backend_hint)) {
67 | # The backend is healthy
68 | # Fetch the object from the backend
69 | return (restart);
70 | }
71 |
72 | # No fresh object and the backend is not healthy
73 | if (obj.ttl + obj.grace > 0s) {
74 | # Deliver graced object
75 | # Automatically triggers a background fetch
76 | return (deliver);
77 | }
78 |
79 | # No valid object to deliver
80 | # No healthy backend to handle request
81 | # Return error
82 | return (synth(503, "API is down"));
83 | }
84 |
85 | sub vcl_deliver {
86 | # Don't send cache tags related headers to the client
87 | unset resp.http.url;
88 | # Comment the following line to send the "Cache-Tags" header to the client (e.g. to use CloudFlare cache tags)
89 | unset resp.http.Cache-Tags;
90 | }
91 |
92 | sub vcl_backend_response {
93 | # Ban lurker friendly header
94 | set beresp.http.url = bereq.url;
95 |
96 | # Add a grace in case the backend is down
97 | set beresp.grace = 1h;
98 | }
99 |
--------------------------------------------------------------------------------
/api/fixtures/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dunglas/demo-vulcain-api-platform/f0d66cf06827f63d5c9cfd3fede2ecedd44483f8/api/fixtures/.gitignore
--------------------------------------------------------------------------------
/api/fixtures/data.yaml:
--------------------------------------------------------------------------------
1 | App\Entity\Conference:
2 | conference_{1..10}:
3 | name: ''
4 |
5 | App\Entity\Session:
6 | session_{1..100}:
7 | conference: '@conference_*'
8 | title: ''
9 | summary: ''
10 | author: ''
11 |
12 | App\Entity\Feedback:
13 | feedback_{1..100}:
14 | session: '@session_*'
15 | comment: ''
16 | rating: ''
17 |
--------------------------------------------------------------------------------
/api/helm/api/.helmignore:
--------------------------------------------------------------------------------
1 | # Patterns to ignore when building packages.
2 | # This supports shell glob matching, relative path matching, and
3 | # negation (prefixed with !). Only one pattern per line.
4 | .DS_Store
5 | # Common VCS dirs
6 | .git/
7 | .gitignore
8 | .bzr/
9 | .bzrignore
10 | .hg/
11 | .hgignore
12 | .svn/
13 | # Common backup files
14 | *.swp
15 | *.bak
16 | *.tmp
17 | *~
18 | # Various IDEs
19 | .project
20 | .idea/
21 | *.tmproj
22 | .vscode/
23 |
--------------------------------------------------------------------------------
/api/helm/api/Chart.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | appVersion: 0.1.0
3 | description: A Helm chart for an API Platform API
4 | name: api
5 | version: 0.1.0
6 | home: https://api-platform.com
7 | icon: https://api-platform.com/logo-250x250.png
8 |
--------------------------------------------------------------------------------
/api/helm/api/requirements.lock:
--------------------------------------------------------------------------------
1 | dependencies:
2 | - name: postgresql
3 | repository: https://kubernetes-charts.storage.googleapis.com/
4 | version: 3.9.5
5 | - name: mercure
6 | repository: https://kubernetes-charts.storage.googleapis.com/
7 | version: 1.0.0
8 | digest: sha256:6466d376987cc08b70fe36945dd93474836aab05edc155955951bcb0774a0896
9 | generated: 2019-03-26T18:14:32.4074+01:00
10 |
--------------------------------------------------------------------------------
/api/helm/api/requirements.yaml:
--------------------------------------------------------------------------------
1 | dependencies:
2 | - name: postgresql
3 | version: ~3.9.0
4 | repository: https://kubernetes-charts.storage.googleapis.com/
5 | condition: postgresql.enabled
6 | - name: mercure
7 | version: ~1.0.0
8 | repository: https://kubernetes-charts.storage.googleapis.com/
9 | condition: mercure.enabled
10 |
--------------------------------------------------------------------------------
/api/helm/api/templates/NOTES.txt:
--------------------------------------------------------------------------------
1 | API deployed.
2 |
3 | To get the ingress's IP:
4 |
5 | kubectl --namespace {{ .Release.Namespace }} get ingress -o jsonpath="{.items[0].status.loadBalancer.ingress[0].ip}"
6 |
--------------------------------------------------------------------------------
/api/helm/api/templates/_helpers.tpl:
--------------------------------------------------------------------------------
1 | {{/* vim: set filetype=mustache: */}}
2 | {{/*
3 | Expand the name of the chart.
4 | */}}
5 | {{- define "name" -}}
6 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7 | {{- end -}}
8 |
9 | {{/*
10 | Create a default fully qualified app name.
11 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12 | */}}
13 | {{- define "fullname" -}}
14 | {{- $name := default .Chart.Name .Values.nameOverride -}}
15 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
16 | {{- end -}}
17 |
18 | {{- define "postgresql.fullname" -}}
19 | {{- printf "%s-%s" .Release.Name "postgresql" | trunc 63 | trimSuffix "-" -}}
20 | {{- end -}}
21 |
22 | {{/*
23 | Create chart name and version as used by the chart label.
24 | */}}
25 | {{- define "chart" -}}
26 | {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
27 | {{- end -}}
28 |
--------------------------------------------------------------------------------
/api/helm/api/templates/configmap.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: ConfigMap
3 | metadata:
4 | name: {{ template "fullname" . }}
5 | labels:
6 | app.kubernetes.io/name: {{ include "name" . }}
7 | app.kubernetes.io/part-of: {{ include "name" . }}
8 | helm.sh/chart: {{ include "chart" . }}
9 | app.kubernetes.io/instance: {{ .Release.Name }}
10 | app.kubernetes.io/managed-by: {{ .Release.Service }}
11 | data:
12 | env: {{ .Values.php.env | quote }}
13 | debug: {{ .Values.php.debug | quote }}
14 | cors-allow-origin: {{ .Values.php.corsAllowOrigin | quote }}
15 | varnish-url: {{ if .Values.varnish.url }}{{ .Values.varnish.url | quote }}{{ else }}http://varnish{{ end }}
16 | trusted-hosts: {{ .Values.php.trustedHosts | quote }}
17 | trusted-proxies: {{ join "," .Values.php.trustedProxies }}
18 | mercure-publish-url: {{ .Values.mercure.publishUrl | quote }}
19 | mercure-subscribe-url: {{ .Values.mercure.subscribeUrl | quote }}
20 |
--------------------------------------------------------------------------------
/api/helm/api/templates/ingress.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: extensions/v1beta1
2 | kind: Ingress
3 | metadata:
4 | name: {{ template "fullname" . }}
5 | labels:
6 | app.kubernetes.io/name: {{ include "name" . }}-ingress
7 | app.kubernetes.io/part-of: {{ include "name" . }}
8 | helm.sh/chart: {{ include "chart" . }}
9 | app.kubernetes.io/instance: {{ .Release.Name }}
10 | app.kubernetes.io/managed-by: {{ .Release.Service }}
11 | {{- with .Values.ingress.annotations }}
12 | annotations:
13 | {{- toYaml . | nindent 4 }}
14 | {{- end }}
15 | spec:
16 | {{- if .Values.ingress.tls }}
17 | tls:
18 | {{- range .Values.ingress.tls }}
19 | - hosts:
20 | {{- range .hosts }}
21 | - {{ .host | quote }}
22 | {{- end }}
23 | secretName: {{ .secretName }}
24 | {{- end }}
25 | {{- end }}
26 | rules:
27 | {{- range .Values.ingress.hosts }}
28 | - host: {{ .host | quote }}
29 | http:
30 | paths:
31 | - path: /*
32 | backend:
33 | serviceName: {{ .serviceName }}
34 | servicePort: {{ .servicePort | default 80 }}
35 | {{- end }}
36 |
--------------------------------------------------------------------------------
/api/helm/api/templates/nginx-deployment.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: extensions/v1beta1
2 | kind: Deployment
3 | metadata:
4 | name: {{ template "fullname" . }}-nginx
5 | labels:
6 | app.kubernetes.io/name: {{ include "name" . }}-nginx
7 | app.kubernetes.io/part-of: {{ include "name" . }}
8 | helm.sh/chart: {{ include "chart" . }}
9 | app.kubernetes.io/instance: {{ .Release.Name }}
10 | app.kubernetes.io/managed-by: {{ .Release.Service }}
11 | spec:
12 | replicas: {{ .Values.nginx.replicaCount }}
13 | template:
14 | metadata:
15 | labels:
16 | app.kubernetes.io/name: {{ include "name" . }}-nginx
17 | app.kubernetes.io/part-of: {{ include "name" . }}
18 | helm.sh/chart: {{ include "chart" . }}
19 | app.kubernetes.io/instance: {{ .Release.Name }}
20 | app.kubernetes.io/managed-by: {{ .Release.Service }}
21 | spec:
22 | containers:
23 | - name: {{ .Chart.Name }}-nginx
24 | image: "{{ .Values.nginx.repository }}:{{ .Values.nginx.tag }}"
25 | imagePullPolicy: {{ .Values.nginx.pullPolicy }}
26 | ports:
27 | - containerPort: 80
28 | resources:
29 | {{ toYaml .Values.resources | indent 12 }}
30 | {{- if .Values.nodeSelector }}
31 | nodeSelector:
32 | {{ toYaml .Values.nodeSelector | indent 8 }}
33 | {{- end }}
34 |
--------------------------------------------------------------------------------
/api/helm/api/templates/nginx-service.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Service
3 | metadata:
4 | name: api
5 | labels:
6 | app.kubernetes.io/name: {{ include "name" . }}-nginx
7 | app.kubernetes.io/part-of: {{ include "name" . }}
8 | helm.sh/chart: {{ include "chart" . }}
9 | app.kubernetes.io/instance: {{ .Release.Name }}
10 | app.kubernetes.io/managed-by: {{ .Release.Service }}
11 | spec:
12 | type: NodePort
13 | ports:
14 | - port: 80
15 | targetPort: 80
16 | protocol: TCP
17 | selector:
18 | app.kubernetes.io/name: {{ include "name" . }}-nginx
19 | app.kubernetes.io/instance: {{ .Release.Name }}
20 |
--------------------------------------------------------------------------------
/api/helm/api/templates/php-deployment.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: extensions/v1beta1
2 | kind: Deployment
3 | metadata:
4 | name: {{ template "fullname" . }}-php
5 | labels:
6 | app.kubernetes.io/name: {{ include "name" . }}-php
7 | app.kubernetes.io/part-of: {{ include "name" . }}
8 | helm.sh/chart: {{ include "chart" . }}
9 | app.kubernetes.io/instance: {{ .Release.Name }}
10 | app.kubernetes.io/managed-by: {{ .Release.Service }}
11 | spec:
12 | replicas: {{ .Values.php.replicaCount }}
13 | template:
14 | metadata:
15 | labels:
16 | app.kubernetes.io/name: {{ include "name" . }}-php
17 | app.kubernetes.io/part-of: {{ include "name" . }}
18 | helm.sh/chart: {{ include "chart" . }}
19 | app.kubernetes.io/instance: {{ .Release.Name }}
20 | app.kubernetes.io/managed-by: {{ .Release.Service }}
21 | spec:
22 | containers:
23 | - name: {{ .Chart.Name }}-php
24 | image: "{{ .Values.php.repository }}:{{ .Values.php.tag }}"
25 | imagePullPolicy: {{ .Values.php.pullPolicy }}
26 | ports:
27 | - containerPort: 9000
28 | env:
29 | - name: TRUSTED_HOSTS
30 | valueFrom:
31 | configMapKeyRef:
32 | name: {{ template "fullname" . }}
33 | key: trusted-hosts
34 | - name: TRUSTED_PROXIES
35 | valueFrom:
36 | configMapKeyRef:
37 | name: {{ template "fullname" . }}
38 | key: trusted-proxies
39 | - name: APP_ENV
40 | valueFrom:
41 | configMapKeyRef:
42 | name: {{ template "fullname" . }}
43 | key: env
44 | - name: APP_DEBUG
45 | valueFrom:
46 | configMapKeyRef:
47 | name: {{ template "fullname" . }}
48 | key: debug
49 | - name: CORS_ALLOW_ORIGIN
50 | valueFrom:
51 | configMapKeyRef:
52 | name: {{ template "fullname" . }}
53 | key: cors-allow-origin
54 | - name: VARNISH_URL
55 | valueFrom:
56 | configMapKeyRef:
57 | name: {{ template "fullname" . }}
58 | key: varnish-url
59 | - name: APP_SECRET
60 | valueFrom:
61 | secretKeyRef:
62 | name: {{ template "fullname" . }}
63 | key: secret
64 | - name: DATABASE_URL
65 | valueFrom:
66 | secretKeyRef:
67 | name: {{ template "fullname" . }}
68 | key: database-url
69 | - name: MERCURE_PUBLISH_URL
70 | valueFrom:
71 | configMapKeyRef:
72 | name: {{ template "fullname" . }}
73 | key: mercure-publish-url
74 | - name: MERCURE_SUBSCRIBE_URL
75 | valueFrom:
76 | configMapKeyRef:
77 | name: {{ template "fullname" . }}
78 | key: mercure-subscribe-url
79 | - name: MERCURE_JWT_TOKEN
80 | valueFrom:
81 | secretKeyRef:
82 | name: {{ template "fullname" . }}
83 | key: mercure-jwt-token
84 | resources:
85 | {{ toYaml .Values.resources | indent 12 }}
86 | {{- if .Values.nodeSelector }}
87 | nodeSelector:
88 | {{ toYaml .Values.nodeSelector | indent 8 }}
89 | {{- end }}
90 |
--------------------------------------------------------------------------------
/api/helm/api/templates/php-service.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Service
3 | metadata:
4 | name: php
5 | labels:
6 | app.kubernetes.io/name: {{ include "name" . }}-php
7 | app.kubernetes.io/part-of: {{ include "name" . }}
8 | helm.sh/chart: {{ include "chart" . }}
9 | app.kubernetes.io/instance: {{ .Release.Name }}
10 | app.kubernetes.io/managed-by: {{ .Release.Service }}
11 | spec:
12 | type: ClusterIP
13 | ports:
14 | - port: 9000
15 | selector:
16 | app.kubernetes.io/name: {{ include "name" . }}-php
17 | app.kubernetes.io/instance: {{ .Release.Name }}
18 |
--------------------------------------------------------------------------------
/api/helm/api/templates/secrets.yaml:
--------------------------------------------------------------------------------
1 | {{- $postgresqlServiceName := include "postgresql.fullname" . -}}
2 | apiVersion: v1
3 | kind: Secret
4 | metadata:
5 | name: {{ template "fullname" . }}
6 | labels:
7 | app.kubernetes.io/name: {{ include "name" . }}
8 | app.kubernetes.io/part-of: {{ include "name" . }}
9 | helm.sh/chart: {{ include "chart" . }}
10 | app.kubernetes.io/instance: {{ .Release.Name }}
11 | app.kubernetes.io/managed-by: {{ .Release.Service }}
12 | type: Opaque
13 | data:
14 | {{ if .Values.postgresql.enabled }}
15 | database-url: {{ printf "pgsql://%s:%s@%s/%s?serverVersion=9.6" .Values.postgresql.postgresqlUsername .Values.postgresql.postgresqlPassword $postgresqlServiceName .Values.postgresql.postgresqlDatabase | b64enc | quote }}
16 | {{ else }}
17 | database-url: {{ .Values.postgresql.url | b64enc | quote }}
18 | {{ end }}
19 | secret: {{ .Values.php.secret | default (randAlphaNum 40) | b64enc | quote }}
20 | mercure-jwt-token: {{ .Values.php.mercure.jwtToken | b64enc | quote }}
21 |
--------------------------------------------------------------------------------
/api/helm/api/templates/varnish-deployment.yaml:
--------------------------------------------------------------------------------
1 | {{- if .Values.varnish.enabled -}}
2 | apiVersion: extensions/v1beta1
3 | kind: Deployment
4 | metadata:
5 | name: {{ template "fullname" . }}-varnish
6 | labels:
7 | app.kubernetes.io/name: {{ include "name" . }}-varnish
8 | app.kubernetes.io/part-of: {{ include "name" . }}
9 | helm.sh/chart: {{ include "chart" . }}
10 | app.kubernetes.io/instance: {{ .Release.Name }}
11 | app.kubernetes.io/managed-by: {{ .Release.Service }}
12 | spec:
13 | replicas: {{ .Values.varnish.replicaCount }}
14 | template:
15 | metadata:
16 | labels:
17 | app.kubernetes.io/name: {{ include "name" . }}-varnish
18 | helm.sh/chart: {{ include "chart" . }}
19 | app.kubernetes.io/instance: {{ .Release.Name }}
20 | app.kubernetes.io/managed-by: {{ .Release.Service }}
21 | spec:
22 | containers:
23 | - name: {{ .Chart.Name }}-varnish
24 | image: "{{ .Values.varnish.repository }}:{{ .Values.varnish.tag }}"
25 | imagePullPolicy: {{ .Values.varnish.pullPolicy }}
26 | command: ["varnishd"]
27 | args: ["-F", "-f", "/etc/varnish/default.vcl", "-p", "http_resp_hdr_len=65536", "-p", "http_resp_size=98304"]
28 | ports:
29 | - containerPort: 80
30 | livenessProbe:
31 | httpGet:
32 | path: /healthz
33 | port: 80
34 | readinessProbe:
35 | httpGet:
36 | path: /healthz
37 | port: 80
38 | resources:
39 | {{ toYaml .Values.resources | indent 12 }}
40 | {{- if .Values.nodeSelector }}
41 | nodeSelector:
42 | {{ toYaml .Values.nodeSelector | indent 8 }}
43 | {{- end }}
44 | {{- end -}}
45 |
--------------------------------------------------------------------------------
/api/helm/api/templates/varnish-service.yaml:
--------------------------------------------------------------------------------
1 | {{- if .Values.varnish.enabled -}}
2 | apiVersion: v1
3 | kind: Service
4 | metadata:
5 | name: varnish
6 | labels:
7 | app.kubernetes.io/name: {{ include "name" . }}-varnish
8 | app.kubernetes.io/part-of: {{ include "name" . }}
9 | helm.sh/chart: {{ include "chart" . }}
10 | app.kubernetes.io/instance: {{ .Release.Name }}
11 | app.kubernetes.io/managed-by: {{ .Release.Service }}
12 | spec:
13 | type: NodePort
14 | ports:
15 | - port: 80
16 | targetPort: 80
17 | protocol: TCP
18 | selector:
19 | app.kubernetes.io/name: {{ include "name" . }}-varnish
20 | app.kubernetes.io/instance: {{ .Release.Name }}
21 | {{- end -}}
22 |
--------------------------------------------------------------------------------
/api/helm/api/values.yaml:
--------------------------------------------------------------------------------
1 | # Default values for api.
2 | # This is a YAML-formatted file.
3 | # Declare variables to be passed into your templates.
4 |
5 | php:
6 | repository: quay.io/api-platform/php
7 | tag: latest
8 | pullPolicy: Always
9 | replicaCount: 1
10 | mercure:
11 | jwtToken: ""
12 | env: prod
13 | debug: '0'
14 | secret: ""
15 | corsAllowOrigin: "^https?://.*?\\.example\\.com$"
16 | trustedHosts: "^.*\\.example\\.com$"
17 | trustedProxies:
18 | - 10.0.0.0/8
19 | - 172.16.0.0/12
20 | - 192.168.0.0/16
21 |
22 | nginx:
23 | repository: quay.io/api-platform/nginx
24 | tag: latest
25 | pullPolicy: Always
26 | replicaCount: 1
27 |
28 | varnish:
29 | enabled: true
30 | #url: https://example.com
31 | repository: quay.io/api-platform/varnish
32 | tag: latest
33 | pullPolicy: Always
34 | replicaCount: 1
35 |
36 | postgresql:
37 | enabled: true
38 | imageTag: 10-alpine
39 | # If bringing your own PostgreSQL, the full uri to use
40 | #url: pgsql://api-platform:!ChangeMe!@example.com/api?serverVersion=10.1
41 | postgresqlUsername: "example"
42 | postgresqlPassword: "!ChangeMe!"
43 | postgresqlDatabase: "api"
44 | # Persistent Volume Storage configuration.
45 | # ref: https://kubernetes.io/docs/user-guide/persistent-volumes
46 | persistence:
47 | enabled: false
48 | pullPolicy: IfNotPresent
49 | # image:
50 | # repository: postgres
51 | # tag: alpine
52 |
53 | mercure:
54 | enabled: true
55 | publishUrl: http://mercure/.well-known/mercure
56 | subscribeUrl: https://mercure.example.com/.well-known/mercure
57 | allowAnonymous: "1"
58 | corsAllowedOrigins: "^https?://.*?\\.example\\.com$"
59 | acmeHosts: "" # TODO: Fix the Mercure chart
60 | jwtKey: ""
61 | service:
62 | type: NodePort
63 | port: 80
64 |
65 | ingress:
66 | annotations:
67 | # kubernetes.io/ingress.global-static-ip-name: chart-ip
68 | # kubernetes.io/ingress.class: gce
69 | # kubernetes.io/tls-acme: "true"
70 | tls:
71 | # Secrets must be manually created in the namespace, you can also use cert-manager.
72 | # - hosts:
73 | # - example.com
74 | # - mercure.example.com
75 | hosts:
76 | api:
77 | host: example.com
78 | serviceName: varnish
79 | mercure:
80 | host: mercure.example.com
81 | serviceName: mercure
82 |
83 | resources: {}
84 | # We usually recommend not to specify default resources and to leave this as a conscious
85 | # choice for the user. This also increases chances charts run on environments with little
86 | # resources, such as Minikube. If you do want to specify resources, uncomment the following
87 | # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
88 | # limits:
89 | # cpu: 100m
90 | # memory: 128Mi
91 | # requests:
92 | # cpu: 100m
93 | # memory: 128Mi
94 |
--------------------------------------------------------------------------------
/api/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dunglas/demo-vulcain-api-platform/f0d66cf06827f63d5c9cfd3fede2ecedd44483f8/api/public/favicon.ico
--------------------------------------------------------------------------------
/api/public/index.php:
--------------------------------------------------------------------------------
1 | handle($request);
26 | $response->send();
27 | $kernel->terminate($request, $response);
28 |
--------------------------------------------------------------------------------
/api/public/test-max-waterfall.html:
--------------------------------------------------------------------------------
1 |
2 | Maximum waterfall: API Platform X Vulcain
3 |
33 |
This script is designed to simulate more data dependencies than they really exist to increase the waterfall effect.
34 |
--------------------------------------------------------------------------------
/api/public/test-min-waterfall.html:
--------------------------------------------------------------------------------
1 |
2 |
Minimum waterfall: API Platform X Vulcain
3 |
35 |