Skip to content

Commit

Permalink
SC-6257: Gateway and BackOffice application (#193)
Browse files Browse the repository at this point in the history
* SC-6257: Gateway application

* SC-6257: Rename newly introduced enpoints

* Update index.php

* Remove session from gateway

* SC-5500: Enpoints separation. Docs. Follow up (#210)

* Add Backend-gateway application type

* Update index.php
  • Loading branch information
alexanderM91 authored Jun 1, 2021
1 parent 1fce19f commit a4296d5
Show file tree
Hide file tree
Showing 27 changed files with 362 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Learn how to convert a project into a Docker based instance in [Integrating the

## Running production

Currently, there is no installation guide for deploying Spryker in Docker in a production environment. But you can generate the images suitable for a production environment and the archives with assets for each application - Yves, Zed, Glue, and MerchantPortal.
Currently, there is no installation guide for deploying Spryker in Docker in a production environment. But you can generate the images suitable for a production environment and the archives with assets for each application - Yves, BackOffice(Zed), Backend-Gateway, Glue, , and MerchantPortal.

Learn how to generate Docker images and assets for a production environment in [Running production](07-running-production.md).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ docker/sdk up

9. Update the `hosts` file:
```bash
echo "127.0.0.1 zed.de.spryker.local yves.de.spryker.local glue.de.spryker.local zed.at.spryker.local yves.at.spryker.local glue.at.spryker.local zed.us.spryker.local yves.us.spryker.local glue.us.spryker.local mail.spryker.local scheduler.spryker.local queue.spryker.local" | sudo tee -a /etc/hosts
echo "127.0.0.1 backoffice.de.spryker.local backend-gateway.de.spryker.local backend-api.de.spryker.local yves.de.spryker.local glue.de.spryker.local backoffice.at.spryker.local backend-gateway.at.spryker.local backend-api.at.spryker.local yves.at.spryker.local glue.at.spryker.local backoffice.us.spryker.local backend-gateway.us.spryker.local backend-api.us.spryker.local yves.us.spryker.local glue.us.spryker.local mail.spryker.local scheduler.spryker.local queue.spryker.local" | sudo tee -a /etc/hosts
```
@(Info)()(If needed, add corresponding entries for other stores. For example, if you are going to have a US store, add the following entries: `zed.us.spryker.local glue.us.spryker.local yves.us.spryker.local`)
@(Info)()(If needed, add corresponding entries for other stores. For example, if you are going to have a US store, add the following entries: `backoffice.us.spryker.local backend-gateway.us.spryker.local backend-api.us.spryker.local glue.us.spryker.local yves.us.spryker.local`)

@(Warning)()(Depending on the hardware performance, the first project launch can take up to 20 minutes.)

Expand All @@ -92,7 +92,7 @@ To ensure that the installation is successful, make sure you can access the foll
| Application | Endpoints |
| --- | --- |
| The Storefront | yves.de.spryker.local, yves.at.spryker.local, yves.us.spryker.local |
| The Back Office | zed.de.spryker.local, zed.at.spryker.local, zed.us.spryker.local |
| the Back Office | backoffice.de.spryker.local, backoffice.at.spryker.local, backoffice.us.spryker.local |
| Glue API | glue.de.spryker.local, glue.at.spryker.local, glue.us.spryker.local |
| The Merchant Portal | mp.de.spryker.local, mp.at.spryker.local, mp.us.spryker.local |
| Jenkins (scheduler) | scheduler.spryker.local |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ docker/sdk up
The hosts file opens in the drop-down.
8. Add the following line into the file:
```text
127.0.0.1 zed.de.spryker.local glue.de.spryker.local yves.de.spryker.local scheduler.spryker.local mail.spryker.local queue.spryker.local
127.0.0.1 backoffice.de.spryker.local backend-gateway.de.spryker.local backend-api.de.spryker.local glue.de.spryker.local yves.de.spryker.local scheduler.spryker.local mail.spryker.local queue.spryker.local
```
@(Info)()(If needed, add corresponding entries for other stores. For example, if you are going to have a US store, add the following entries: `zed.us.spryker.local glue.us.spryker.local yves.us.spryker.local`)
@(Info)()(If needed, add corresponding entries for other stores. For example, if you are going to have a US store, add the following entries: `backoffice.us.spryker.local backend-gateway.us.spryker.local backend-api.us.spryker.local glue.us.spryker.local yves.us.spryker.local`)
9. Select **File** > **Save**.
10. Close the file.

Expand All @@ -115,7 +115,7 @@ To ensure that the installation is successful, make sure you can access the foll
| Application | Endpoints |
| --- | --- |
| The Storefront | yves.de.spryker.local, yves.at.spryker.local, yves.us.spryker.local |
| the Back Office | zed.de.spryker.local, zed.at.spryker.local, zed.us.spryker.local |
| the Back Office | backoffice.de.spryker.local, backoffice.at.spryker.local, backoffice.us.spryker.local |
| Glue API | glue.de.spryker.local, glue.at.spryker.local, glue.us.spryker.local |
| The Merchant Portal | mp.de.spryker.local, mp.at.spryker.local, mp.us.spryker.local |
| Jenkins (scheduler) | scheduler.spryker.local |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ docker/sdk up
8. Update the `hosts` file:
```bash
echo "127.0.0.1 zed.de.spryker.local yves.de.spryker.local glue.de.spryker.local zed.at.spryker.local yves.at.spryker.local glue.at.spryker.local zed.us.spryker.local yves.us.spryker.local glue.us.spryker.local mail.spryker.local scheduler.spryker.local queue.spryker.local" | sudo tee -a /etc/hosts
echo "127.0.0.1 backoffice.de.spryker.local backend-gateway.de.spryker.local backend-api.de.spryker.local yves.de.spryker.local glue.de.spryker.local backoffice.at.spryker.local backend-gateway.at.spryker.local backend-api.at.spryker.local yves.at.spryker.local glue.at.spryker.local backoffice.us.spryker.local backend-gateway.us.spryker.local backend-api.us.spryker.local yves.us.spryker.local glue.us.spryker.local mail.spryker.local scheduler.spryker.local queue.spryker.local" | sudo tee -a /etc/hosts
```
@(Info)()(If needed, add corresponding entries for other stores. For example, if you are going to have a US store, add the following entries: `zed.us.spryker.local glue.us.spryker.local yves.us.spryker.local`)
@(Info)()(If needed, add corresponding entries for other stores. For example, if you are going to have a US store, add the following entries: `backoffice.us.spryker.local backend-gateway.us.spryker.local backend-api.us.spryker.local glue.us.spryker.local yves.us.spryker.local`)
@(Warning)()(Depending on the hardware performance, the first project launch can take up to 20 minutes.)
Expand All @@ -90,7 +90,7 @@ To ensure that the installation is successful, make sure you can access the foll
| Application | Endpoints |
| --- | --- |
| The Storefront | yves.de.spryker.local, yves.at.spryker.local, yves.us.spryker.local |
| the Back Office | zed.de.spryker.local, zed.at.spryker.local, zed.us.spryker.local |
| the Back Office | backoffice.de.spryker.local, backoffice.at.spryker.local, backoffice.us.spryker.local |
| Glue API | glue.de.spryker.local, glue.at.spryker.local, glue.us.spryker.local |
| The Merchant Portal | mp.de.spryker.local, mp.at.spryker.local, mp.us.spryker.local |
| Jenkins (scheduler) | scheduler.spryker.local |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ docker/sdk up
The hosts file opens in the drop-down.
8. Add the following line into the file:
```text
127.0.0.1 zed.de.spryker.local glue.de.spryker.local yves.de.spryker.local scheduler.spryker.local mail.spryker.local queue.spryker.local
127.0.0.1 backoffice.de.spryker.local backend-gateway.de.spryker.local backend-api.de.spryker.local glue.de.spryker.local yves.de.spryker.local scheduler.spryker.local mail.spryker.local queue.spryker.local
```
@(Info)()(If needed, add corresponding entries for other stores. For example, if you are going to have a US store, add the following entries: `zed.us.spryker.local glue.us.spryker.local yves.us.spryker.local`)
@(Info)()(If needed, add corresponding entries for other stores. For example, if you are going to have a US store, add the following entries: `backoffice.us.spryker.local backend-gateway.us.spryker.local backend-api.us.spryker.local glue.us.spryker.local yves.us.spryker.local`)
9. Select **File** > **Save**.
10. Close the file.
Expand All @@ -103,7 +103,7 @@ To ensure that the installation is successful, make sure you can access the foll
| Application | Endpoints |
| --- | --- |
| The Storefront | yves.de.spryker.local, yves.at.spryker.local, yves.us.spryker.local |
| the Back Office | zed.de.spryker.local, zed.at.spryker.local, zed.us.spryker.local |
| the Back Office | backoffice.de.spryker.local, backoffice.at.spryker.local, backoffice.us.spryker.local |
| Glue API | glue.de.spryker.local, glue.at.spryker.local, glue.us.spryker.local |
| The Merchant Portal | mp.de.spryker.local, mp.at.spryker.local, mp.us.spryker.local |
| Jenkins (scheduler) | scheduler.spryker.local |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ To ensure that the installation is successful, make sure you can access the foll
| Application | Endpoints |
| --- | --- |
| The Storefront | yves.de.spryker.local, yves.at.spryker.local, yves.us.spryker.local |
| the Back Office | zed.de.spryker.local, zed.at.spryker.local, zed.us.spryker.local |
| the Back Office | backoffice.de.spryker.local, backoffice.at.spryker.local, backoffice.us.spryker.local |
| Glue API | glue.de.spryker.local, glue.at.spryker.local, glue.us.spryker.local |
| The Merchant Portal | mp.de.spryker.local, mp.at.spryker.local, mp.us.spryker.local |
| Jenkins (scheduler) | scheduler.spryker.local |
Expand Down
2 changes: 1 addition & 1 deletion docs/09-troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ docker/sdk up
### An application is not reachable via http
**when**
An application like Yves, Zed, Glue, or MerchantPortal is not reachable after installation.
An application like Yves, BackOffice(Zed), Glue, or MerchantPortal is not reachable after installation.
**then**
In `deploy.*.yml`, ensure that SSL encryption is disabled:
Expand Down
4 changes: 2 additions & 2 deletions docs/10-configuration-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ To increase maximum upload size, update `deploy.*.yml` as follows:
```yaml
...
applications:
zed:
application: zed
backoffice:
application: backoffice
http:
max-request-body-size: {request_body_size_value}
...
Expand Down
60 changes: 30 additions & 30 deletions docs/99-deploy.file.reference.v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This reference page describes version 1 of the Deploy file format. This is the n
<dd>A store related context a request is processed in.</dd>

<dt>Application</dt>
<dd>A Spryker application, like Zed, Yves, Glue or MerchantPortal.</dd>
<dd>A Spryker application, like Backoffice(Zed), Backend-Gateway, Yves, Glue or MerchantPortal.</dd>

<dt>Service</dt>
<dd>An external storage or utility service. Represents service type and configuration. The configuration can be defined on different levels: project-wide, region-wide, store-specific or endpoint-specific with limitations based on the service type.</dd>
Expand Down Expand Up @@ -235,28 +235,28 @@ groups:
BACKEND-1:
region: REGION-1
applications:
zed_1:
application: zed
backoffice_1:
application: backoffice
endpoints:
zed.store1.spryker.local:
backoffice.store1.spryker.local:
store: STORE-1
services:
# Application-Store-specific services settings
zed.store2.spryker.local:
backoffice.store2.spryker.local:
store: STORE-2
services:
# Application-Store-specific services settings
merchant_portal_1:
application: merchant-portal
endpoints:
mp.store1.spryker.local:
store: STORE-1
services:
# Application-Store-specific services settings
mp.store2.spryker.local:
store: STORE-2
services:
# Application-Store-specific services settings
application: merchant-portal
endpoints:
mp.store1.spryker.local:
store: STORE-1
services:
# Application-Store-specific services settings
mp.store2.spryker.local:
store: STORE-2
services:
# Application-Store-specific services settings
STOREFRONT-1:
region: REGION-1
applications:
Expand All @@ -267,7 +267,7 @@ groups:
store: STORE-1
services:
# Application-Store-specific services settings
yves.astore2t.spryker.local:
yves.store2.spryker.local:
store: STORE-2
services:
# Application-Store-specific services settings
Expand All @@ -289,15 +289,15 @@ groups:
BACKEND-1:
region: REGION-1
applications:
zed_store_1:
application: zed
backoffice_store_1:
application: backoffice
endpoints:
zed.store1.spryker.local:
backoffice.store1.spryker.local:
store: STORE-1
zed_store_2:
application: zed
backoffice_store_2:
application: backoffice
endpoints:
zed.store2.spryker.local:
backoffice.store2.spryker.local:
store: STORE-2
```
Expand All @@ -312,7 +312,7 @@ The key must be project-wide unique.

Obligatory parameters for `application:`:

* `groups: applications: application:` - defines the type of *Application*. Possible values are `zed`, `yves`, `glue`, and `merchant-portal`.
* `groups: applications: application:` - defines the type of *Application*. Possible values are `backoffice(zed)`, `backend-gateway`, `yves`, `glue` and `merchant-portal`.
* `groups: applications: endpoints:` - defines the list of *Endpoints* to access the *Application*. See [groups: applications: endpoints:](#groups-applications-endpoints-) to learn more.

Optional parameters for `application:`:
Expand All @@ -335,20 +335,20 @@ Optional parameters for `application:`:

* `groups: applications: application: endpoints: primal:` - defines if a ZED endpoint is primal for a store. Yves and Glue applications send Zed RPC calls to the primal endpoint. This variable is optional with the default value of `false`. If no endpoint is defined as primal for a store, the first endpoint in descending order is considered primal.
* `groups: applications: application: http: max-request-body-size:` - defines the maximum allowed size of the request body that can be sent to the application, in MB. If not specified, the default values apply:
* `zed` - `10m`
* `merchant-portal` - `10m`
* `backoffice` - `10m`
* `merchant-portal` - `10m`
* `glue` - `2m`
* `yves` - `1m`

```yaml
...
applications:
zed:
application: zed
backoffice:
application: backoffice
http:
max-request-body-size: 20m
endpoints:
zed.store1.spryker.local:
backoffice.store1.spryker.local:
store: STORE-1
```

Expand All @@ -357,8 +357,8 @@ Optional parameters for `application:`:
```yaml
...
applications:
zed:
application: zed
backoffice:
application: backoffice
limits:
workers: 4
...
Expand Down
54 changes: 50 additions & 4 deletions generator/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,29 @@ public function setIsActive(bool $isActive): void

verbose('Generating ENV files... [DONE]');

const YVES_APP = 'yves';
const ZED_APP = 'zed';
const GLUE_APP = 'glue';
const BACKOFFICE_APP = 'backoffice';
const BACKEND_GATEWAY_APP = 'backend-gateway';
const MERCHANT_PORTAL = 'merchant-portal';

const ENTRY_POINTS = [
BACKOFFICE_APP => 'Backoffice',
BACKEND_GATEWAY_APP => 'BackendGateway',
ZED_APP => 'Zed',
YVES_APP => 'Yves',
GLUE_APP => 'Glue',
MERCHANT_PORTAL => 'MerchantPortal',
];

foreach ($projectData['groups'] ?? [] as $groupName => $groupData) {
foreach ($groupData['applications'] ?? [] as $applicationName => $applicationData) {
foreach ($applicationData['endpoints'] ?? [] as $endpoint => $endpointData) {
if ($endpointData === null) {
$endpointData = [];
}
$entryPoint = $endpointData['entry-point'] ?? str_replace('-', '', ucwords(strtolower($applicationData['application']), '-'));
$entryPoint = $endpointData['entry-point'] ?? str_replace('-', '', ucwords(strtolower(ENTRY_POINTS[$applicationData['application']]), '-'));
$projectData['_entryPoints'][$entryPoint] = $entryPoint;
$projectData['groups'][$groupName]['applications'][$applicationName]['endpoints'][$endpoint]['entry-point'] = $entryPoint;

Expand Down Expand Up @@ -189,12 +205,38 @@ public function setIsActive(bool $isActive): void
}
}

$endpointMap = $projectData['_endpointMap'];
$endpointMap = $projectData['_endpointMap'] = mapBackendEndpointsWithFallbackZed($projectData['_endpointMap']);

$projectData['_applications'] = [];
$frontend = [];
$environment = [
'project' => $projectData['namespace'],
];

/**
* @param array $endpointMap
*
* @return array
*/
function mapBackendEndpointsWithFallbackZed(array $endpointMap): array
{
$zedApplicationsToCheck = [
BACKOFFICE_APP,
BACKEND_GATEWAY_APP,
];

foreach ($zedApplicationsToCheck as $zedApplicationToCheck) {
foreach ($endpointMap as $store => $storeEndpointMap) {
if (array_key_exists($zedApplicationToCheck, $storeEndpointMap)) {
continue;
}
$endpointMap[$store][$zedApplicationToCheck] = $storeEndpointMap[ZED_APP];
}
}

return $endpointMap;
}

foreach ($projectData['groups'] ?? [] as $groupName => $groupData) {
foreach ($groupData['applications'] ?? [] as $applicationName => $applicationData) {
if ($applicationData['application'] !== 'static') {
Expand Down Expand Up @@ -257,7 +299,11 @@ static function ($endpoint) use ($projectData) {
);
}

if ($applicationData['application'] === 'zed' || $applicationData['application'] === 'merchant-portal') {
if ($applicationData['application'] === ZED_APP
|| $applicationData['application'] === BACKEND_GATEWAY_APP
|| $applicationData['application'] === BACKOFFICE_APP
|| $applicationData['application'] === MERCHANT_PORTAL
) {
$services = [];

if (array_key_exists('store', $endpointData)) {
Expand Down Expand Up @@ -300,7 +346,7 @@ static function ($endpoint) use ($projectData) {
$envVarEncoder->setIsActive(false);
}

if ($applicationData['application'] === 'yves') {
if ($applicationData['application'] === YVES_APP) {
$services = [];

$isEndpointDataHasStore = array_key_exists('store', $endpointData);
Expand Down
22 changes: 22 additions & 0 deletions generator/src/templates/application/backend-gateway.yml.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{ applicationName | lower }}:
image: ${SPRYKER_DOCKER_PREFIX}_run_app:${SPRYKER_DOCKER_TAG}-{{ applicationName | lower }}
depends_on:
- database
- broker
- key_value_store
- search
networks:
- private
labels:
'spryker.app.name': {{ applicationName }}
'spryker.app.type': zed-gateway
'spryker.project': ${SPRYKER_DOCKER_PREFIX}:${SPRYKER_DOCKER_TAG}
env_file:
- ${DEPLOYMENT_PATH}/env/{{ applicationName }}.env
environment:
SPRYKER_TESTING_ENABLED: ${SPRYKER_TESTING_ENABLE}
SPRYKER_XDEBUG_HOST_IP: ${SPRYKER_XDEBUG_HOST_IP}
TIDEWAYS_APIKEY: ${TIDEWAYS_APIKEY}
TIDEWAYS_CLI_ENABLED: ${TIDEWAYS_CLI_ENABLED}
TIDEWAYS_ENVIRONMENT_NAME: ${TIDEWAYS_ENVIRONMENT_NAME}
<<: *app-volumes
23 changes: 23 additions & 0 deletions generator/src/templates/application/backoffice.yml.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{ applicationName | lower }}:
image: ${SPRYKER_DOCKER_PREFIX}_run_app:${SPRYKER_DOCKER_TAG}-{{ applicationName | lower }}
depends_on:
- database
- broker
- key_value_store
- session
- search
networks:
- private
labels:
'spryker.app.name': {{ applicationName }}
'spryker.app.type': zed-backoffice
'spryker.project': ${SPRYKER_DOCKER_PREFIX}:${SPRYKER_DOCKER_TAG}
env_file:
- ${DEPLOYMENT_PATH}/env/{{ applicationName }}.env
environment:
SPRYKER_TESTING_ENABLED: ${SPRYKER_TESTING_ENABLE}
SPRYKER_XDEBUG_HOST_IP: ${SPRYKER_XDEBUG_HOST_IP}
TIDEWAYS_APIKEY: ${TIDEWAYS_APIKEY}
TIDEWAYS_CLI_ENABLED: ${TIDEWAYS_CLI_ENABLED}
TIDEWAYS_ENVIRONMENT_NAME: ${TIDEWAYS_ENVIRONMENT_NAME}
<<: *app-volumes
Loading

0 comments on commit a4296d5

Please sign in to comment.