Commit c24d5f85 authored by jnsone11's avatar jnsone11
Browse files

add api

parent 2102975d
{}
\ No newline at end of file
FROM node:alpine
ARG NODE_ENV=production
WORKDIR /app
COPY package.json .
RUN npm install
CMD [ "npm" , "start" ]
\ No newline at end of file
# 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
apiVersion: v1
description: Graphql Api
name: graphqlapi
version: 0.1.0
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
apiVersion: extensions/v1beta1 apiVersion: extensions/v1beta1
kind: Deployment kind: Deployment
metadata: metadata:
name: {{ template "chart.fullname" . }} name: {{ template "fullname" . }}
labels: labels:
app: {{ template "chart.name" . }} app: {{ template "name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }} release: {{ .Release.Name }}
heritage: {{ .Release.Service }} heritage: {{ .Release.Service }}
...@@ -12,7 +12,7 @@ spec: ...@@ -12,7 +12,7 @@ spec:
template: template:
metadata: metadata:
labels: labels:
app: {{ template "chart.name" . }} app: {{ template "name" . }}
release: {{ .Release.Name }} release: {{ .Release.Name }}
spec: spec:
containers: containers:
......
apiVersion: v1
kind: Service
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }}
protocol: TCP
name: http
selector:
app: {{ template "name" . }}
release: {{ .Release.Name }}
# Default values for chart.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: workshop/graphqlapi
tag: latest
pullPolicy: IfNotPresent
service:
name: graphqlapi
type: ClusterIP
externalPort: 5000
internalPort: 5000
This diff is collapsed.
...@@ -4,11 +4,14 @@ ...@@ -4,11 +4,14 @@
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1",
"build" : "docker build -t workshop/graphqlapi .",
"showImages" : "docker images",
"start" : "node_modules/.bin/postgraphile -c postgresql://postgres@backend-database-postgresql/postgres -s workshop -w"
}, },
"author": "Jens Neuse <jens.neuse@gmx.de>", "author": "Jens Neuse <jens.neuse@gmx.de>",
"license": "ISC", "license": "ISC",
"devDependencies": { "dependencies": {
"postgraphile": "^4.0.0-alpha2.28" "postgraphile": "^4.0.0-alpha2.28"
} }
} }
\ No newline at end of file
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-configmap
data:
v1.sql: |-
{{ .Files.Get "v1.sql" | indent 4 }}
\ No newline at end of file
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ template "chart.fullname" . }}
labels:
app: {{ template "chart.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
template:
metadata:
labels:
app: {{ template "chart.name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.service.internalPort }}
volumeMounts:
- name: sql
mountPath: /docker-entrypoint-initdb.d
volumes:
- name: sql
configMap:
name: {{ .Release.Name }}-configmap
create schema if not EXISTS workshop;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
create table if not EXISTS workshop.author (
id UUID default uuid_generate_v1mc(),
name text NOT NULL,
PRIMARY KEY (id)
);
create table if NOT EXISTS workshop.article (
id UUID default uuid_generate_v1mc(),
title text default null,
description text default null,
content JSONB default null,
author_id UUID not null REFERENCES workshop.author(id),
PRIMARY KEY (id)
);
insert into workshop.author (name) VALUES ('Jens');
insert into workshop.article (title, description, content, author_id) VALUES (
'My First Article',
'This article is awesome!',
'{"bigButton":"on my desk"}',
(select id from workshop.author where name = 'Jens')
);
insert into workshop.article (title, description, content, author_id) VALUES (
'My Second Article',
'This article is awesome too! amazing!!',
'{"thisButton":"even Bigger!"}',
(select id from workshop.author where name = 'Jens')
);
\ No newline at end of file
...@@ -7,7 +7,7 @@ image: ...@@ -7,7 +7,7 @@ image:
tag: 9.6 tag: 9.6
pullPolicy: IfNotPresent pullPolicy: IfNotPresent
service: service:
name: backend-db name: backend-database
type: ClusterIP type: ClusterIP
externalPort: 5432 externalPort: 5432
internalPort: 5432 internalPort: 5432
\ No newline at end of file
{
"name": "renderine",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment