Skip to content

Commit 032bab3

Browse files
Add harness for Alokai
1 parent 3fa1ffa commit 032bab3

10 files changed

Lines changed: 262 additions & 3 deletions

File tree

Jenkinsfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pipeline {
3131
}
3232
stage('Build and Test') {
3333
parallel {
34-
stage('1. NextJS') {
34+
stage('1. NextJS, Alokai') {
3535
agent {
3636
docker {
3737
// Reuse the same agent selected at the top of the file
@@ -60,12 +60,15 @@ pipeline {
6060
}
6161
steps {
6262
sh './test nextjs dynamic mutagen'
63+
sh './test alokai dynamic mutagen'
6364

6465
sh './test nextjs static'
66+
sh './test alokai static'
6567

6668
sh './test nextjs dynamic'
69+
sh './test alokai dynamic'
6770
}
68-
post { failure { script { failureMessages << 'NextJS quality checks' } } }
71+
post { failure { script { failureMessages << 'NextJS and Alokai quality checks' } } }
6972
}
7073
stage('Acceptance Tests') {
7174
environment {

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Each framework will fully override a base harness file if differing behaviour is
1010
## Available Frameworks
1111

1212
- [NextJs](src/nextjs/)
13+
- [Alokai](src/alokai/)
1314

1415
## Features of each harness
1516

@@ -185,4 +186,5 @@ When you're ready to release:
185186

186187
[Workspace]: https://github.com/my127/workspace
187188
[inviqa/harness-nextjs]: https://github.com/inviqa/harness-base-node/tree/main/src/nextjs
189+
[inviqa/harness-alokai]: https://github.com/inviqa/harness-base-node/tree/main/src/alokai
188190
[my127/my127.io]: https://github.com/my127/my127.io

build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ $0 [--archive]
99
EOF
1010
}
1111

12-
HARNESSES=(nextjs)
12+
HARNESSES=(nextjs alokai)
1313
ARCHIVE=0
1414
ARGS=()
1515

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
services:
2+
middleware:
3+
{% if @('app.build' == 'static') %}
4+
build:
5+
context: ./
6+
dockerfile: .vuestorefrontcloud/docker/middleware/Dockerfile-middleware
7+
args: {{ to_nice_yaml(@('services.middleware.build.args'), 2, 8) }}
8+
{% else %}
9+
extends: console
10+
working_dir: /app/apps/storefront-middleware
11+
command: [ {{ @('node.packageManager') | json_encode }}, run, dev ]
12+
{% endif %}
13+
labels:
14+
# Traefik 1, deprecated
15+
- traefik.enable=false
16+
environment: {{ to_nice_yaml(deep_merge([
17+
@('services.middleware.environment'),
18+
@('services.middleware.environment_dynamic'),
19+
@('services.middleware.environment_secrets')
20+
]), 2, 6) }}
21+
networks:
22+
- private
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
services:
2+
nextjs:
3+
{% if @('app.build' == 'static') %}
4+
build:
5+
context: ./
6+
dockerfile: .vuestorefrontcloud/docker/nextjs/Dockerfile-frontend
7+
args: {{ to_nice_yaml(deep_merge([
8+
@('services.nextjs.build.args'),
9+
@('services.nextjs.environment')
10+
]), 2, 8) }}
11+
{% else %}
12+
extends: console
13+
working_dir: /app/apps/storefront-unified-nextjs
14+
command: [ {{ @('node.packageManager') | json_encode }}, run, dev ]
15+
{% endif %}
16+
labels:
17+
# Traefik 1, deprecated
18+
- traefik.enable=false
19+
environment: {{ to_nice_yaml(deep_merge([
20+
@('app.build') == 'dynamic' ? @('services.nextjs.build.args') : [],
21+
@('services.nextjs.environment'),
22+
@('services.nextjs.environment_dynamic'),
23+
@('services.nextjs.environment_secrets')
24+
]), 2, 6) }}
25+
networks:
26+
- private
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% if @('app.build') == 'host' %}
2+
{% for name, value in @('services.middleware.environment')|merge(@('services.middleware.environment_secrets')) %}
3+
{{ name }}={{ value }}
4+
{% endfor %}
5+
{% endif %}

src/alokai/_twig/nextjs.env.twig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{% if @('app.build') == 'host' %}
2+
{% for name, value in @('services.nextjs.build.args') | filter((value, key) => key starts with 'NEXT_PUBLIC_') %}
3+
{{ name }}={{ value }}
4+
{% endfor %}
5+
{% for name, value in @('services.nextjs.environment')|merge(@('services.nextjs.environment_secrets')) %}
6+
{{ name }}={{ value }}
7+
{% endfor %}
8+
{% endif %}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
map $http_upgrade $connection_upgrade {
2+
default upgrade;
3+
'' close;
4+
}
5+
6+
server {
7+
8+
listen 80 default_server;
9+
listen 443 ssl default_server;
10+
http2 on;
11+
12+
server_name _;
13+
14+
ssl_certificate /etc/ssl/certs/app.crt;
15+
ssl_certificate_key /etc/ssl/private/app.key;
16+
17+
set $custom_https $https;
18+
set $custom_scheme $scheme;
19+
20+
if ($http_x_forwarded_proto) {
21+
set $custom_scheme $http_x_forwarded_proto;
22+
}
23+
24+
location / {
25+
proxy_pass http://nextjs:3000;
26+
proxy_set_header Host $host;
27+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
28+
proxy_set_header X-Forwarded-Proto $custom_scheme;
29+
proxy_buffers 4 256k;
30+
proxy_buffer_size 128k;
31+
proxy_busy_buffers_size 256k;
32+
proxy_http_version 1.1;
33+
proxy_set_header Upgrade $http_upgrade;
34+
proxy_set_header Connection $connection_upgrade;
35+
}
36+
37+
location /api/ {
38+
proxy_pass http://middleware:4000/;
39+
proxy_set_header Host $host;
40+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
41+
proxy_set_header X-Forwarded-Proto $custom_scheme;
42+
proxy_buffers 4 256k;
43+
proxy_buffer_size 128k;
44+
proxy_busy_buffers_size 256k;
45+
}
46+
47+
}

src/alokai/harness.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
harness('inviqa/alokai'):
2+
description: A docker based development environment for Alokai
3+
harnessLayers:
4+
- inviqa/docker:v0.4.0
5+
require:
6+
services:
7+
- proxy
8+
confd:
9+
- harness:/
10+
---
11+
attributes:
12+
app:
13+
multistore:
14+
enabled: false
15+
code_owner: node
16+
17+
node:
18+
packageManager: yarn
19+
version: '18'
20+
21+
npm:
22+
login: true
23+
registry:
24+
# username:
25+
# password:
26+
# email: # email address ignored but field required
27+
url: https://registrynpm.storefrontcloud.io
28+
scope: '@vsf-enterprise'
29+
30+
services:
31+
console:
32+
build:
33+
from: = 'node:' ~ @('node.version') ~ '-slim'
34+
args:
35+
NPM_USER: = @('npm.registry.username')
36+
NPM_PASS: = @('npm.registry.password')
37+
NPM_EMAIL: = @('npm.registry.email')
38+
NPM_REGISTRY: = @('npm.registry.url')
39+
NPM_SCOPE: = @('npm.registry.scope')
40+
publish: false
41+
nginx:
42+
enabled: true
43+
relay:
44+
enabled: false
45+
middleware:
46+
enabled: true
47+
build:
48+
args:
49+
NPM_USER: = @('npm.registry.username')
50+
NPM_PASS: = @('npm.registry.password')
51+
NPM_EMAIL: = @('npm.registry.email')
52+
NPM_REGISTRY: = @('npm.registry.url')
53+
NPM_SCOPE: = @('npm.registry.scope')
54+
environment:
55+
### Commerce
56+
IS_MULTISTORE_ENABLED: >
57+
= @('app.build') == 'host' ? 'false'
58+
: @('alokia.multistore.enabled') ? 'true'
59+
: false
60+
# BIGCOMMERCE_API_CLIENT_ID:
61+
# BIGCOMMERCE_API_URL:
62+
# BIGCOMMERCE_STORE_ID:
63+
64+
### CMS
65+
# Contentful config
66+
# CNTF_SPACE:
67+
# CNTF_ENVIRONMENT:
68+
environment_secrets:
69+
# BIGCOMMERCE_API_CLIENT_SECRET:
70+
# BIGCOMMERCE_API_ACCESS_TOKEN:
71+
# BIGCOMMERCE_STORE_GUEST_TOKEN:
72+
# CNTF_TOKEN:
73+
nextjs:
74+
enabled: true
75+
build:
76+
args:
77+
NPM_USER: = @('npm.registry.username')
78+
NPM_PASS: = @('npm.registry.password')
79+
NPM_EMAIL: = @('npm.registry.email')
80+
NPM_REGISTRY: = @('npm.registry.url')
81+
NPM_SCOPE: = @('npm.registry.scope')
82+
83+
NEXT_PUBLIC_API_BASE_URL: >
84+
= @('app.build') == 'host' ? 'http://localhost:4000'
85+
: @('alokia.multistore.enabled') ? '/api'
86+
: 'https://' ~ @('hostname') ~ '/api'
87+
NEXT_PUBLIC_IS_MULTISTORE_ENABLED: >
88+
= @('app.build') == 'host' ? 'false'
89+
: @('alokia.multistore.enabled') ? 'true'
90+
: false
91+
92+
# Default Image Loader fetch url.
93+
# For Cloudinary check https://cloudinary.com/documentation/fetch_remote_images#fetch_and_deliver_remote_files
94+
# NEXT_PUBLIC_IMAGE_LOADER_FETCH_URL: https://res.cloudinary.com/dcqchkrzw/image/fetch/
95+
96+
# Optional. Will be used when image url will not start with http.
97+
# For Cloudinary check https://cloudinary.com/documentation/migration#lazy_migration_with_auto_upload
98+
# NEXT_PUBLIC_IMAGE_LOADER_UPLOAD_URL: https://res.cloudinary.com/vsf-sap/image/upload/
99+
environment: {} # no NEXT_PUBLIC variables supported for runtime
100+
environment_secrets:
101+
# to allow nextjs server-side talking to nginx https locally for middleware routing
102+
NODE_TLS_REJECT_UNAUTHORIZED: '0'
103+
---
104+
import:
105+
- harness/config/*.yml
106+
- harness/attributes/*.yml
107+
- harness/attributes/environment/={env('MY127WS_ENV','local')}.yml
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# this file is not considered part of the public API so changes aren't considered breaking
2+
confd('harness:/'):
3+
# inviqa/docker templates
4+
- { src: docker/image/console/Dockerfile }
5+
- { src: docker/image/console/home/.my.cnf }
6+
- { src: docker/image/console/root/entrypoint.sh }
7+
- { src: docker/image/console/root/usr/lib/task/build.sh }
8+
- { src: docker/image/console/root/usr/lib/task/database/import.sh }
9+
- { src: docker/image/console/root/usr/lib/task/init.sh }
10+
- { src: docker/image/console/root/usr/lib/task/install.sh }
11+
- { src: docker/image/console/root/usr/lib/task/migrate.sh }
12+
- { src: docker/image/console/root/usr/lib/task/rabbitmq/vhosts.sh }
13+
- { src: docker/image/console/root/usr/lib/task/welcome.sh }
14+
- { src: docker/image/lighthouse/Dockerfile }
15+
- { src: docker/image/lighthouse/root/app/run.sh }
16+
- { src: docker/image/solr/Dockerfile }
17+
- { src: docker/image/tls-offload/root/etc/nginx/conf.d/0-nginx.conf }
18+
- { src: docker/image/tls-offload/root/etc/nginx/conf.d/default.conf }
19+
- { src: docker/image/tls-offload/root/etc/ssl/certs/app.crt }
20+
- { src: docker/image/tls-offload/root/etc/ssl/private/app.key }
21+
- { src: docker/image/varnish/root/etc/varnish/default.vcl }
22+
- { src: application/overlay/Jenkinsfile }
23+
- { src: application/overlay/.dockerignore, dst: workspace:/.dockerignore }
24+
- { src: application/skeleton/README.md }
25+
- { src: mutagen.yml, dst: workspace:/mutagen.yml } # docker-compose.yml render reads this file
26+
- { src: docker-compose.yml, dst: workspace:/docker-compose.yml }
27+
- { src: harness/scripts/enable.sh }
28+
- { src: helm/app/_twig/templates/service/varnish/configmap.yaml, dst: harness:/helm/app/templates/service/varnish/configmap.yaml }
29+
- { src: helm/app/values.yaml }
30+
- { src: helm/app/values-production.yaml }
31+
- { src: helm/app/values-preview.yaml }
32+
- { src: helm/app/Chart.yaml }
33+
# node/_base templates
34+
- { src: docker/image/nginx/root/etc/nginx/conf.d/default.conf }
35+
- { src: docker/image/nginx/root/etc/ssl/certs/app.crt }
36+
- { src: docker/image/nginx/root/etc/ssl/private/app.key }
37+
# node/alokai templates
38+
- { src: _twig/middleware.env, dst: workspace:/apps/storefront-middleware/.env }
39+
- { src: _twig/nextjs.env, dst: workspace:/apps/storefront-unified-nextjs/.env }

0 commit comments

Comments
 (0)