diff --git a/.env b/.env deleted file mode 100644 index dcb5cdb41..000000000 --- a/.env +++ /dev/null @@ -1,10 +0,0 @@ -NEO4J_URI=bolt://localhost:7687 -NEO4J_USER=neo4j -NEO4J_PASSWORD=letmein - -GRAPHQL_LISTEN_PORT=4000 -GRAPHQL_URI=http://localhost:4000 -CLIENT_URI=http://localhost:3000 -JWT_SECRET=b/&&7b78BF&fv/Vd - -MOCK=false diff --git a/.env.template b/.env.template index 4d849a121..df678a343 100644 --- a/.env.template +++ b/.env.template @@ -4,3 +4,5 @@ NEO4J_PASSWORD=letmein GRAPHQL_LISTEN_PORT=4000 GRAPHQL_URI=http://localhost:4000 MOCK=false + +JWT_SECRET=b/&&7b78BF&fv/Vd diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..87e0ad52e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,20 @@ +--- +name: Bug report +about: Create a report to help us improve + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Authenticate '...' +2. Post following data to endpoint '...' +3. See error + +**Expected behavior** +A clear and concise description of what you expected to happen + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..066b2d920 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,17 @@ +--- +name: Feature request +about: Suggest an idea for this project + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/Dockerfile b/Dockerfile index 1c33f50b3..5e3f8c650 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ LABEL Description="Server part of the social network Human Connection" Vendor="H # expose the app port EXPOSE 4000 -ARG WORKDIR=/Backend +ARG WORKDIR=/backend RUN mkdir -p $WORKDIR WORKDIR $WORKDIR diff --git a/Dockerfile.neo4j b/Dockerfile.neo4j index 3675669f6..66f996e68 100644 --- a/Dockerfile.neo4j +++ b/Dockerfile.neo4j @@ -1,3 +1,2 @@ FROM neo4j:3.4 -RUN mkdir /plugins && wget https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.4.0.3/apoc-3.4.0.3-all.jar -P /plugins - +RUN wget https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.4.0.3/apoc-3.4.0.3-all.jar -P plugins/ diff --git a/README.md b/README.md index e00ac8306..2cb57e264 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Human-Connection - NITRO API +# Human-Connection - NITRO Backend > This Prototype tries to resolve the biggest hurdle of connecting > our services together. This is not possible in a sane way using @@ -89,7 +89,7 @@ Note that grand-stack-starter does not currently bundle a distribution of Neo4j. You can download [Neo4j Desktop](https://neo4j.com/download/) and run locally for development, spin up a [hosted Neo4j Sandbox instance](https://neo4j.com/download/), run Neo4j in one of the [many cloud options](https://neo4j.com/developer/guide-cloud-deployment/), -or [spin up Neo4j in a Docker container](https://neo4j.com/developer/docker/). +[spin up Neo4j in a Docker container](https://neo4j.com/developer/docker/) or on Debian-based systems install [Neo4j from the Debian Repository](http://debian.neo4j.org/). Just be sure to update the Neo4j connection string and credentials accordingly in `.env`. ## Mocking API Results @@ -115,7 +115,7 @@ npm run seedDb - [x] add jwt authentication - [ ] get directives working correctly (@toLower, @auth, @role, etc.) - [ ] check if search is working -- [ ] check if sorting is working +- [x] check if sorting is working - [x] check if pagination is working - [ ] check if upload is working (using graphql-yoga?) - [x] evaluate middleware diff --git a/docker-compose.override.yml b/docker-compose.override.yml new file mode 100644 index 000000000..22e16da73 --- /dev/null +++ b/docker-compose.override.yml @@ -0,0 +1,16 @@ +version: "3.7" + +services: + backend: + container_name: backend.127.0.0.1.xip.io + volumes: + - .:/backend + - /backend/node_modules + neo4j: + ports: + - 7687:7687 + - 7474:7474 + +networks: + hc-network: + name: hc-network diff --git a/docker-compose.yml b/docker-compose.yml index a46a96f71..0a47bb3c0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.7" services: backend: - container_name: backend.127.0.0.1.xip.io + image: humanconnection/backend:latest build: . networks: - hc-network @@ -17,14 +17,9 @@ services: - CLIENT_URI=http://localhost:3000 - JWT_SECRET=b/&&7b78BF&fv/Vd - MOCK=false - volumes: - - .:/Backend - - /Backend/node_modules neo4j: - ports: - - 7687:7687 - - 7474:7474 + image: humanconnection/neo4j:latest build: context: . dockerfile: Dockerfile.neo4j @@ -37,7 +32,6 @@ services: networks: hc-network: - name: hc-network volumes: neo4j-data: diff --git a/kubernetes/README.md b/kubernetes/README.md new file mode 100644 index 000000000..3f22e039a --- /dev/null +++ b/kubernetes/README.md @@ -0,0 +1,37 @@ +# Usage with minikube + +First of all start minikube on your machine: +```sh +minikube start +``` +You can always get an overview and see what's going on with your minikube: +```sh +minikube dashboard +``` + +Build Docker images, using the Minikube Docker daemon: +```sh +eval $(minikube docker-env) +docker build -t humanconnection/backend:latest . +docker build -t humanconnection/neo4j:latest -f Dockerfile.neo4j . +``` + +check that the image is in Minikube’s Docker registry: +```sh +minikube ssh docker images +``` + +Now change into directory kubernetes and create services and deployments: +```sh +cd kubernetes + +kubectl create -f neo4j-deployment.yaml,neo4j-data-persistentvolumeclaim.yaml,backend-deployment.yaml,neo4j-service.json,backend-service.json +``` + +You can see the backend in action with: +```sh +minikube service backend +``` + + + diff --git a/kubernetes/backend-deployment.yaml b/kubernetes/backend-deployment.yaml new file mode 100644 index 000000000..cf7f34063 --- /dev/null +++ b/kubernetes/backend-deployment.yaml @@ -0,0 +1,41 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert -f ../docker-compose.yml + kompose.version: 1.16.0 (0c01309) + creationTimestamp: null + labels: + io.kompose.service: backend + name: backend +spec: + replicas: 1 + strategy: {} + template: + metadata: + creationTimestamp: null + labels: + io.kompose.service: backend + spec: + containers: + - env: + - name: CLIENT_URI + value: http://localhost:3000 + - name: GRAPHQL_LISTEN_PORT + value: "4000" + - name: GRAPHQL_URI + value: http://localhost:4000 + - name: JWT_SECRET + value: b/&&7b78BF&fv/Vd + - name: MOCK + value: "false" + - name: NEO4J_URI + value: bolt://neo4j:7687 + image: humanconnection/backend:latest + name: backend + ports: + - containerPort: 4000 + resources: {} + imagePullPolicy: IfNotPresent + restartPolicy: Always +status: {} diff --git a/kubernetes/backend-service.json b/kubernetes/backend-service.json new file mode 100644 index 000000000..28581be45 --- /dev/null +++ b/kubernetes/backend-service.json @@ -0,0 +1,35 @@ +{ + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "backend", + "namespace": "default", + "selfLink": "/api/v1/namespaces/default/services/backend", + "uid": "57749bc1-dea3-11e8-ace2-080027b5d96d", + "resourceVersion": "8321", + "creationTimestamp": "2018-11-02T13:29:36Z", + "labels": { + "io.kompose.service": "backend" + } + }, + "spec": { + "ports": [ + { + "protocol": "TCP", + "port": 4000, + "targetPort": 4000, + "nodePort": 32633 + } + ], + "selector": { + "io.kompose.service": "backend" + }, + "clusterIP": "10.110.129.92", + "type": "LoadBalancer", + "sessionAffinity": "None", + "externalTrafficPolicy": "Cluster" + }, + "status": { + "loadBalancer": {} + } +} diff --git a/kubernetes/dashboard-admin.yml b/kubernetes/dashboard-admin.yml new file mode 100644 index 000000000..5d76d3902 --- /dev/null +++ b/kubernetes/dashboard-admin.yml @@ -0,0 +1,14 @@ +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRoleBinding +metadata: + name: kubernetes-dashboard + labels: + k8s-app: kubernetes-dashboard +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cluster-admin +subjects: +- kind: ServiceAccount + name: kubernetes-dashboard + namespace: kube-system diff --git a/kubernetes/neo4j-data-persistentvolumeclaim.yaml b/kubernetes/neo4j-data-persistentvolumeclaim.yaml new file mode 100644 index 000000000..de9c89e2f --- /dev/null +++ b/kubernetes/neo4j-data-persistentvolumeclaim.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + creationTimestamp: null + labels: + io.kompose.service: neo4j-data + name: neo4j-data +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Mi +status: {} diff --git a/kubernetes/neo4j-deployment.yaml b/kubernetes/neo4j-deployment.yaml new file mode 100644 index 000000000..13f4d52e3 --- /dev/null +++ b/kubernetes/neo4j-deployment.yaml @@ -0,0 +1,40 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert -f ../docker-compose.yml + kompose.version: 1.16.0 (0c01309) + creationTimestamp: null + labels: + io.kompose.service: neo4j + name: neo4j +spec: + replicas: 1 + strategy: + type: Recreate + template: + metadata: + creationTimestamp: null + labels: + io.kompose.service: neo4j + spec: + containers: + - env: + - name: NEO4J_AUTH + value: none + image: humanconnection/neo4j:latest + name: neo4j + ports: + - containerPort: 7687 + - containerPort: 7474 + resources: {} + imagePullPolicy: IfNotPresent + volumeMounts: + - mountPath: /data + name: neo4j-data + restartPolicy: Always + volumes: + - name: neo4j-data + persistentVolumeClaim: + claimName: neo4j-data +status: {} diff --git a/kubernetes/neo4j-service.json b/kubernetes/neo4j-service.json new file mode 100644 index 000000000..89ac10367 --- /dev/null +++ b/kubernetes/neo4j-service.json @@ -0,0 +1,43 @@ +{ + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "neo4j", + "namespace": "default", + "selfLink": "/api/v1/namespaces/default/services/neo4j", + "uid": "57de6181-dea3-11e8-ace2-080027b5d96d", + "resourceVersion": "8326", + "creationTimestamp": "2018-11-02T13:29:37Z", + "labels": { + "io.kompose.service": "neo4j" + } + }, + "spec": { + "ports": [ + { + "name": "port-1", + "protocol": "TCP", + "port": 7687, + "targetPort": 7687, + "nodePort": 30116 + }, + { + "name": "port-2", + "protocol": "TCP", + "port": 7474, + "targetPort": 7474, + "nodePort": 32658 + } + ], + "selector": { + "io.kompose.service": "neo4j" + }, + "clusterIP": "10.108.175.122", + "type": "LoadBalancer", + "sessionAffinity": "None", + "externalTrafficPolicy": "Cluster" + }, + "status": { + "loadBalancer": {} + } +}