From 889a7cdd24dda04a139b2b77d626e984d6db6781 Mon Sep 17 00:00:00 2001 From: roschaefer Date: Tue, 17 Sep 2019 02:20:24 +0200 Subject: [PATCH 001/116] Intermediate commit --- deployment/helm/human-connection/.helmignore | 22 +++++++++++++++++++ deployment/helm/human-connection/Chart.yaml | 5 +++++ .../human-connection/templates/configmap.yml | 21 ++++++++++++++++++ deployment/helm/human-connection/values.yaml | 1 + 4 files changed, 49 insertions(+) create mode 100644 deployment/helm/human-connection/.helmignore create mode 100644 deployment/helm/human-connection/Chart.yaml create mode 100644 deployment/helm/human-connection/templates/configmap.yml create mode 100644 deployment/helm/human-connection/values.yaml diff --git a/deployment/helm/human-connection/.helmignore b/deployment/helm/human-connection/.helmignore new file mode 100644 index 000000000..50af03172 --- /dev/null +++ b/deployment/helm/human-connection/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/deployment/helm/human-connection/Chart.yaml b/deployment/helm/human-connection/Chart.yaml new file mode 100644 index 000000000..ab0d80bb1 --- /dev/null +++ b/deployment/helm/human-connection/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: human-connection +version: 0.1.0 diff --git a/deployment/helm/human-connection/templates/configmap.yml b/deployment/helm/human-connection/templates/configmap.yml new file mode 100644 index 000000000..82973fd69 --- /dev/null +++ b/deployment/helm/human-connection/templates/configmap.yml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-configmap +dath: + SMTP_HOST: "mailserver.human-connection" + SMTP_PORT: "25" + GRAPHQL_PORT: "4000" + GRAPHQL_URI: "http://nitro-backend.human-connection:4000" + NEO4J_URI: "bolt://nitro-neo4j.human-connection:7687" + NEO4J_AUTH: "none" + CLIENT_URI: "https://{{ .Values.domain }}" + NEO4J_apoc_import_file_enabled: "true" + NEO4J_dbms_memory_pagecache_size: "490M" + NEO4J_dbms_memory_heap_max__size: "500M" + NEO4J_dbms_memory_heap_initial__size: "500M" + NEO4J_dbms_security_procedures_unrestricted: "algo.*,apoc.*" + VERSION: "0.1.0" + SENTRY_DSN_WEBAPP: "" + SENTRY_DSN_BACKEND: "" + COMMIT: "" diff --git a/deployment/helm/human-connection/values.yaml b/deployment/helm/human-connection/values.yaml new file mode 100644 index 000000000..0fe0dc898 --- /dev/null +++ b/deployment/helm/human-connection/values.yaml @@ -0,0 +1 @@ +domain: nitro-staging.human-connection.org From caf2bc79cfa343d90e6550e4808fa72478c28d56 Mon Sep 17 00:00:00 2001 From: roschaefer Date: Tue, 17 Sep 2019 13:41:49 +0200 Subject: [PATCH 002/116] Start to write a helm chart for Human Connection --- deployment/helm/human-connection/Chart.yaml | 2 +- .../human-connection/templates/configmap.yml | 28 ++++++------ .../templates/deployment-backend.yaml | 45 +++++++++++++++++++ deployment/helm/human-connection/values.yaml | 31 +++++++++++++ 4 files changed, 90 insertions(+), 16 deletions(-) create mode 100644 deployment/helm/human-connection/templates/deployment-backend.yaml diff --git a/deployment/helm/human-connection/Chart.yaml b/deployment/helm/human-connection/Chart.yaml index ab0d80bb1..1cfe9378b 100644 --- a/deployment/helm/human-connection/Chart.yaml +++ b/deployment/helm/human-connection/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v1 appVersion: "1.0" -description: A Helm chart for Kubernetes +description: A Helm chart for Human Connection name: human-connection version: 0.1.0 diff --git a/deployment/helm/human-connection/templates/configmap.yml b/deployment/helm/human-connection/templates/configmap.yml index 82973fd69..d298f1b08 100644 --- a/deployment/helm/human-connection/templates/configmap.yml +++ b/deployment/helm/human-connection/templates/configmap.yml @@ -3,19 +3,17 @@ kind: ConfigMap metadata: name: {{ .Release.Name }}-configmap dath: - SMTP_HOST: "mailserver.human-connection" - SMTP_PORT: "25" - GRAPHQL_PORT: "4000" - GRAPHQL_URI: "http://nitro-backend.human-connection:4000" - NEO4J_URI: "bolt://nitro-neo4j.human-connection:7687" - NEO4J_AUTH: "none" + GRAPHQL_URI: "http://{{ .Release.Name }}-backend:4000" + NEO4J_URI: "bolt://{{ .Release.Name }}-neo4j:7687" CLIENT_URI: "https://{{ .Values.domain }}" - NEO4J_apoc_import_file_enabled: "true" - NEO4J_dbms_memory_pagecache_size: "490M" - NEO4J_dbms_memory_heap_max__size: "500M" - NEO4J_dbms_memory_heap_initial__size: "500M" - NEO4J_dbms_security_procedures_unrestricted: "algo.*,apoc.*" - VERSION: "0.1.0" - SENTRY_DSN_WEBAPP: "" - SENTRY_DSN_BACKEND: "" - COMMIT: "" + NEO4J_apoc_import_file_enabled: {{ .Values.neo4j.apoc_import_file_enabled }} + NEO4J_dbms_memory_pagecache_size: {{ .Values.neo4j.dbms_memory_pagecache_size }} + NEO4J_dbms_memory_heap_max__size: {{ .Values.neo4j.dbms_memory_heap_max__size }} + NEO4J_dbms_memory_heap_initial__size: {{ .Values.neo4j.dbms_memory_heap_initial__size }} + NEO4J_dbms_security_procedures_unrestricted: {{ .Values.neo4j.dbms_security_procedures_unrestricted }} + VERSION: {{ .Chart.AppVersion }} + SENTRY_DSN_WEBAPP: {{ .Values.sentry.dsn_webapp }} + SENTRY_DSN_BACKEND: {{ .Values.sentry.dsn_backend }} + COMMIT: {{ .Values.commit }} + SMTP_HOST: {{ .Values.smtp.host }} + SMTP_PORT: {{ .Values.smtp.port }} diff --git a/deployment/helm/human-connection/templates/deployment-backend.yaml b/deployment/helm/human-connection/templates/deployment-backend.yaml new file mode 100644 index 000000000..596036fd2 --- /dev/null +++ b/deployment/helm/human-connection/templates/deployment-backend.yaml @@ -0,0 +1,45 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-backend +spec: + replicas: 1 + minReadySeconds: 15 + progressDeadlineSeconds: 60 + strategy: + rollingUpdate: + maxSurge: 0 + maxUnavailable: "100%" + selector: + matchLabels: + human-connection.org/selector: deployment-backend + template: + metadata: + name: deployment-backend + annotations: + backup.velero.io/backup-volumes: uploads + labels: + human-connection.org/commit: {{ .Values.commit }} + human-connection.org/selector: deployment-backend + spec: + containers: + - name: backend + image: humanconnection/nitro-backend:latest + imagePullPolicy: {{ .Values.pullPolicy }} + ports: + - containerPort: 4000 + envFrom: + - configMapRef: + name: {{ .Release.Name }}-configmap + - secretRef: + name: {{ .Release.Name }}-secrets + # volumeMounts: + # - mountPath: /nitro-backend/public/uploads + # name: uploads + # volumes: + # - name: uploads + # persistentVolumeClaim: + # claimName: uploads-claim + restartPolicy: Always + terminationGracePeriodSeconds: 30 +status: {} diff --git a/deployment/helm/human-connection/values.yaml b/deployment/helm/human-connection/values.yaml index 0fe0dc898..c15537a83 100644 --- a/deployment/helm/human-connection/values.yaml +++ b/deployment/helm/human-connection/values.yaml @@ -1 +1,32 @@ domain: nitro-staging.human-connection.org +commit: 889a7cdd24dda04a139b2b77d626e984d6db6781 +pullPolicy: Always + +# configs +smtp: + host: "mailserver.human-connection" + port: "25" +neo4j: + apoc_import_file_enabled: "true" + dbms_memory_pagecache_size: "490M" + dbms_memory_heap_max__size: "500M" + dbms_memory_heap_initial__size: "500M" + dbms_security_procedures_unrestricted: "algo.*,apoc.*" +sentry: + dsn_webapp: + dsn_backend: + +# secrets +jwt_secret: b/&&7b78BF&fv/Vd +private_key_passphrase: a7dsf78sadg87ad87sfagsadg78 +mapbox: + token: pk.eyJ1IjoiaHVtYW4tY29ubmVjdGlvbiIsImEiOiJjajl0cnBubGoweTVlM3VwZ2lzNTNud3ZtIn0.KZ8KK9l70omjXbEkkbHGsQ +mongodb: + username: + password: +neo4j: + username: + password: +smtp: + username: + password: From a2a71975abdba9a806add1477da0e0f14a6f7700 Mon Sep 17 00:00:00 2001 From: roschaefer Date: Tue, 17 Sep 2019 20:01:34 +0200 Subject: [PATCH 003/116] Templates for webapp+neo4j, use camelCase --- .../human-connection/templates/configmap.yml | 13 ++--- .../templates/deployment-neo4j.yaml | 55 +++++++++++++++++++ .../templates/deployment-web.yaml | 37 +++++++++++++ deployment/helm/human-connection/values.yaml | 35 +++++------- 4 files changed, 110 insertions(+), 30 deletions(-) create mode 100644 deployment/helm/human-connection/templates/deployment-neo4j.yaml create mode 100644 deployment/helm/human-connection/templates/deployment-web.yaml diff --git a/deployment/helm/human-connection/templates/configmap.yml b/deployment/helm/human-connection/templates/configmap.yml index d298f1b08..8be7b517e 100644 --- a/deployment/helm/human-connection/templates/configmap.yml +++ b/deployment/helm/human-connection/templates/configmap.yml @@ -6,14 +6,9 @@ dath: GRAPHQL_URI: "http://{{ .Release.Name }}-backend:4000" NEO4J_URI: "bolt://{{ .Release.Name }}-neo4j:7687" CLIENT_URI: "https://{{ .Values.domain }}" - NEO4J_apoc_import_file_enabled: {{ .Values.neo4j.apoc_import_file_enabled }} - NEO4J_dbms_memory_pagecache_size: {{ .Values.neo4j.dbms_memory_pagecache_size }} - NEO4J_dbms_memory_heap_max__size: {{ .Values.neo4j.dbms_memory_heap_max__size }} - NEO4J_dbms_memory_heap_initial__size: {{ .Values.neo4j.dbms_memory_heap_initial__size }} - NEO4J_dbms_security_procedures_unrestricted: {{ .Values.neo4j.dbms_security_procedures_unrestricted }} VERSION: {{ .Chart.AppVersion }} - SENTRY_DSN_WEBAPP: {{ .Values.sentry.dsn_webapp }} - SENTRY_DSN_BACKEND: {{ .Values.sentry.dsn_backend }} + SENTRY_DSN_WEBAPP: {{ .Values.sentryDsnWebapp }} + SENTRY_DSN_BACKEND: {{ .Values.sentryDsnBackend }} COMMIT: {{ .Values.commit }} - SMTP_HOST: {{ .Values.smtp.host }} - SMTP_PORT: {{ .Values.smtp.port }} + SMTP_HOST: {{ .Values.smtpHost }} + SMTP_PORT: {{ .Values.smtpPort }} diff --git a/deployment/helm/human-connection/templates/deployment-neo4j.yaml b/deployment/helm/human-connection/templates/deployment-neo4j.yaml new file mode 100644 index 000000000..692533abf --- /dev/null +++ b/deployment/helm/human-connection/templates/deployment-neo4j.yaml @@ -0,0 +1,55 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-neo4j +spec: + replicas: 1 + strategy: + rollingUpdate: + maxSurge: 0 + maxUnavailable: "100%" + selector: + matchLabels: + human-connection.org/selector: deployment-neo4j + template: + metadata: + name: neo4j + annotations: + backup.velero.io/backup-volumes: neo4j-data + labels: + human-connection.org/commit: {{ .Values.commit }} + human-connection.org/selector: deployment-neo4j + spec: + containers: + - name: neo4j + image: humanconnection/neo4j:latest + imagePullPolicy: {{ .Values.pullPolicy }} + ports: + - containerPort: 7687 + - containerPort: 7474 + # resources: + # requests: + # memory: "2G" + # limits: + # memory: "8G" + env: + - name: NEO4J_dbms_security_procedures_unrestricted + value: "algo.*,apoc.*" + {{- range $key, $val := .Values.neo4jConfig }} + - name: NEO4J_{{ $key }} + value: {{ $val | quote }} + {{- end}} + envFrom: + - configMapRef: + name: {{ .Release.Name }}-configmap + - secretRef: + name: {{ .Release.Name }}-secrets + # volumeMounts: + # - mountPath: /data/ + # name: neo4j-data + # volumes: + # - name: neo4j-data + # persistentVolumeClaim: + # claimName: neo4j-data-claim + restartPolicy: Always + terminationGracePeriodSeconds: 30 diff --git a/deployment/helm/human-connection/templates/deployment-web.yaml b/deployment/helm/human-connection/templates/deployment-web.yaml new file mode 100644 index 000000000..0e432774f --- /dev/null +++ b/deployment/helm/human-connection/templates/deployment-web.yaml @@ -0,0 +1,37 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-webapp +spec: + replicas: 2 + minReadySeconds: 15 + progressDeadlineSeconds: 60 + selector: + matchLabels: + human-connection.org/selector: deployment-webapp + template: + metadata: + name: webapp + labels: + human-connection.org/commit: {{ .Values.commit }} + human-connection.org/selector: deployment-webapp + spec: + containers: + - name: webapp + image: humanconnection/nitro-web:latest + imagePullPolicy: {{ .Values.pullPolicy }} + envFrom: + - configMapRef: + name: {{ .Release.Name }}-configmap + - secretRef: + name: {{ .Release.Name }}-secrets + env: + - name: HOST + value: 0.0.0.0 + ports: + - containerPort: 3000 + resources: {} + imagePullPolicy: Always + restartPolicy: Always + terminationGracePeriodSeconds: 30 +status: {} diff --git a/deployment/helm/human-connection/values.yaml b/deployment/helm/human-connection/values.yaml index c15537a83..25a346fae 100644 --- a/deployment/helm/human-connection/values.yaml +++ b/deployment/helm/human-connection/values.yaml @@ -3,30 +3,23 @@ commit: 889a7cdd24dda04a139b2b77d626e984d6db6781 pullPolicy: Always # configs -smtp: - host: "mailserver.human-connection" - port: "25" -neo4j: +smtpHost: "mailserver.human-connection" +smtpPort: "25" +smtpUsername: +smtpPassword: +sentryDsnWebapp: +sentryDsnBackend: +neo4jConfig: apoc_import_file_enabled: "true" dbms_memory_pagecache_size: "490M" dbms_memory_heap_max__size: "500M" dbms_memory_heap_initial__size: "500M" - dbms_security_procedures_unrestricted: "algo.*,apoc.*" -sentry: - dsn_webapp: - dsn_backend: # secrets -jwt_secret: b/&&7b78BF&fv/Vd -private_key_passphrase: a7dsf78sadg87ad87sfagsadg78 -mapbox: - token: pk.eyJ1IjoiaHVtYW4tY29ubmVjdGlvbiIsImEiOiJjajl0cnBubGoweTVlM3VwZ2lzNTNud3ZtIn0.KZ8KK9l70omjXbEkkbHGsQ -mongodb: - username: - password: -neo4j: - username: - password: -smtp: - username: - password: +jwtSecret: b/&&7b78BF&fv/Vd +privateKeyPassphrase: a7dsf78sadg87ad87sfagsadg78 +mapboxToken: pk.eyJ1IjoiaHVtYW4tY29ubmVjdGlvbiIsImEiOiJjajl0cnBubGoweTVlM3VwZ2lzNTNud3ZtIn0.KZ8KK9l70omjXbEkkbHGsQ +mongodbUsername: +mongodbPassword: +neo4jUsername: +neo4jPassword: From fccf53a176789ecc728032bda99cc2f55ab018b8 Mon Sep 17 00:00:00 2001 From: roschaefer Date: Tue, 17 Sep 2019 23:28:17 +0200 Subject: [PATCH 004/116] Implement services and maintenance deployment Also found: ``` Some users have raised concerns that the Neo4j image changes file permissions on the host machine. By default, Neo4j runs as the user neo4j who only exists in the container, not on the host. That means that it's hard to set up mount folders on the host which this new user has write permissions for. We have updated the error messaging with advice about how to fix file permission errors. We also introduced writability checks and reduced the amount of file permission changes the image will perform. This has been found to interfere with some Kubernetes setups, so is currently an opt-in feature. To enforce stricter file permissions checking you can pass this environment variable to the container: --env SECURE_FILE_PERMISSIONS=yes ``` from https://hub.docker.com/_/neo4j Implemented the above :point_up: --- .../templates/deployment-maintenance.yaml | 26 +++++++++++++++++++ .../templates/deployment-neo4j.yaml | 2 ++ .../templates/service-backend.yaml | 11 ++++++++ .../templates/service-maintenance.yaml | 11 ++++++++ .../templates/service-neo4j.yaml | 14 ++++++++++ .../templates/service-webapp.yaml | 11 ++++++++ 6 files changed, 75 insertions(+) create mode 100644 deployment/helm/human-connection/templates/deployment-maintenance.yaml create mode 100644 deployment/helm/human-connection/templates/service-backend.yaml create mode 100644 deployment/helm/human-connection/templates/service-maintenance.yaml create mode 100644 deployment/helm/human-connection/templates/service-neo4j.yaml create mode 100644 deployment/helm/human-connection/templates/service-webapp.yaml diff --git a/deployment/helm/human-connection/templates/deployment-maintenance.yaml b/deployment/helm/human-connection/templates/deployment-maintenance.yaml new file mode 100644 index 000000000..8ce4442b9 --- /dev/null +++ b/deployment/helm/human-connection/templates/deployment-maintenance.yaml @@ -0,0 +1,26 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-maintenance +spec: + selector: + matchLabels: + human-connection.org/selector: deployment-maintenance + template: + metadata: + labels: + human-connection.org/commit: {{ .Values.commit }} + human-connection.org/selector: deployment-maintenance + name: maintenance + spec: + containers: + - name: maintenance + env: + - name: HOST + value: 0.0.0.0 + image: humanconnection/maintenance:latest + ports: + - containerPort: 80 + imagePullPolicy: Always + restartPolicy: Always + terminationGracePeriodSeconds: 30 diff --git a/deployment/helm/human-connection/templates/deployment-neo4j.yaml b/deployment/helm/human-connection/templates/deployment-neo4j.yaml index 692533abf..290f79332 100644 --- a/deployment/helm/human-connection/templates/deployment-neo4j.yaml +++ b/deployment/helm/human-connection/templates/deployment-neo4j.yaml @@ -35,6 +35,8 @@ spec: env: - name: NEO4J_dbms_security_procedures_unrestricted value: "algo.*,apoc.*" + - name: SECURE_FILE_PERMISSIONS + value: "yes" {{- range $key, $val := .Values.neo4jConfig }} - name: NEO4J_{{ $key }} value: {{ $val | quote }} diff --git a/deployment/helm/human-connection/templates/service-backend.yaml b/deployment/helm/human-connection/templates/service-backend.yaml new file mode 100644 index 000000000..b9d40ef8a --- /dev/null +++ b/deployment/helm/human-connection/templates/service-backend.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-backend +spec: + ports: + - name: graphql + port: 4000 + targetPort: 4000 + selector: + human-connection.org/selector: deployment-backend diff --git a/deployment/helm/human-connection/templates/service-maintenance.yaml b/deployment/helm/human-connection/templates/service-maintenance.yaml new file mode 100644 index 000000000..a82473e2e --- /dev/null +++ b/deployment/helm/human-connection/templates/service-maintenance.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-maintenance +spec: + ports: + - name: web + port: 80 + targetPort: 80 + selector: + human-connection.org/selector: deployment-maintenance diff --git a/deployment/helm/human-connection/templates/service-neo4j.yaml b/deployment/helm/human-connection/templates/service-neo4j.yaml new file mode 100644 index 000000000..547dad6c7 --- /dev/null +++ b/deployment/helm/human-connection/templates/service-neo4j.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-neo4j +spec: + ports: + - name: bolt + port: 7687 + targetPort: 7687 + - name: web + port: 7474 + targetPort: 7474 + selector: + human-connection.org/selector: deployment-neo4j diff --git a/deployment/helm/human-connection/templates/service-webapp.yaml b/deployment/helm/human-connection/templates/service-webapp.yaml new file mode 100644 index 000000000..c1a9771ee --- /dev/null +++ b/deployment/helm/human-connection/templates/service-webapp.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-webapp +spec: + ports: + - name: web + port: 3000 + targetPort: 3000 + selector: + human-connection.org/selector: deployment-webapp From 18ffafcabce8a46fba55d0b33950847caa95ff1b Mon Sep 17 00:00:00 2001 From: roschaefer Date: Wed, 18 Sep 2019 00:05:00 +0200 Subject: [PATCH 005/116] Assign the neo4j pod at least 1G memory I just went into memory issues when creating all the pods. Neo4j was in a crash loop with exit code 137. Apparently this one: https://success.docker.com/article/what-causes-a-container-to-exit-with-code-137 --- .../human-connection/templates/deployment-neo4j.yaml | 10 +++++----- deployment/helm/human-connection/values.yaml | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/deployment/helm/human-connection/templates/deployment-neo4j.yaml b/deployment/helm/human-connection/templates/deployment-neo4j.yaml index 290f79332..3818af2ef 100644 --- a/deployment/helm/human-connection/templates/deployment-neo4j.yaml +++ b/deployment/helm/human-connection/templates/deployment-neo4j.yaml @@ -27,11 +27,11 @@ spec: ports: - containerPort: 7687 - containerPort: 7474 - # resources: - # requests: - # memory: "2G" - # limits: - # memory: "8G" + resources: + requests: + memory: {{ .Values.neo4jResourceRequestsMemory | default "1G" | quote }} + limits: + memory: {{ .Values.neo4jResourceLimitsMemory | default "1G" | quote }} env: - name: NEO4J_dbms_security_procedures_unrestricted value: "algo.*,apoc.*" diff --git a/deployment/helm/human-connection/values.yaml b/deployment/helm/human-connection/values.yaml index 25a346fae..77d799861 100644 --- a/deployment/helm/human-connection/values.yaml +++ b/deployment/helm/human-connection/values.yaml @@ -9,6 +9,8 @@ smtpUsername: smtpPassword: sentryDsnWebapp: sentryDsnBackend: +neo4jResourceRequestsMemory: "1G" +neo4jResourceLimitsMemory: "1G" neo4jConfig: apoc_import_file_enabled: "true" dbms_memory_pagecache_size: "490M" @@ -21,5 +23,5 @@ privateKeyPassphrase: a7dsf78sadg87ad87sfagsadg78 mapboxToken: pk.eyJ1IjoiaHVtYW4tY29ubmVjdGlvbiIsImEiOiJjajl0cnBubGoweTVlM3VwZ2lzNTNud3ZtIn0.KZ8KK9l70omjXbEkkbHGsQ mongodbUsername: mongodbPassword: -neo4jUsername: -neo4jPassword: +neo4jUsername: neo4j +neo4jPassword: neo4j From c189b620739b9aca1344054ed8dc28c3f5f9cf09 Mon Sep 17 00:00:00 2001 From: roschaefer Date: Wed, 18 Sep 2019 00:19:24 +0200 Subject: [PATCH 006/116] Set app version --- deployment/helm/human-connection/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/helm/human-connection/Chart.yaml b/deployment/helm/human-connection/Chart.yaml index 1cfe9378b..0f303ade0 100644 --- a/deployment/helm/human-connection/Chart.yaml +++ b/deployment/helm/human-connection/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v1 -appVersion: "1.0" +appVersion: "0.1.0" description: A Helm chart for Human Connection name: human-connection version: 0.1.0 From c8c345be485d0b3516eb6787d8b432c74487d4e7 Mon Sep 17 00:00:00 2001 From: roschaefer Date: Wed, 18 Sep 2019 01:19:06 +0200 Subject: [PATCH 007/116] Fixup bug dath --- deployment/helm/human-connection/templates/configmap.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/helm/human-connection/templates/configmap.yml b/deployment/helm/human-connection/templates/configmap.yml index 8be7b517e..dec2c2bac 100644 --- a/deployment/helm/human-connection/templates/configmap.yml +++ b/deployment/helm/human-connection/templates/configmap.yml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ .Release.Name }}-configmap -dath: +data: GRAPHQL_URI: "http://{{ .Release.Name }}-backend:4000" NEO4J_URI: "bolt://{{ .Release.Name }}-neo4j:7687" CLIENT_URI: "https://{{ .Values.domain }}" From 6e0b7c86e17fff78464aef34726c091b645cb8c9 Mon Sep 17 00:00:00 2001 From: roschaefer Date: Wed, 18 Sep 2019 01:19:50 +0200 Subject: [PATCH 008/116] Conditionally deploy mailserver --- .../human-connection/templates/configmap.yml | 5 +++ .../templates/deployment-mailserver.yaml | 34 +++++++++++++++++++ .../templates/service-mailserver.yaml | 16 +++++++++ deployment/helm/human-connection/values.yaml | 1 + 4 files changed, 56 insertions(+) create mode 100644 deployment/helm/human-connection/templates/deployment-mailserver.yaml create mode 100644 deployment/helm/human-connection/templates/service-mailserver.yaml diff --git a/deployment/helm/human-connection/templates/configmap.yml b/deployment/helm/human-connection/templates/configmap.yml index dec2c2bac..4c57a7e94 100644 --- a/deployment/helm/human-connection/templates/configmap.yml +++ b/deployment/helm/human-connection/templates/configmap.yml @@ -10,5 +10,10 @@ data: SENTRY_DSN_WEBAPP: {{ .Values.sentryDsnWebapp }} SENTRY_DSN_BACKEND: {{ .Values.sentryDsnBackend }} COMMIT: {{ .Values.commit }} +{{- if .Values.developmentMailserverDomain }} + SMTP_HOST: {{ .Release.Name }}-mailserver + SMTP_PORT: "25" +{{- else }} SMTP_HOST: {{ .Values.smtpHost }} SMTP_PORT: {{ .Values.smtpPort }} +{{- end }} diff --git a/deployment/helm/human-connection/templates/deployment-mailserver.yaml b/deployment/helm/human-connection/templates/deployment-mailserver.yaml new file mode 100644 index 000000000..685cabea0 --- /dev/null +++ b/deployment/helm/human-connection/templates/deployment-mailserver.yaml @@ -0,0 +1,34 @@ +{{- if .Values.developmentMailserverDomain }} +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-mailserver +spec: + replicas: 1 + minReadySeconds: 15 + progressDeadlineSeconds: 60 + selector: + matchLabels: + human-connection.org/selector: deployment-mailserver + template: + metadata: + labels: + human-connection.org/selector: deployment-mailserver + name: mailserver + spec: + containers: + - name: mailserver + image: djfarrelly/maildev + imagePullPolicy: {{ .Values.pullPolicy }} + ports: + - containerPort: 80 + - containerPort: 25 + envFrom: + - configMapRef: + name: {{ .Release.Name }}-configmap + - secretRef: + name: {{ .Release.Name }}-secrets + restartPolicy: Always + terminationGracePeriodSeconds: 30 +status: {} +{{- end}} diff --git a/deployment/helm/human-connection/templates/service-mailserver.yaml b/deployment/helm/human-connection/templates/service-mailserver.yaml new file mode 100644 index 000000000..e5e22aa37 --- /dev/null +++ b/deployment/helm/human-connection/templates/service-mailserver.yaml @@ -0,0 +1,16 @@ +{{- if .Values.developmentMailserverDomain }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-mailserver +spec: + ports: + - name: web + port: 80 + targetPort: 80 + - name: smtp + port: 25 + targetPort: 25 + selector: + human-connection.org/selector: deployment-mailserver +{{- end}} diff --git a/deployment/helm/human-connection/values.yaml b/deployment/helm/human-connection/values.yaml index 77d799861..6db2f87fd 100644 --- a/deployment/helm/human-connection/values.yaml +++ b/deployment/helm/human-connection/values.yaml @@ -3,6 +3,7 @@ commit: 889a7cdd24dda04a139b2b77d626e984d6db6781 pullPolicy: Always # configs +developmentMailserverDomain: "nitro-mailserver.human-connection.org" smtpHost: "mailserver.human-connection" smtpPort: "25" smtpUsername: From 2363c285e146b8a76864bab1eec0e8d8961fb07e Mon Sep 17 00:00:00 2001 From: roschaefer Date: Wed, 18 Sep 2019 02:12:50 +0200 Subject: [PATCH 009/116] Implement ingress and letsencrypt issuers --- .../templates/ingress.template.yaml | 31 +++++++++++++++++++ .../templates/letsencrypt-prod.yaml | 11 +++++++ .../templates/letsencrypt-staging.yaml | 11 +++++++ deployment/helm/human-connection/values.yaml | 5 ++- 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 deployment/helm/human-connection/templates/ingress.template.yaml create mode 100644 deployment/helm/human-connection/templates/letsencrypt-prod.yaml create mode 100644 deployment/helm/human-connection/templates/letsencrypt-staging.yaml diff --git a/deployment/helm/human-connection/templates/ingress.template.yaml b/deployment/helm/human-connection/templates/ingress.template.yaml new file mode 100644 index 000000000..99c3fbb78 --- /dev/null +++ b/deployment/helm/human-connection/templates/ingress.template.yaml @@ -0,0 +1,31 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-ingress + annotations: + kubernetes.io/ingress.class: "nginx" + certmanager.k8s.io/issuer: {{ .Values.letsencryptIssuer }} + certmanager.k8s.io/acme-challenge-type: http01 + nginx.ingress.kubernetes.io/proxy-body-size: 6m +spec: + tls: + - hosts: + - {{ .Values.humanConnectionDomain }} + secretName: tls + rules: + - host: {{ .Values.humanConnectionDomain }} + http: + paths: + - path: / + backend: + serviceName: webapp + servicePort: 3000 +{{- if .Values.developmentMailserverDomain }} + - host: {{ .Values.developmentMailserverDomain }} + http: + paths: + - path: / + backend: + serviceName: {{ .Release.Name }}-mailserver + servicePort: 80 +{{- end }} diff --git a/deployment/helm/human-connection/templates/letsencrypt-prod.yaml b/deployment/helm/human-connection/templates/letsencrypt-prod.yaml new file mode 100644 index 000000000..9801fb974 --- /dev/null +++ b/deployment/helm/human-connection/templates/letsencrypt-prod.yaml @@ -0,0 +1,11 @@ +apiVersion: certmanager.k8s.io/v1alpha1 +kind: Issuer +metadata: + name: {{ .Release.Name }}-letsencrypt-prod +spec: + acme: + server: https://acme-v02.api.letsencrypt.org/directory + email: {{ .Values.supportEmail }} + privateKeySecretRef: + name: letsencrypt-prod + http01: {} diff --git a/deployment/helm/human-connection/templates/letsencrypt-staging.yaml b/deployment/helm/human-connection/templates/letsencrypt-staging.yaml new file mode 100644 index 000000000..2bb6784a8 --- /dev/null +++ b/deployment/helm/human-connection/templates/letsencrypt-staging.yaml @@ -0,0 +1,11 @@ +apiVersion: certmanager.k8s.io/v1alpha1 +kind: Issuer +metadata: + name: {{ .Release.Name }}-letsencrypt-staging +spec: + acme: + server: https://acme-staging-v02.api.letsencrypt.org/directory + email: {{ .Values.supportEmail }} + privateKeySecretRef: + name: letsencrypt-staging + http01: {} diff --git a/deployment/helm/human-connection/values.yaml b/deployment/helm/human-connection/values.yaml index 6db2f87fd..f5fd5a6aa 100644 --- a/deployment/helm/human-connection/values.yaml +++ b/deployment/helm/human-connection/values.yaml @@ -3,7 +3,10 @@ commit: 889a7cdd24dda04a139b2b77d626e984d6db6781 pullPolicy: Always # configs -developmentMailserverDomain: "nitro-mailserver.human-connection.org" +developmentMailserverDomain: "helm-nitro-mailserver.human-connection.org" +humanConnectionDomain: "helm-staging.human-connection.org" +supportEmail: "developer@human-connection.org" +letsencryptIssuer: "letsencrypt-staging" smtpHost: "mailserver.human-connection" smtpPort: "25" smtpUsername: From 3be5dee08b3a1853d86b7c01f768bf4920784be9 Mon Sep 17 00:00:00 2001 From: roschaefer Date: Fri, 24 Jan 2020 17:25:45 +0100 Subject: [PATCH 010/116] Draft: Setup subsriptions for backend+frontend Please clean up this commit and squash it later on. --- backend/package.json | 1 + backend/src/config/index.js | 1 + backend/src/index.js | 7 +++-- backend/src/schema/resolvers/posts.js | 12 ++++++++ backend/src/schema/types/schema.gql | 4 +++ backend/src/server.js | 43 ++++++++++++++++++++------- backend/yarn.lock | 7 ++++- webapp/pages/index.vue | 40 +++++++++++++++++++++++++ webapp/plugins/apollo-config.js | 3 +- 9 files changed, 102 insertions(+), 16 deletions(-) diff --git a/backend/package.json b/backend/package.json index 2a83c7f01..d33f9e14a 100644 --- a/backend/package.json +++ b/backend/package.json @@ -96,6 +96,7 @@ "request": "~2.88.0", "sanitize-html": "~1.21.1", "slug": "~2.1.0", + "subscriptions-transport-ws": "^0.9.16", "trunc-html": "~1.1.2", "uuid": "~3.4.0", "validator": "^12.1.0", diff --git a/backend/src/config/index.js b/backend/src/config/index.js index 2f8d0ed22..59ab20af7 100644 --- a/backend/src/config/index.js +++ b/backend/src/config/index.js @@ -49,6 +49,7 @@ export const serverConfigs = { CLIENT_URI, GRAPHQL_URI, PUBLIC_REGISTRATION: process.env.PUBLIC_REGISTRATION === 'true', + SUBSCRIPTIONS_PATH: '/subscriptions', } export const developmentConfigs = { diff --git a/backend/src/index.js b/backend/src/index.js index 98354dc1f..0eb4f51b6 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -1,9 +1,10 @@ import createServer from './server' import CONFIG from './config' -const { app } = createServer() +const { app, server, httpServer } = createServer() const url = new URL(CONFIG.GRAPHQL_URI) -app.listen({ port: url.port }, () => { +httpServer.listen({ port: url.port }, () => { /* eslint-disable-next-line no-console */ - console.log(`GraphQLServer ready at ${CONFIG.GRAPHQL_URI} 🚀`) + console.log(`🚀 Server ready at http://localhost:${url.port}${server.graphqlPath}`) + console.log(`🚀 Subscriptions ready at ws://localhost:${url.port}${server.subscriptionsPath}`) }) diff --git a/backend/src/schema/resolvers/posts.js b/backend/src/schema/resolvers/posts.js index af8165997..f8609f7a6 100644 --- a/backend/src/schema/resolvers/posts.js +++ b/backend/src/schema/resolvers/posts.js @@ -5,6 +5,11 @@ import { UserInputError } from 'apollo-server' import fileUpload from './fileUpload' import Resolver from './helpers/Resolver' import { filterForMutedUsers } from './helpers/filterForMutedUsers' +import { PubSub } from 'apollo-server' + +const pubsub = new PubSub(); +const POST_ADDED = 'POST_ADDED'; + const maintainPinnedPosts = params => { const pinnedPostFilter = { pinned: true } @@ -17,6 +22,12 @@ const maintainPinnedPosts = params => { } export default { + Subscription: { + postAdded: { + // Additional event labels can be passed to asyncIterator creation + subscribe: () => pubsub.asyncIterator([POST_ADDED]), + }, + }, Query: { Post: async (object, params, context, resolveInfo) => { params = await filterForMutedUsers(params, context) @@ -102,6 +113,7 @@ export default { }) try { const [post] = await writeTxResultPromise + pubsub.publish(POST_ADDED, { postAdded: post }); return post } catch (e) { if (e.code === 'Neo.ClientError.Schema.ConstraintValidationFailed') diff --git a/backend/src/schema/types/schema.gql b/backend/src/schema/types/schema.gql index 23c2ded4d..b3df61af2 100644 --- a/backend/src/schema/types/schema.gql +++ b/backend/src/schema/types/schema.gql @@ -1,3 +1,7 @@ +type Subscription { + postAdded: Post +} + type Mutation { # Get a JWT Token for the given Email and password login(email: String!, password: String!): String! diff --git a/backend/src/server.js b/backend/src/server.js index 02e166b71..22431bd7f 100644 --- a/backend/src/server.js +++ b/backend/src/server.js @@ -1,6 +1,9 @@ import express from 'express' +import http from 'http' import helmet from 'helmet' import { ApolloServer } from 'apollo-server-express' + + import CONFIG from './config' import middleware from './middleware' import { getNeode, getDriver } from './db/neo4j' @@ -8,19 +11,28 @@ import decode from './jwt/decode' import schema from './schema' import webfinger from './activitypub/routes/webfinger' + const driver = getDriver() const neode = getNeode() -export const context = async ({ req }) => { - const user = await decode(driver, req.headers.authorization) - return { - driver, - neode, - user, - req, - cypherParams: { - currentUserId: user ? user.id : null, - }, +const getContext = async (req) => { + const user = await decode(driver, req.headers.authorization) + return { + driver, + neode, + user, + req, + cypherParams: { + currentUserId: user ? user.id : null, + }, + } +} +export const context = async (options) => { + const { connection, req } = options + if (connection) { + return connection.context + } else { + return getContext(req) } } @@ -28,6 +40,12 @@ const createServer = options => { const defaults = { context, schema: middleware(schema), + subscriptions: { + onConnect: (connectionParams, webSocket) => { + console.log('connectionParams', connectionParams) + return getContext(connectionParams) + }, + }, debug: !!CONFIG.DEBUG, tracing: !!CONFIG.DEBUG, formatError: error => { @@ -46,8 +64,11 @@ const createServer = options => { app.use('/.well-known/', webfinger()) app.use(express.static('public')) server.applyMiddleware({ app, path: '/' }) + const httpServer = http.createServer(app); + server.installSubscriptionHandlers(httpServer); - return { server, app } + + return { server, httpServer, app } } export default createServer diff --git a/backend/yarn.lock b/backend/yarn.lock index caf302820..9d3e0e571 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -1175,7 +1175,7 @@ url-regex "~4.1.1" video-extensions "~1.1.0" -"@metascraper/helpers@^5.10.5", "@metascraper/helpers@^5.10.6": +"@metascraper/helpers@^5.10.6": version "5.10.6" resolved "https://registry.yarnpkg.com/@metascraper/helpers/-/helpers-5.10.6.tgz#0b786607212925a577926fd0cd0313a49de3499c" integrity sha512-/jvhlM3RKGYMoUK8D8S1r3tN03/EYizCqWF7zDx0aBMC8Ihp33DRGs9oNdsgkgwzVF7O/YpDm55l9K+qVJlsyQ== @@ -7918,6 +7918,11 @@ serve-static@1.14.1: version "1.14.1" resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.14.1.tgz#666e636dc4f010f7ef29970a88a674320898b2f9" integrity sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg== + dependencies: + encodeurl "~1.0.2" + escape-html "~1.0.3" + parseurl "~1.3.3" + send "0.17.1" set-blocking@^2.0.0, set-blocking@~2.0.0: version "2.0.0" diff --git a/webapp/pages/index.vue b/webapp/pages/index.vue index 609c3d800..f0089979d 100644 --- a/webapp/pages/index.vue +++ b/webapp/pages/index.vue @@ -74,6 +74,16 @@ import { mapGetters, mapMutations } from 'vuex' import { filterPosts } from '~/graphql/PostQuery.js' import PostMutations from '~/graphql/PostMutations' import UpdateQuery from '~/components/utils/UpdateQuery' +import gql from 'graphql-tag' +import { + userFragment, + postFragment, + commentFragment, + postCountsFragment, + userCountsFragment, + locationAndBadgesFragment, + tagsCategoriesAndPinnedFragment, +} from '~/graphql/Fragments' export default { components: { @@ -213,6 +223,36 @@ export default { this.posts = Post }, fetchPolicy: 'cache-and-network', + subscribeToMore: { + document: gql` + ${userFragment} + ${userCountsFragment} + ${locationAndBadgesFragment('EN')} + ${postFragment} + ${postCountsFragment} + ${tagsCategoriesAndPinnedFragment} + + subscription Post { + postAdded { + ...post + ...postCounts + ...tagsCategoriesAndPinned + author { + ...user + ...userCounts + ...locationAndBadges + } + } + }`, + // Mutate the previous result + updateQuery: (previousResult, { subscriptionData }) => { + console.log('previousResult', previousResult) + console.log('subscriptionData', subscriptionData) + const { data: { postAdded: newPost } } = subscriptionData + return { Post: [newPost, ...previousResult.Post] } + // Here, return the new result from the previous with the new data + }, + } }, }, } diff --git a/webapp/plugins/apollo-config.js b/webapp/plugins/apollo-config.js index 4bf05f178..a4487c0bb 100644 --- a/webapp/plugins/apollo-config.js +++ b/webapp/plugins/apollo-config.js @@ -9,6 +9,7 @@ export default ({ app }) => { const backendUrl = process.env.GRAPHQL_URI || 'http://localhost:4000' return { + wsEndpoint: 'ws://localhost:4000/graphql', // optional httpEndpoint: process.server ? backendUrl : '/api', httpLinkOptions: { credentials: 'same-origin', @@ -16,7 +17,7 @@ export default ({ app }) => { credentials: true, tokenName: 'human-connection-token', persisting: false, - websocketsOnly: false, + websocketsOnly: true, cache: new InMemoryCache({ fragmentMatcher }), } } From a28eb8c91f60a13784f7ac666db4940747953056 Mon Sep 17 00:00:00 2001 From: mattwr18 Date: Fri, 24 Jan 2020 18:23:59 +0100 Subject: [PATCH 011/116] Start subscriptions for notifications --- .../notifications/notificationsMiddleware.js | 16 ++++++-- backend/src/schema/resolvers/notifications.js | 9 +++++ backend/src/schema/resolvers/posts.js | 6 +-- backend/src/schema/types/schema.gql | 4 -- .../src/schema/types/type/Subscription.gql | 4 ++ backend/src/server.js | 1 - .../NotificationMenu/NotificationMenu.vue | 21 +++++++---- webapp/graphql/User.js | 37 +++++++++++++++++++ webapp/pages/index.vue | 4 -- 9 files changed, 80 insertions(+), 22 deletions(-) create mode 100644 backend/src/schema/types/type/Subscription.gql diff --git a/backend/src/middleware/notifications/notificationsMiddleware.js b/backend/src/middleware/notifications/notificationsMiddleware.js index 837193773..ca59be780 100644 --- a/backend/src/middleware/notifications/notificationsMiddleware.js +++ b/backend/src/middleware/notifications/notificationsMiddleware.js @@ -1,5 +1,9 @@ import extractMentionedUsers from './mentions/extractMentionedUsers' import { validateNotifyUsers } from '../validation/validationMiddleware' +import { PubSub } from 'apollo-server' + +const pubsub = new PubSub() +const NOTIFICATION_ADDED = 'NOTIFICATION_ADDED' const handleContentDataOfPost = async (resolve, root, args, context, resolveInfo) => { const idsOfUsers = extractMentionedUsers(args.content) @@ -74,12 +78,18 @@ const notifyUsersOfMention = async (label, id, idsOfUsers, reason, context) => { WHEN notification.createdAt IS NULL THEN notification END ).createdAt = toString(datetime()) SET notification.updatedAt = toString(datetime()) + RETURN notification ` const session = context.driver.session() + const writeTxResultPromise = session.writeTransaction(async transaction => { + const notificationTransactionResponse = await transaction.run(mentionedCypher, { id, idsOfUsers, reason }) + return notificationTransactionResponse.records.map(record => record.get('notification').properties) + }) try { - await session.writeTransaction(transaction => { - return transaction.run(mentionedCypher, { id, idsOfUsers, reason }) - }) + const [notification] = await writeTxResultPromise + return pubsub.publish(NOTIFICATION_ADDED, { notificationAdded: notification }) + } catch (error) { + throw new Error(error) } finally { session.close() } diff --git a/backend/src/schema/resolvers/notifications.js b/backend/src/schema/resolvers/notifications.js index 31369a8c7..f92292bfc 100644 --- a/backend/src/schema/resolvers/notifications.js +++ b/backend/src/schema/resolvers/notifications.js @@ -1,4 +1,8 @@ import log from './helpers/databaseLogger' +import { PubSub } from 'apollo-server' + +const pubsub = new PubSub() +const NOTIFICATION_ADDED = 'NOTIFICATION_ADDED' const resourceTypes = ['Post', 'Comment'] @@ -16,6 +20,11 @@ const transformReturnType = record => { } export default { + Subscription: { + notificationAdded: { + subscribe: () => pubsub.asyncIterator([NOTIFICATION_ADDED]), + }, + }, Query: { notifications: async (_parent, args, context, _resolveInfo) => { const { user: currentUser } = context diff --git a/backend/src/schema/resolvers/posts.js b/backend/src/schema/resolvers/posts.js index f8609f7a6..11f6eebc3 100644 --- a/backend/src/schema/resolvers/posts.js +++ b/backend/src/schema/resolvers/posts.js @@ -7,8 +7,8 @@ import Resolver from './helpers/Resolver' import { filterForMutedUsers } from './helpers/filterForMutedUsers' import { PubSub } from 'apollo-server' -const pubsub = new PubSub(); -const POST_ADDED = 'POST_ADDED'; +const pubsub = new PubSub() +const POST_ADDED = 'POST_ADDED' const maintainPinnedPosts = params => { @@ -113,7 +113,7 @@ export default { }) try { const [post] = await writeTxResultPromise - pubsub.publish(POST_ADDED, { postAdded: post }); + pubsub.publish(POST_ADDED, { postAdded: post }) return post } catch (e) { if (e.code === 'Neo.ClientError.Schema.ConstraintValidationFailed') diff --git a/backend/src/schema/types/schema.gql b/backend/src/schema/types/schema.gql index b3df61af2..23c2ded4d 100644 --- a/backend/src/schema/types/schema.gql +++ b/backend/src/schema/types/schema.gql @@ -1,7 +1,3 @@ -type Subscription { - postAdded: Post -} - type Mutation { # Get a JWT Token for the given Email and password login(email: String!, password: String!): String! diff --git a/backend/src/schema/types/type/Subscription.gql b/backend/src/schema/types/type/Subscription.gql new file mode 100644 index 000000000..a2f8b11b9 --- /dev/null +++ b/backend/src/schema/types/type/Subscription.gql @@ -0,0 +1,4 @@ +type Subscription { + postAdded: Post + notificationAdded: NOTIFIED +} \ No newline at end of file diff --git a/backend/src/server.js b/backend/src/server.js index 22431bd7f..d20fa5e63 100644 --- a/backend/src/server.js +++ b/backend/src/server.js @@ -42,7 +42,6 @@ const createServer = options => { schema: middleware(schema), subscriptions: { onConnect: (connectionParams, webSocket) => { - console.log('connectionParams', connectionParams) return getContext(connectionParams) }, }, diff --git a/webapp/components/NotificationMenu/NotificationMenu.vue b/webapp/components/NotificationMenu/NotificationMenu.vue index a3b085db9..b18203b45 100644 --- a/webapp/components/NotificationMenu/NotificationMenu.vue +++ b/webapp/components/NotificationMenu/NotificationMenu.vue @@ -22,13 +22,13 @@ diff --git a/webapp/locales/de.json b/webapp/locales/de.json index d52a9817c..a3135c011 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -798,5 +798,9 @@ "donations-for": "Spenden für", "donate-now": "Jetzt spenden", "amount-of-total": "{amount} von {total} € erreicht" + }, + "error-pages" : { + "user-not-found": "Dieser Benutzer konnte nicht gefunden werden", + "back-to-index": "Zurück zur Startseite" } } diff --git a/webapp/locales/en.json b/webapp/locales/en.json index 1906a5f6f..f8dea3914 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -798,6 +798,10 @@ "title": "In addition, we regularly hold events where you can also share your impressions and ask questions. You can find a current overview here:", "description": " https://human-connection.org/events/ " } + }, + "error-pages" : { + "user-not-found": "This user could not be found", + "back-to-index": "Back to index page" } } diff --git a/webapp/pages/profile/_id.vue b/webapp/pages/profile/_id.vue index 992e5efce..6b57e3b2d 100644 --- a/webapp/pages/profile/_id.vue +++ b/webapp/pages/profile/_id.vue @@ -23,7 +23,7 @@ const options = { } } `, - message: 'This user could not be found', + message: 'error-pages.user-not-found', path: 'profile', } const persistentLinks = PersistentLinks(options) From 9948f4ef201ee66339663442a84ca8ffd48afea5 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 20 Jan 2020 11:24:18 +0100 Subject: [PATCH 013/116] improved layout, key-name changed --- webapp/layouts/error.vue | 23 +++++++++++++++++++++-- webapp/locales/de.json | 2 +- webapp/locales/en.json | 2 +- webapp/pages/profile/_id.vue | 2 +- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/webapp/layouts/error.vue b/webapp/layouts/error.vue index d11755ad4..0b8c37bec 100644 --- a/webapp/layouts/error.vue +++ b/webapp/layouts/error.vue @@ -1,6 +1,9 @@ @@ -10,3 +13,19 @@ export default { props: ['error'], } + diff --git a/webapp/locales/de.json b/webapp/locales/de.json index a3135c011..21a717c6b 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -800,7 +800,7 @@ "amount-of-total": "{amount} von {total} € erreicht" }, "error-pages" : { - "user-not-found": "Dieser Benutzer konnte nicht gefunden werden", + "profile-not-found": "Dieses Profil konnte nicht gefunden werden", "back-to-index": "Zurück zur Startseite" } } diff --git a/webapp/locales/en.json b/webapp/locales/en.json index f8dea3914..54121af20 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -800,7 +800,7 @@ } }, "error-pages" : { - "user-not-found": "This user could not be found", + "user-not-found": "This profile could not be found", "back-to-index": "Back to index page" } } diff --git a/webapp/pages/profile/_id.vue b/webapp/pages/profile/_id.vue index 6b57e3b2d..b9bbef83e 100644 --- a/webapp/pages/profile/_id.vue +++ b/webapp/pages/profile/_id.vue @@ -23,7 +23,7 @@ const options = { } } `, - message: 'error-pages.user-not-found', + message: 'error-pages.profile-not-found', path: 'profile', } const persistentLinks = PersistentLinks(options) From 04ff82f880c1efec4f5bc732ff77cda97fa3a18b Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 20 Jan 2020 11:29:26 +0100 Subject: [PATCH 014/116] Cypress test fixed --- cypress/integration/common/steps.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index 9a5c02d08..44d2ada64 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -300,7 +300,7 @@ Then( cy.visit(route, { failOnStatusCode: false }); - cy.get(".error").should("contain", message); + cy.get(".error-message").should("contain", message); } ); From a4907f2bcb4cea68a0bc6bf5828d15c7487d1fc9 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 20 Jan 2020 12:57:14 +0100 Subject: [PATCH 015/116] localised error message for cannot edit post --- webapp/locales/de.json | 4 +++- webapp/locales/en.json | 6 ++++-- webapp/pages/post/_id.vue | 20 ++++++++++---------- webapp/pages/post/edit/_id.vue | 2 +- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/webapp/locales/de.json b/webapp/locales/de.json index 21a717c6b..1a396fa01 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -801,6 +801,8 @@ }, "error-pages" : { "profile-not-found": "Dieses Profil konnte nicht gefunden werden", - "back-to-index": "Zurück zur Startseite" + "back-to-index": "Zurück zur Startseite", + "post-not-found": "Dieser Beitrag konnte nicht gefunden werden", + "cannot-edit-post": "Dieser Beitrag kann nicht editiert werden" } } diff --git a/webapp/locales/en.json b/webapp/locales/en.json index 54121af20..3138af41f 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -800,8 +800,10 @@ } }, "error-pages" : { - "user-not-found": "This profile could not be found", - "back-to-index": "Back to index page" + "profile-not-found": "This profile could not be found", + "back-to-index": "Back to index page", + "post-not-found": "This post could not be found", + "cannot-edit-post": "This post cannot be edited" } } diff --git a/webapp/pages/post/_id.vue b/webapp/pages/post/_id.vue index a02afd3b9..92795606f 100644 --- a/webapp/pages/post/_id.vue +++ b/webapp/pages/post/_id.vue @@ -35,7 +35,7 @@ const options = { } `, path: 'post', - message: 'This post could not be found', + message: 'error-pages.post-not-found', } const persistentLinks = PersistentLinks(options) @@ -55,14 +55,14 @@ export default { }, // TODO implement /* { - name: this.$t('common.letsTalk'), - path: `/post/${id}/${slug}#lets-talk` - }, */ + name: this.$t('common.letsTalk'), + path: `/post/${id}/${slug}#lets-talk` + }, */ // TODO implement /* { - name: this.$t('common.versus'), - path: `/post/${id}/${slug}#versus` - } */ + name: this.$t('common.versus'), + path: `/post/${id}/${slug}#versus` + } */ ], }, { @@ -71,9 +71,9 @@ export default { }, // TODO implement /* { - name: this.$t('common.takeAction'), - path: `/post/${id}/${slug}/take-action` - } */ + name: this.$t('common.takeAction'), + path: `/post/${id}/${slug}/take-action` + } */ ] }, }, diff --git a/webapp/pages/post/edit/_id.vue b/webapp/pages/post/edit/_id.vue index c79d2b70e..d269a04d8 100644 --- a/webapp/pages/post/edit/_id.vue +++ b/webapp/pages/post/edit/_id.vue @@ -38,7 +38,7 @@ export default { variables: { id }, }) if (contribution.author.id !== store.getters['auth/user'].id) { - error({ statusCode: 403, message: "You can't edit that!" }) + error({ statusCode: 403, message: 'error-pages.cannot-edit-post' }) } return { contribution } }, From 7315cacb5a6057b17e6552f3358713266d6c85aa Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 20 Jan 2020 22:55:22 +0100 Subject: [PATCH 016/116] Text for 403 error is localized I hacked the error.vue to catch the default 404 error message and to display a localized message instead. I found no better way to do it. Any ideas? --- webapp/layouts/error.vue | 5 ++++- webapp/locales/de.json | 4 +++- webapp/locales/en.json | 4 +++- webapp/middleware/isAdmin.js | 2 +- webapp/middleware/isModerator.js | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/webapp/layouts/error.vue b/webapp/layouts/error.vue index 0b8c37bec..ab4f5e5bb 100644 --- a/webapp/layouts/error.vue +++ b/webapp/layouts/error.vue @@ -2,7 +2,10 @@

