Ablageort im Repository (GitLab): Projekt58-Terminfinder SH
Diskussionsforum (Discourse): Projekt58-Terminfinder SH
Readme: Projekt58-Terminfinder SH
Beschreibung des Projektes:
PublicCode.YML: anzeigen
OSS Compliance: anzeigen
Prerequesities
Der Rest wird mit den manifests ausgerollt.
Kubernetes:
```bash
kubectl create namespace poc-dvs-demo-apps
kubectl create secret docker-registry dockercred --docker-server=registry.o4oe.de --docker-username=<user_name> --docker-password=<PERSONAL_ACCESS_TOKENS> --docker-email=<user_email>
kubectl apply -f -R manifests/
```
Openshift:
```bash
oc new-project poc-dvs-demo-apps
oc create secret docker-registry dockercred --docker-server=registry.o4oe.de --docker-username=jondoe --docker-password=<PERSONAL_ACCESS_TOKENS> --docker-email=jon@example.net
oc apply -R -f manifests/
oc expose svc terminfinder-frontend-svc
oc get route
```
Container-Registry: `registry.o4oe.de/ig-bvc/demo-apps/terminfinder-sh/terminfinder-sh-frontend:1.13.9`
Im Container muss die Adresse des Backendservers gesetzt werden. Dazu muss im Pfad `/usr/share/nginx/html/dynamicVariables.json` mit folgendem Inhalt gemounted sein:
```json
{
"apiBaseUrl": "https://dterminfinder.dvs-poc.dataport.de/api"
}
```
Container-Registry: `registry.o4oe.de/ig-bvc/demo-apps/terminfinder-sh/terminfinder-sh-backend:V1.0.6-c`
Das Backend wird über ENV-Variablen konfiguriert.
```bash
dabstimmbox_server=db_port
dabstimmbox_database=db_username
dabstimmbox_password=$db_password
```
wenn in Cluster
Container-Registry: `registry.o4oe.de/ig-bvc/demo-apps/terminfinder-sh/terminfinder-sh-postgres:v0.1.0`
sonst als Appliance außerhalb.
```bash
db_admin_username=db_admin_password
db_username=db_password
db_name=$db_name
db_customer_id=1CDCD974-1169-4E04-8144-5A4AAFF55667
db_customer_name=Dataport
```
`createuser.sql`
```sql
\c dabstimmbox
\set db_admin_user `echo $db_admin_user`
\set db_admin_pass `echo $db_admin_pass`
\set db_user `echo $db_user`
\set db_pass `echo $db_pass`
\set db_name `echo $db_name`
-- DB User
-- User: :db_user
DROP USER IF EXISTS :db_user;
CREATE USER :db_user WITH
LOGIN
NOSUPERUSER
INHERIT
NOCREATEDB
NOCREATEROLE
NOREPLICATION;
ALTER USER ":db_user" WITH PASSWORD ':db_pass';
-- User: :db_admin_user
DROP USER IF EXISTS :db_admin_user;
CREATE USER :db_admin_user WITH
LOGIN
NOSUPERUSER
INHERIT
NOCREATEDB
NOCREATEROLE
NOREPLICATION;
ALTER USER :db_admin_user WITH PASSWORD :db_admin_pass;
```
`createdb.sql`
```sql
\set db_admin_user `echo $db_admin_user`
\set db_admin_pass `echo $db_admin_pass`
\set db_user `echo $db_user`
\set db_pass `echo $db_pass`
\set db_name `echo $db_name`
CREATE DATABASE :db_name
WITH
OWNER = :db_admin_user
ENCODING = 'UTF8'
LC_COLLATE = 'de_DE.utf8'
LC_CTYPE = 'de_DE.utf8'
TABLESPACE = pg_default
CONNECTION LIMIT = -1;
GRANT TEMPORARY, CONNECT ON DATABASE :db_name TO PUBLIC;
GRANT ALL ON DATABASE :db_name TO :db_admin_user;
GRANT CONNECT ON DATABASE :db_name TO :db_user;
```
`createtables.sql`
```sql
\set db_admin_user `echo $db_admin_user`
\set db_admin_pass `echo $db_admin_pass`
\set db_user `echo $db_user`
\set db_pass `echo $db_pass`
\set db_name `echo $db_name`
-- DB: use dabstimmbox;
\c dabstimmbox
-- Extention for uuid
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- Table: public.appconfig
-- DROP TABLESPACE
-- DROP TABLE public.voting;
-- DROP TABLE public.participant;
-- DROP TABLE public.suggesteddate;
-- DROP TABLE public.appointment;
-- DROP TABLE public.customer;
-- DROP TABLE public.appconfig;
CREATE TABLE public.appconfig
(
configkey character varying(100) COLLATE pg_catalog."default" NOT NULL,
configvalue character varying(300) COLLATE pg_catalog."default",
CONSTRAINT appconfig_pkey PRIMARY KEY (configkey)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.appconfig
OWNER to :db_admin_user;
GRANT SELECT ON TABLE public.appconfig TO :db_user;
GRANT ALL ON TABLE public.appconfig TO :db_admin_user;
--
-- Table: public.customer
CREATE TABLE public.customer
(
customerid uuid NOT NULL DEFAULT uuid_generate_v4(),
customername character varying(100) COLLATE pg_catalog."default" NOT NULL,
status character varying(20) COLLATE pg_catalog."default" NOT NULL,
creationdate timestamp with time zone NOT NULL default CURRENT_TIMESTAMP,
CONSTRAINT customer_pkey PRIMARY KEY (customerid)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.customer
OWNER to :db_admin_user;
-- Table: public.appointment
CREATE TABLE public.appointment
(
appointmentid uuid NOT NULL DEFAULT uuid_generate_v4(),
customerid uuid NOT NULL,
adminid uuid NOT NULL DEFAULT uuid_generate_v4(),
creatorname character varying(100) COLLATE pg_catalog."default" NOT NULL,
creationdate timestamp with time zone NOT NULL default CURRENT_TIMESTAMP,
subject character varying(300) COLLATE pg_catalog."default",
description character varying(1500) COLLATE pg_catalog."default",
place character varying(300) COLLATE pg_catalog."default",
status character varying(20) COLLATE pg_catalog."default" NOT NULL,
password character varying(120) COLLATE pg_catalog."default"
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE appointment ADD CONSTRAINT appointment_pkey PRIMARY KEY (appointmentid),
ADD CONSTRAINT appointment_customerid_fkey FOREIGN KEY (customerid) REFERENCES customer (customerid) ON DELETE RESTRICT;
CREATE UNIQUE INDEX appointment_adminid_ix on appointment (adminid);
ALTER TABLE public.appointment
OWNER to :db_admin_user;
-- Table: public.suggesteddate
CREATE TABLE public.suggesteddate
(
suggesteddateid uuid NOT NULL DEFAULT uuid_generate_v4(),
appointmentid uuid NOT NULL,
customerid uuid NOT NULL,
creationdate timestamp with time zone NOT NULL default CURRENT_TIMESTAMP,
startdate date NOT NULL,
starttime time with time zone NULL,
enddate date NULL,
endtime time with time zone NULL
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE suggesteddate ADD CONSTRAINT suggesteddate_pkey PRIMARY KEY (suggesteddateid),
ADD CONSTRAINT suggesteddate_customerid_fkey FOREIGN KEY (customerid) REFERENCES customer (customerid) ON DELETE RESTRICT,
ADD CONSTRAINT suggesteddate_appointmentid_fkey FOREIGN KEY (appointmentid) REFERENCES appointment (appointmentid) ON DELETE CASCADE;
CREATE INDEX suggesteddate_startdate_ix on suggesteddate (startdate);
CREATE INDEX suggesteddate_enddate_ix on suggesteddate (enddate);
CREATE INDEX suggesteddate_appointmentid_ix ON suggesteddate (appointmentid);
ALTER TABLE public.suggesteddate
OWNER to :db_admin_user;
-- Table: public.participant
CREATE TABLE public.participant
(
participantid uuid NOT NULL DEFAULT uuid_generate_v4(),
appointmentid uuid NOT NULL,
customerid uuid NOT NULL,
creationdate timestamp with time zone NOT NULL default CURRENT_TIMESTAMP,
name character varying(50) COLLATE pg_catalog."default" NOT NULL
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE participant ADD CONSTRAINT participant_pkey PRIMARY KEY (participantid),
ADD CONSTRAINT participant_customerid_fkey FOREIGN KEY (customerid) REFERENCES customer (customerid) ON DELETE RESTRICT,
ADD CONSTRAINT participant_appointmentid_fkey FOREIGN KEY (appointmentid) REFERENCES appointment (appointmentid) ON DELETE CASCADE;
CREATE INDEX participant_appointmentid_ix ON participant (appointmentid);
ALTER TABLE public.participant
OWNER to :db_admin_user;
-- Table: public.voting
CREATE TABLE public.voting
(
votingid uuid NOT NULL DEFAULT uuid_generate_v4(),
participantid uuid NOT NULL,
suggesteddateid uuid NOT NULL,
appointmentid uuid NOT NULL,
customerid uuid NOT NULL,
creationdate timestamp with time zone NOT NULL default CURRENT_TIMESTAMP,
status character varying(20) COLLATE pg_catalog."default" NOT NULL
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE voting ADD CONSTRAINT voting_pkey PRIMARY KEY (votingid),
ADD CONSTRAINT voting_customerid_fkey FOREIGN KEY (customerid) REFERENCES customer (customerid) ON DELETE RESTRICT,
ADD CONSTRAINT voting_appointmentid_fkey FOREIGN KEY (appointmentid) REFERENCES appointment (appointmentid) ON DELETE CASCADE,
ADD CONSTRAINT voting_participantid_fkey FOREIGN KEY (participantid) REFERENCES participant (participantid) ON DELETE CASCADE,
ADD CONSTRAINT voting_suggesteddateid_fkey FOREIGN KEY (suggesteddateid) REFERENCES suggesteddate (suggesteddateid) ON DELETE CASCADE;
CREATE INDEX voting_appointmentid_ix ON voting (appointmentid);
CREATE INDEX voting_participantid_ix ON voting (participantid);
ALTER TABLE public.voting
OWNER to :db_admin_user;
GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE public.voting TO :db_user;
GRANT ALL ON TABLE public.voting TO :db_admin_user;
```
`insertapp.sql`
```sql
\set db_name `echo $db_name`
\c :db_name
insert into public.appconfig (configkey, configvalue) values ('version','V1.0.7');
insert into public.appconfig (configkey, configvalue) values ('builddate','2021-11-08');
```
`insert_customer.sql`
```sql
\set db_name `echo $db_name`
\set db_customer_id `echo $db_customer_id`
\set db_customer_name `echo $db_customer_name`
\c :db_name
insert into public.customer (customerid, customername, status) values (:db_customer_id, :db_customer_id, 'Started');
```