Skip to content

Commit 4543c2d

Browse files
authored
Merge pull request #4 from catenax-ng/TRACEFOSS-565-docker
Tracefoss-565: Support usage of context path in docker file
2 parents 7c27353 + bd333cf commit 4543c2d

File tree

16 files changed

+96
-18
lines changed

16 files changed

+96
-18
lines changed

Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,17 @@ COPY --from=builder /usr/local/bin /usr/local/bin
3939

4040
# Copy NGINX server configuration
4141
COPY ./build/security-headers.conf ./build/nginx.conf /etc/nginx/
42+
43+
# Copy custom script runner
44+
COPY scripts/custom-injector.sh /docker-entrypoint.d/00-custom-injector.sh
45+
4246
# Add env variables inject script
43-
COPY ./scripts/run-inject-dynamic-env.sh /docker-entrypoint.d/00-inject-dynamic-env.sh
4447
COPY ./scripts/inject-dynamic-env.js /docker-entrypoint.d/
48+
# Add replace base url script
49+
COPY ./scripts/replace-base-href.js /docker-entrypoint.d/
50+
51+
USER root
52+
RUN chown nginx:nginx /etc/nginx/nginx.conf
53+
RUN chown nginx:nginx /etc/nginx/security-headers.conf
4554

46-
# Validate NGINX configuration
47-
RUN nginx -t
4855
USER 101

INSTALL.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const ENV_VARS_MAPPING = {
88
CATENAX_PORTAL_CLIENT_ID: 'clientId',
99
CATENAX_PORTAL_API_URL: 'apiUrl',
1010
CATENAX_PORTAL_BASE_URL: 'baseUrl',
11+
CATENAX_PORTAL_BACKEND_DOMAIN,
1112
};
1213
```
1314

@@ -23,6 +24,11 @@ This variable points to the desired api
2324
`CATENAX_PORTAL_BASE_URL`
2425
This variable is used to set the base path of the application. (Should be set if application runs as a subtopic)
2526

27+
`CATENAX_PORTAL_BACKEND_DOMAIN`
28+
This variable is needed for security, to be more explicit, for the security headers of a request.
29+
The domain of the corresponding backend should be used here.
30+
An example value could be: `catena-x.net`
31+
2632
# Helm deployment
2733

2834
## Configuration of values.yaml
@@ -102,7 +108,7 @@ When running the build docker image you are able to pass through multiple enviro
102108
### Example command:
103109
104110
```shell
105-
$ docker run -d -p 4200:8080 -e ENV_VAR=VAR_VALUE ${dockerImage}
111+
$ docker run -d -p 4200:8080 -e CATENAX_PORTAL_BASE_URL=/example -e CATENAX_PORTAL_BACKEND_DOMAIN=catena-x.net ${dockerImage}
106112
```
107113

108114
#### `Docker run`

build/nginx.conf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,19 @@ http {
3535

3636
server_tokens off;
3737

38-
location ~ /index.html|.*\.json$ {
38+
location ~ /{baseHrefPlaceholder}/index.html|/{baseHrefPlaceholder}/*\.json$ {
3939
expires -1;
4040
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
4141
include /etc/nginx/security-headers.conf;
4242
}
4343

44-
location ~ .*\.css$|.*\.js$ {
44+
location ~ /{baseHrefPlaceholder}/*\.(css|js)$ {
4545
add_header Cache-Control 'max-age=31449600'; # one year
4646
include /etc/nginx/security-headers.conf;
4747
}
4848

49-
location / {
49+
location /{baseHrefPlaceholder}/ {
50+
alias /usr/share/nginx/html/;
5051
try_files $uri$args $uri$args/ /index.html;
5152

5253
add_header Cache-Control 'max-age=86400'; # one day

build/security-headers.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_header Strict-Transport-Security "max-age=31449600; includeSubDomains" always;
2-
add_header Content-Security-Policy "default-src 'self' https://*.mapbox.com https://*.catena-x.net; object-src 'none'; script-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com https://api.mapbox.com 'self' blob:; script-src-elem 'self'; base-uri 'self'; style-src 'self' 'unsafe-inline' fonts.googleapis.com; block-all-mixed-content; font-src 'self' https: data:; frame-ancestors 'self'; img-src 'self' data:; upgrade-insecure-requests;" always;
2+
add_header Content-Security-Policy "default-src 'self' https://*.mapbox.com https://*.{backendDomain}; object-src 'none'; script-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com https://api.mapbox.com 'self' blob:; script-src-elem 'self'; base-uri 'self'; style-src 'self' 'unsafe-inline' fonts.googleapis.com; block-all-mixed-content; font-src 'self' https: data:; frame-ancestors 'self'; img-src 'self' data:; upgrade-insecure-requests;" always;
33
add_header X-Frame-Options "DENY" always;
44
add_header X-Content-Type-Options "nosniff" always;
55
add_header Referrer-Policy "strict-origin" always;

charts/traceability-foss-frontend/templates/deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ spec:
4949
value: "{{ .Values.image.CATENAX_PORTAL_KEYCLOAK_URL }}"
5050
- name: CATENAX_PORTAL_CLIENT_ID
5151
value: "{{ .Values.image.CATENAX_PORTAL_CLIENT_ID }}"
52+
- name: CATENAX_PORTAL_BASE_URL
53+
value: "{{ .Values.image.CATENAX_PORTAL_BASE_URL }}"
54+
- name: CATENAX_PORTAL_BACKEND_DOMAIN
55+
value: "{{ .Values.image.CATENAX_PORTAL_BACKEND_DOMAIN }}"
5256
ports:
5357
- name: http
5458
containerPort: {{ .Values.service.port }}

charts/traceability-foss-frontend/values-dev-test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ image:
33
tag: $ARGOCD_APP_REVISION
44
CATENAX_PORTAL_API_URL: 'https://traceability-test.dev.demo.catena-x.net/api'
55
CATENAX_PORTAL_KEYCLOAK_URL: 'https://centralidp.dev.demo.catena-x.net/auth'
6+
CATENAX_PORTAL_BACKEND_DOMAIN: 'catena-x.net'
67

78
nameOverride: "traceability-foss-test-frontend"
89
fullnameOverride: "traceability-foss-test-frontend"

charts/traceability-foss-frontend/values-dev.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ image:
22
tag: $ARGOCD_APP_REVISION
33
CATENAX_PORTAL_API_URL: 'https://traceability.dev.demo.catena-x.net/api'
44
CATENAX_PORTAL_KEYCLOAK_URL: 'https://centralidp.dev.demo.catena-x.net/auth'
5+
CATENAX_PORTAL_BACKEND_DOMAIN: 'catena-x.net'
56

67
ingress:
78
enabled: true

charts/traceability-foss-frontend/values-int-test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ image:
22
tag: $ARGOCD_APP_REVISION
33
CATENAX_PORTAL_API_URL: 'https://traceability-test.int.demo.catena-x.net/api'
44
CATENAX_PORTAL_KEYCLOAK_URL: 'https://centralidp.int.demo.catena-x.net/auth'
5+
CATENAX_PORTAL_BACKEND_DOMAIN: 'catena-x.net'
56

67
nameOverride: "traceability-foss-test-frontend"
78
fullnameOverride: "traceability-foss-test-frontend"

charts/traceability-foss-frontend/values-int.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ image:
22
tag: $ARGOCD_APP_REVISION
33
CATENAX_PORTAL_API_URL: 'https://traceability.int.demo.catena-x.net/api'
44
CATENAX_PORTAL_KEYCLOAK_URL: 'https://centralidp.int.demo.catena-x.net/auth'
5+
CATENAX_PORTAL_BACKEND_DOMAIN: 'catena-x.net'
56

67
ingress:
78
enabled: true

charts/traceability-foss-frontend/values-pen.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ image:
22
tag: $ARGOCD_APP_REVISION
33
CATENAX_PORTAL_API_URL: 'https://traceability-pen.dev.demo.catena-x.net/api'
44
CATENAX_PORTAL_KEYCLOAK_URL: 'https://centralidp-pen.dev.demo.catena-x.net/auth'
5+
CATENAX_PORTAL_BACKEND_DOMAIN: 'catena-x.net'
56

67
# important to not conflict with dev env (both use same ArgoCD instance)
78
namespace: product-traceability-foss-pen

0 commit comments

Comments
 (0)