- {{ $t(error.message) }} + + {{ $t('error-pages.default') }} + + {{ $t(error.message) }}
{{ $t('error-pages.back-to-index') }}
diff --git a/webapp/locales/de.json b/webapp/locales/de.json index 1a396fa01..ae4b5bfc1 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -803,6 +803,8 @@ "profile-not-found": "Dieses Profil konnte nicht gefunden werden", "back-to-index": "Zurück zur Startseite", "post-not-found": "Dieser Beitrag konnte nicht gefunden werden", - "cannot-edit-post": "Dieser Beitrag kann nicht editiert werden" + "cannot-edit-post": "Dieser Beitrag kann nicht editiert werden", + "default": "Diese Seite konnte nicht gefunden werden", + "not-authorized": "Kein Zugang zu dieser Seite" } } diff --git a/webapp/locales/en.json b/webapp/locales/en.json index 3138af41f..cb0d3ca07 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -803,7 +803,9 @@ "profile-not-found": "This profile could not be found", "back-to-index": "Back to index page", "post-not-found": "This post could not be found", - "cannot-edit-post": "This post cannot be edited" + "cannot-edit-post": "This post cannot be edited", + "default": "This page could not be found", + "not-authorized": "Not authorized to this page" } } diff --git a/webapp/middleware/isAdmin.js b/webapp/middleware/isAdmin.js index 4db10bbb6..12b6c5bac 100644 --- a/webapp/middleware/isAdmin.js +++ b/webapp/middleware/isAdmin.js @@ -1,5 +1,5 @@ export default ({ store, error }) => { if (!store.getters['auth/isAdmin']) { - return error({ statusCode: 403 }) + return error({ statusCode: 403, message: 'error-pages.not-authorized' }) } } diff --git a/webapp/middleware/isModerator.js b/webapp/middleware/isModerator.js index e99793a3e..9b17badea 100644 --- a/webapp/middleware/isModerator.js +++ b/webapp/middleware/isModerator.js @@ -1,5 +1,5 @@ export default ({ store, error }) => { if (!store.getters['auth/isModerator']) { - return error({ statusCode: 403 }) + return error({ statusCode: 403, message: 'error-pages.not-authorized' }) } } From b05e997743b417c175af1e05b6fc068f1746a69a Mon Sep 17 00:00:00 2001 From: mattwr18 Date: Tue, 28 Jan 2020 20:55:08 +0100 Subject: [PATCH 017/116] Update templates and deploy to develop - proof of concept that this works! --- .../human-connection/templates/configmap.yml | 19 ---- .../templates/deployment-backend.yaml | 39 ++++--- .../templates/deployment-mailserver.yaml | 3 +- .../templates/deployment-maintenance.yaml | 3 +- .../templates/deployment-neo4j.yaml | 19 ++-- .../templates/deployment-web.yaml | 3 +- .../templates/ingress.template.yaml | 10 +- .../templates/letsencrypt-prod.yaml | 11 +- .../templates/letsencrypt-staging.yaml | 11 +- .../templates/service-backend.yaml | 1 + .../templates/service-neo4j.yaml | 1 + .../templates/service-webapp.yaml | 4 +- deployment/helm/human-connection/values.yaml | 26 ++--- .../human-connection/deployment-backend.yaml | 105 ++++++++++-------- 14 files changed, 134 insertions(+), 121 deletions(-) delete mode 100644 deployment/helm/human-connection/templates/configmap.yml diff --git a/deployment/helm/human-connection/templates/configmap.yml b/deployment/helm/human-connection/templates/configmap.yml deleted file mode 100644 index 4c57a7e94..000000000 --- a/deployment/helm/human-connection/templates/configmap.yml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ .Release.Name }}-configmap -data: - GRAPHQL_URI: "http://{{ .Release.Name }}-backend:4000" - NEO4J_URI: "bolt://{{ .Release.Name }}-neo4j:7687" - CLIENT_URI: "https://{{ .Values.domain }}" - VERSION: {{ .Chart.AppVersion }} - SENTRY_DSN_WEBAPP: {{ .Values.sentryDsnWebapp }} - SENTRY_DSN_BACKEND: {{ .Values.sentryDsnBackend }} - COMMIT: {{ .Values.commit }} -{{- if .Values.developmentMailserverDomain }} - SMTP_HOST: {{ .Release.Name }}-mailserver - SMTP_PORT: "25" -{{- else }} - SMTP_HOST: {{ .Values.smtpHost }} - SMTP_PORT: {{ .Values.smtpPort }} -{{- end }} diff --git a/deployment/helm/human-connection/templates/deployment-backend.yaml b/deployment/helm/human-connection/templates/deployment-backend.yaml index 596036fd2..b921934b2 100644 --- a/deployment/helm/human-connection/templates/deployment-backend.yaml +++ b/deployment/helm/human-connection/templates/deployment-backend.yaml @@ -1,7 +1,8 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: {{ .Release.Name }}-backend + namespace: human-connection spec: replicas: 1 minReadySeconds: 15 @@ -23,23 +24,33 @@ spec: human-connection.org/selector: deployment-backend spec: containers: - - name: backend - image: humanconnection/nitro-backend:latest - imagePullPolicy: {{ .Values.pullPolicy }} - ports: - - containerPort: 4000 - envFrom: + - envFrom: - configMapRef: name: {{ .Release.Name }}-configmap - secretRef: name: {{ .Release.Name }}-secrets - # volumeMounts: - # - mountPath: /nitro-backend/public/uploads - # name: uploads - # volumes: - # - name: uploads - # persistentVolumeClaim: - # claimName: uploads-claim + image: humanconnection/nitro-backend:latest + imagePullPolicy: {{ .Values.pullPolicy }} + name: nitro-backend + ports: + - containerPort: 4000 + protocol: TCP + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - mountPath: /nitro-backend/public/uploads + name: uploads + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 + volumes: + - name: uploads + persistentVolumeClaim: + claimName: uploads-claim + dnsPolicy: ClusterFirst restartPolicy: Always terminationGracePeriodSeconds: 30 status: {} diff --git a/deployment/helm/human-connection/templates/deployment-mailserver.yaml b/deployment/helm/human-connection/templates/deployment-mailserver.yaml index 685cabea0..4bc8eaadc 100644 --- a/deployment/helm/human-connection/templates/deployment-mailserver.yaml +++ b/deployment/helm/human-connection/templates/deployment-mailserver.yaml @@ -1,8 +1,9 @@ {{- if .Values.developmentMailserverDomain }} -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: {{ .Release.Name }}-mailserver + namespace: human-connection spec: replicas: 1 minReadySeconds: 15 diff --git a/deployment/helm/human-connection/templates/deployment-maintenance.yaml b/deployment/helm/human-connection/templates/deployment-maintenance.yaml index 8ce4442b9..c414fb452 100644 --- a/deployment/helm/human-connection/templates/deployment-maintenance.yaml +++ b/deployment/helm/human-connection/templates/deployment-maintenance.yaml @@ -1,7 +1,8 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: {{ .Release.Name }}-maintenance + namespace: human-connection spec: selector: matchLabels: diff --git a/deployment/helm/human-connection/templates/deployment-neo4j.yaml b/deployment/helm/human-connection/templates/deployment-neo4j.yaml index 3818af2ef..c157832dd 100644 --- a/deployment/helm/human-connection/templates/deployment-neo4j.yaml +++ b/deployment/helm/human-connection/templates/deployment-neo4j.yaml @@ -1,7 +1,8 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: {{ .Release.Name }}-neo4j + namespace: human-connection spec: replicas: 1 strategy: @@ -44,14 +45,12 @@ spec: envFrom: - configMapRef: name: {{ .Release.Name }}-configmap - - secretRef: - name: {{ .Release.Name }}-secrets - # volumeMounts: - # - mountPath: /data/ - # name: neo4j-data - # volumes: - # - name: neo4j-data - # persistentVolumeClaim: - # claimName: neo4j-data-claim + volumeMounts: + - mountPath: /data/ + name: neo4j-data + volumes: + - name: neo4j-data + persistentVolumeClaim: + claimName: neo4j-data-claim restartPolicy: Always terminationGracePeriodSeconds: 30 diff --git a/deployment/helm/human-connection/templates/deployment-web.yaml b/deployment/helm/human-connection/templates/deployment-web.yaml index 0e432774f..1f8930612 100644 --- a/deployment/helm/human-connection/templates/deployment-web.yaml +++ b/deployment/helm/human-connection/templates/deployment-web.yaml @@ -1,7 +1,8 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: {{ .Release.Name }}-webapp + namespace: human-connection spec: replicas: 2 minReadySeconds: 15 diff --git a/deployment/helm/human-connection/templates/ingress.template.yaml b/deployment/helm/human-connection/templates/ingress.template.yaml index 99c3fbb78..12ef4c9c4 100644 --- a/deployment/helm/human-connection/templates/ingress.template.yaml +++ b/deployment/helm/human-connection/templates/ingress.template.yaml @@ -2,15 +2,15 @@ apiVersion: extensions/v1beta1 kind: Ingress metadata: name: {{ .Release.Name }}-ingress + namespace: human-connection annotations: kubernetes.io/ingress.class: "nginx" - certmanager.k8s.io/issuer: {{ .Values.letsencryptIssuer }} - certmanager.k8s.io/acme-challenge-type: http01 - nginx.ingress.kubernetes.io/proxy-body-size: 6m + cert-manager.io/cluster-issuer: {{ .Values.letsencryptIssuer }} + nginx.ingress.kubernetes.io/proxy-body-size: 10m spec: tls: - hosts: - - {{ .Values.humanConnectionDomain }} + - {{ .Values.humanConnectionDomain }} secretName: tls rules: - host: {{ .Values.humanConnectionDomain }} @@ -18,7 +18,7 @@ spec: paths: - path: / backend: - serviceName: webapp + serviceName: {{ .Release.Name }}-webapp servicePort: 3000 {{- if .Values.developmentMailserverDomain }} - host: {{ .Values.developmentMailserverDomain }} diff --git a/deployment/helm/human-connection/templates/letsencrypt-prod.yaml b/deployment/helm/human-connection/templates/letsencrypt-prod.yaml index 9801fb974..65bd160e1 100644 --- a/deployment/helm/human-connection/templates/letsencrypt-prod.yaml +++ b/deployment/helm/human-connection/templates/letsencrypt-prod.yaml @@ -1,11 +1,14 @@ -apiVersion: certmanager.k8s.io/v1alpha1 -kind: Issuer +apiVersion: cert-manager.io/v1alpha2 +kind: ClusterIssuer metadata: - name: {{ .Release.Name }}-letsencrypt-prod + name: letsencrypt-prod spec: acme: server: https://acme-v02.api.letsencrypt.org/directory email: {{ .Values.supportEmail }} privateKeySecretRef: name: letsencrypt-prod - http01: {} + solvers: + - http01: + ingress: + class: nginx diff --git a/deployment/helm/human-connection/templates/letsencrypt-staging.yaml b/deployment/helm/human-connection/templates/letsencrypt-staging.yaml index 2bb6784a8..27889f5db 100644 --- a/deployment/helm/human-connection/templates/letsencrypt-staging.yaml +++ b/deployment/helm/human-connection/templates/letsencrypt-staging.yaml @@ -1,11 +1,14 @@ -apiVersion: certmanager.k8s.io/v1alpha1 -kind: Issuer +apiVersion: cert-manager.io/v1alpha2 +kind: ClusterIssuer metadata: - name: {{ .Release.Name }}-letsencrypt-staging + name: letsencrypt-staging spec: acme: server: https://acme-staging-v02.api.letsencrypt.org/directory email: {{ .Values.supportEmail }} privateKeySecretRef: name: letsencrypt-staging - http01: {} + solvers: + - http01: + ingress: + class: nginx \ No newline at end of file diff --git a/deployment/helm/human-connection/templates/service-backend.yaml b/deployment/helm/human-connection/templates/service-backend.yaml index b9d40ef8a..d750703a8 100644 --- a/deployment/helm/human-connection/templates/service-backend.yaml +++ b/deployment/helm/human-connection/templates/service-backend.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Service metadata: name: {{ .Release.Name }}-backend + namespace: human-connection spec: ports: - name: graphql diff --git a/deployment/helm/human-connection/templates/service-neo4j.yaml b/deployment/helm/human-connection/templates/service-neo4j.yaml index 547dad6c7..ec3bb1b6c 100644 --- a/deployment/helm/human-connection/templates/service-neo4j.yaml +++ b/deployment/helm/human-connection/templates/service-neo4j.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Service metadata: name: {{ .Release.Name }}-neo4j + namespace: human-connection spec: ports: - name: bolt diff --git a/deployment/helm/human-connection/templates/service-webapp.yaml b/deployment/helm/human-connection/templates/service-webapp.yaml index c1a9771ee..f6ea7206f 100644 --- a/deployment/helm/human-connection/templates/service-webapp.yaml +++ b/deployment/helm/human-connection/templates/service-webapp.yaml @@ -2,10 +2,12 @@ apiVersion: v1 kind: Service metadata: name: {{ .Release.Name }}-webapp + namespace: human-connection spec: ports: - - name: web + - name: {{ .Release.Name }}-webapp port: 3000 + protocol: TCP targetPort: 3000 selector: human-connection.org/selector: deployment-webapp diff --git a/deployment/helm/human-connection/values.yaml b/deployment/helm/human-connection/values.yaml index f5fd5a6aa..044341e0c 100644 --- a/deployment/helm/human-connection/values.yaml +++ b/deployment/helm/human-connection/values.yaml @@ -1,20 +1,20 @@ -domain: nitro-staging.human-connection.org +domain: develop.human-connection.org commit: 889a7cdd24dda04a139b2b77d626e984d6db6781 pullPolicy: Always # configs -developmentMailserverDomain: "helm-nitro-mailserver.human-connection.org" -humanConnectionDomain: "helm-staging.human-connection.org" -supportEmail: "developer@human-connection.org" -letsencryptIssuer: "letsencrypt-staging" +developmentMailserverDomain: "mailserver.human-connection.org" +humanConnectionDomain: "develop.human-connection.org" +supportEmail: "devcom@human-connection.org" +letsencryptIssuer: "letsencrypt-prod" smtpHost: "mailserver.human-connection" smtpPort: "25" smtpUsername: smtpPassword: -sentryDsnWebapp: -sentryDsnBackend: +sentryDsnWebapp: "https://f6a31aa8f406426187cb45ae6dacdbeb@nitro-sentry.human-connection.org/7" +sentryDsnBackend: "https://44e0f3fb04894fbfbcf898f2bcf652de@nitro-sentry.human-connection.org/6" neo4jResourceRequestsMemory: "1G" -neo4jResourceLimitsMemory: "1G" +neo4jResourceLimitsMemory: "2G" neo4jConfig: apoc_import_file_enabled: "true" dbms_memory_pagecache_size: "490M" @@ -22,10 +22,6 @@ neo4jConfig: dbms_memory_heap_initial__size: "500M" # secrets -jwtSecret: b/&&7b78BF&fv/Vd -privateKeyPassphrase: a7dsf78sadg87ad87sfagsadg78 -mapboxToken: pk.eyJ1IjoiaHVtYW4tY29ubmVjdGlvbiIsImEiOiJjajl0cnBubGoweTVlM3VwZ2lzNTNud3ZtIn0.KZ8KK9l70omjXbEkkbHGsQ -mongodbUsername: -mongodbPassword: -neo4jUsername: neo4j -neo4jPassword: neo4j +jwtSecret: "Yi8mJjdiNzhCRiZmdi9WZA==" +privateKeyPassphrase: "YTdkc2Y3OHNhZGc4N2FkODdzZmFnc2FkZzc4" +mapboxToken: "cGsuZXlKMUlqb2lhSFZ0WVc0dFkyOXVibVZqZEdsdmJpSXNJbUVpT2lKamFqbDBjbkJ1Ykdvd2VUVmxNM1Z3WjJsek5UTnVkM1p0SW4wLktaOEtLOWw3MG9talhiRWtrYkhHc1E=" diff --git a/deployment/human-connection/deployment-backend.yaml b/deployment/human-connection/deployment-backend.yaml index 51f0eb43c..7d93ebf73 100644 --- a/deployment/human-connection/deployment-backend.yaml +++ b/deployment/human-connection/deployment-backend.yaml @@ -1,47 +1,60 @@ ---- - apiVersion: extensions/v1beta1 - kind: Deployment - metadata: - name: nitro-backend - namespace: human-connection - spec: - replicas: 1 - minReadySeconds: 15 - progressDeadlineSeconds: 60 - strategy: - rollingUpdate: - maxSurge: 0 - maxUnavailable: "100%" - selector: - matchLabels: +apiVersion: apps/v1 +kind: Deployment +metadata: + creationTimestamp: null + labels: + human-connection.org/commit: COMMIT + human-connection.org/selector: deployment-human-connection-backend + name: nitro-backend + namespace: human-connection +spec: + minReadySeconds: 15 + progressDeadlineSeconds: 60 + replicas: 1 + revisionHistoryLimit: 2147483647 + selector: + matchLabels: + human-connection.org/selector: deployment-human-connection-backend + strategy: + rollingUpdate: + maxSurge: 0 + maxUnavailable: 100% + type: RollingUpdate + template: + metadata: + annotations: + backup.velero.io/backup-volumes: uploads + creationTimestamp: null + labels: + human-connection.org/commit: COMMIT human-connection.org/selector: deployment-human-connection-backend - template: - metadata: - annotations: - backup.velero.io/backup-volumes: uploads - labels: - human-connection.org/commit: COMMIT - human-connection.org/selector: deployment-human-connection-backend - name: "nitro-backend" - spec: - containers: - - name: nitro-backend - image: humanconnection/nitro-backend:latest - imagePullPolicy: Always - ports: - - containerPort: 4000 - envFrom: - - configMapRef: - name: configmap - - secretRef: - name: human-connection - volumeMounts: - - mountPath: /nitro-backend/public/uploads - name: uploads - volumes: - - name: uploads - persistentVolumeClaim: - claimName: uploads-claim - restartPolicy: Always - terminationGracePeriodSeconds: 30 - status: {} + name: nitro-backend + spec: + containers: + - envFrom: + - configMapRef: + name: configmap + - secretRef: + name: human-connection + image: humanconnection/nitro-backend:latest + imagePullPolicy: Always + name: nitro-backend + ports: + - containerPort: 4000 + protocol: TCP + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - mountPath: /nitro-backend/public/uploads + name: uploads + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 + volumes: + - name: uploads + persistentVolumeClaim: + claimName: uploads-claim +status: {} From 1c10f3769c94adf3f09cb5dd075f2fc60dafd3fa Mon Sep 17 00:00:00 2001 From: mattwr18 Date: Tue, 28 Jan 2020 20:57:55 +0100 Subject: [PATCH 018/116] Drop nitro prefix --- .../helm/human-connection/templates/deployment-backend.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/helm/human-connection/templates/deployment-backend.yaml b/deployment/helm/human-connection/templates/deployment-backend.yaml index b921934b2..2febeab84 100644 --- a/deployment/helm/human-connection/templates/deployment-backend.yaml +++ b/deployment/helm/human-connection/templates/deployment-backend.yaml @@ -31,7 +31,7 @@ spec: name: {{ .Release.Name }}-secrets image: humanconnection/nitro-backend:latest imagePullPolicy: {{ .Values.pullPolicy }} - name: nitro-backend + name: backend ports: - containerPort: 4000 protocol: TCP From 6a1079ac4287d95ec310dc5533a2aa286cae162d Mon Sep 17 00:00:00 2001 From: mattwr18 Date: Tue, 28 Jan 2020 21:05:26 +0100 Subject: [PATCH 019/116] Clean up --- .../templates/deployment-backend.yaml | 11 ++++------- .../templates/letsencrypt-staging.yaml | 2 +- deployment/helm/human-connection/values.yaml | 2 -- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/deployment/helm/human-connection/templates/deployment-backend.yaml b/deployment/helm/human-connection/templates/deployment-backend.yaml index 2febeab84..e30e66431 100644 --- a/deployment/helm/human-connection/templates/deployment-backend.yaml +++ b/deployment/helm/human-connection/templates/deployment-backend.yaml @@ -24,14 +24,14 @@ spec: human-connection.org/selector: deployment-backend spec: containers: - - envFrom: + - name: backend + image: humanconnection/nitro-backend:latest + imagePullPolicy: {{ .Values.pullPolicy }} + envFrom: - configMapRef: name: {{ .Release.Name }}-configmap - secretRef: name: {{ .Release.Name }}-secrets - image: humanconnection/nitro-backend:latest - imagePullPolicy: {{ .Values.pullPolicy }} - name: backend ports: - containerPort: 4000 protocol: TCP @@ -50,7 +50,4 @@ spec: - name: uploads persistentVolumeClaim: claimName: uploads-claim - dnsPolicy: ClusterFirst - restartPolicy: Always - terminationGracePeriodSeconds: 30 status: {} diff --git a/deployment/helm/human-connection/templates/letsencrypt-staging.yaml b/deployment/helm/human-connection/templates/letsencrypt-staging.yaml index 27889f5db..f8315c9be 100644 --- a/deployment/helm/human-connection/templates/letsencrypt-staging.yaml +++ b/deployment/helm/human-connection/templates/letsencrypt-staging.yaml @@ -11,4 +11,4 @@ spec: solvers: - http01: ingress: - class: nginx \ No newline at end of file + class: nginx diff --git a/deployment/helm/human-connection/values.yaml b/deployment/helm/human-connection/values.yaml index 044341e0c..8efcd0c06 100644 --- a/deployment/helm/human-connection/values.yaml +++ b/deployment/helm/human-connection/values.yaml @@ -11,8 +11,6 @@ smtpHost: "mailserver.human-connection" smtpPort: "25" smtpUsername: smtpPassword: -sentryDsnWebapp: "https://f6a31aa8f406426187cb45ae6dacdbeb@nitro-sentry.human-connection.org/7" -sentryDsnBackend: "https://44e0f3fb04894fbfbcf898f2bcf652de@nitro-sentry.human-connection.org/6" neo4jResourceRequestsMemory: "1G" neo4jResourceLimitsMemory: "2G" neo4jConfig: From 31790a9ebc17cedcf6698ddd0f53b271c3129f8f Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 28 Jan 2020 16:23:56 +0100 Subject: [PATCH 020/116] Imported images from https://github.com/Human-Connection/WebApp/blob/develop/static/assets/svg/errors/ --- webapp/static/img/svg/errors/error403.svg | 1 + webapp/static/img/svg/errors/error404.svg | 1 + webapp/static/img/svg/errors/error500.svg | 1 + webapp/static/img/svg/errors/error503.svg | 15 +++++++++++++++ 4 files changed, 18 insertions(+) create mode 100644 webapp/static/img/svg/errors/error403.svg create mode 100644 webapp/static/img/svg/errors/error404.svg create mode 100644 webapp/static/img/svg/errors/error500.svg create mode 100644 webapp/static/img/svg/errors/error503.svg diff --git a/webapp/static/img/svg/errors/error403.svg b/webapp/static/img/svg/errors/error403.svg new file mode 100644 index 000000000..e52d00a7a --- /dev/null +++ b/webapp/static/img/svg/errors/error403.svg @@ -0,0 +1 @@ + diff --git a/webapp/static/img/svg/errors/error404.svg b/webapp/static/img/svg/errors/error404.svg new file mode 100644 index 000000000..78f019410 --- /dev/null +++ b/webapp/static/img/svg/errors/error404.svg @@ -0,0 +1 @@ + diff --git a/webapp/static/img/svg/errors/error500.svg b/webapp/static/img/svg/errors/error500.svg new file mode 100644 index 000000000..5a95d7bf6 --- /dev/null +++ b/webapp/static/img/svg/errors/error500.svg @@ -0,0 +1 @@ + diff --git a/webapp/static/img/svg/errors/error503.svg b/webapp/static/img/svg/errors/error503.svg new file mode 100644 index 000000000..45b7b0cf7 --- /dev/null +++ b/webapp/static/img/svg/errors/error503.svg @@ -0,0 +1,15 @@ + + + + error503 + Created with Sketch. + + + + + + + + + + From d4e496b9e646079d19b5270135ca6878b08f8b10 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 28 Jan 2020 16:46:55 +0100 Subject: [PATCH 021/116] error image rendered --- webapp/layouts/error.spec.js | 47 ++++++++++++++++++++++++++++++++++++ webapp/layouts/error.vue | 24 +++++++++++++++--- webapp/locales/de.json | 7 ++++-- webapp/locales/en.json | 7 ++++-- 4 files changed, 77 insertions(+), 8 deletions(-) create mode 100644 webapp/layouts/error.spec.js diff --git a/webapp/layouts/error.spec.js b/webapp/layouts/error.spec.js new file mode 100644 index 000000000..95234ec5f --- /dev/null +++ b/webapp/layouts/error.spec.js @@ -0,0 +1,47 @@ +import { config, shallowMount } from '@vue/test-utils' +import Error from './error.vue' + +const localVue = global.localVue + +config.stubs['nuxt-link'] = '' + +describe('error.vue', () => { + let mocks, wrapper + + beforeEach(() => { + mocks = { + $t: jest.fn(key => key), + } + }) + + const Wrapper = (propsData = {}) => { + return shallowMount(Error, { mocks, propsData, localVue }) + } + + describe('shallowMount', () => { + it('renders default error message', () => { + wrapper = Wrapper({ error: {} }) + expect(wrapper.find('.error-message').text()).toBe('error-pages.default') + }) + + it('renders error message to given statusCode', () => { + wrapper = Wrapper({ error: { statusCode: 404 } }) + expect(wrapper.find('.error-message').text()).toBe('error-pages.404-default') + }) + + it('renders error message to given custom key', () => { + wrapper = Wrapper({ error: { statusCode: 404, key: 'my-custom-key' } }) + expect(wrapper.find('.error-message').text()).toBe('my-custom-key') + }) + + it('has a link to index page', () => { + wrapper = Wrapper({ error: {} }) + expect(wrapper.find('span[to="/"]').text()).toBe('error-pages.back-to-index') + }) + + it('has an image related to the status code', () => { + wrapper = Wrapper({ error: { statusCode: 404 } }) + expect(wrapper.find('.error-image').attributes('src')).toBe('/img/svg/errors/error404.svg') + }) + }) +}) diff --git a/webapp/layouts/error.vue b/webapp/layouts/error.vue index ab4f5e5bb..4394a5cdb 100644 --- a/webapp/layouts/error.vue +++ b/webapp/layouts/error.vue @@ -1,6 +1,6 @@