This commit is contained in:
Piotr Biernat 2022-12-25 23:21:27 +01:00
parent 317d1a871b
commit 6042f81c35
14 changed files with 219 additions and 41 deletions

View File

@ -1,9 +0,0 @@
-- TODO: Add variables for db, user name, etc...
CREATE DATABASE svc_identity
WITH
OWNER = postgres
ENCODING = 'UTF8'
CONNECTION LIMIT = -1;
GRANT ALL ON DATABASE svc_identity TO postgres;

View File

@ -0,0 +1,2 @@
DROP TABLE IF EXISTS basket.basket_item;
DROP TABLE IF EXISTS basket.basket;

View File

@ -0,0 +1,34 @@
CREATE TABLE IF NOT EXISTS basket.basket
(
id uuid NOT NULL DEFAULT gen_random_uuid(),
state character varying NOT NULL DEFAULT 'new',
created_at timestamp without time zone NOT NULL DEFAULT now(),
updated_at timestamp without time zone,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS basket.basket_item
(
id uuid NOT NULL DEFAULT gen_random_uuid(),
basket_id uuid NOT NULL,
product_id integer NOT NULL,
quantity integer NOT NULL DEFAULT 1,
price double precision NOT NULL DEFAULT 0.00;
created_at timestamp without time zone NOT NULL DEFAULT now(),
updated_at timestamp without time zone,
PRIMARY KEY (id)
);
ALTER TABLE IF EXISTS basket.basket_item
ADD CONSTRAINT basket_item_basket_fkey FOREIGN KEY (basket_id)
REFERENCES basket.basket (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
ALTER TABLE IF EXISTS basket.basket
OWNER to postgres;
ALTER TABLE IF EXISTS basket.basket_item
OWNER to postgres;
-- TODO ^^ PRIVILEGES...

View File

@ -0,0 +1,2 @@
ALTER TABLE IF EXISTS basket.basket_item
DROP COLUMN price;

View File

@ -0,0 +1,2 @@
ALTER TABLE IF EXISTS basket.basket_item
ADD COLUMN price double precision NOT NULL DEFAULT 0.00;

View File

@ -0,0 +1 @@
DROP TABLE IF EXISTS catalog.product;

View File

@ -0,0 +1,16 @@
CREATE TABLE catalog.product
(
id integer NOT NULL GENERATED ALWAYS AS IDENTITY,
pid character varying NOT NULL,
name character varying NOT NULL,
price double precision NOT NULL,
created_at timestamp without time zone NOT NULL DEFAULT now(),
updated_at timestamp without time zone,
PRIMARY KEY (id)
);
ALTER TABLE IF EXISTS catalog.product
OWNER to postgres;
COMMENT ON COLUMN catalog.product.pid
IS 'Unique product ID. EAN, UPC etc...';

View File

@ -0,0 +1 @@
DROP TABLE IF EXISTS identity.users;

View File

@ -0,0 +1,12 @@
CREATE TABLE IF NOT EXISTS identity.users
(
id uuid NOT NULL DEFAULT gen_random_uuid(),
username character varying NOT NULL,
email character varying NOT NULL,
created_at timestamp without time zone NOT NULL DEFAULT now(),
updated_at timestamp without time zone,
PRIMARY KEY (id)
);
ALTER TABLE IF EXISTS identity.users
OWNER to postgres;

View File

@ -0,0 +1,2 @@
DROP TABLE IF EXISTS ordering.order_item;
DROP TABLE IF EXISTS ordering."order";

View File

@ -0,0 +1,34 @@
CREATE TABLE IF NOT EXISTS ordering."order"
(
id uuid NOT NULL DEFAULT gen_random_uuid(),
state character varying NOT NULL DEFAULT 'new',
created_at timestamp without time zone NOT NULL DEFAULT now(),
updated_at timestamp without time zone,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS ordering.order_item
(
id uuid NOT NULL DEFAULT gen_random_uuid(),
order_id uuid NOT NULL,
product_id integer NOT NULL,
quantity integer NOT NULL DEFAULT 1,
price double precision NOT NULL DEFAULT 0.00;
created_at timestamp without time zone NOT NULL DEFAULT now(),
updated_at timestamp without time zone,
PRIMARY KEY (id)
);
ALTER TABLE IF EXISTS ordering.order_item
ADD CONSTRAINT order_item_order_fkey FOREIGN KEY (order_id)
REFERENCES "ordering"."order" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
ALTER TABLE IF EXISTS "ordering"."order"
OWNER to postgres;
ALTER TABLE IF EXISTS "ordering".order_item
OWNER to postgres;
-- TODO ^^ PRIVILEGES...

View File

@ -15,7 +15,6 @@ services:
# - "traefik.http.routers.api-gateway-api.rule=PathPrefix(`/api`)" # - "traefik.http.routers.api-gateway-api.rule=PathPrefix(`/api`)"
# - "traefik.http.routers.api-gateway-api.service=api@internal" # - "traefik.http.routers.api-gateway-api.service=api@internal"
# - "traefik.http.routers.api-gateway-api.middlewares=PathPrefix(`/`)" # - "traefik.http.routers.api-gateway-api.middlewares=PathPrefix(`/`)"
# - "traefik.http.routers.api-gateway.tls=true"
# - "traefik.http.routers.api-gateway.rule=Headers(`X-API-SERVICE`, `admin-gateway`)" # - "traefik.http.routers.api-gateway.rule=Headers(`X-API-SERVICE`, `admin-gateway`)"
# - "traefik.http.routers.api-gateway.tls=true" # - "traefik.http.routers.api-gateway.tls=true"
# - "traefik.http.routers.api-gateway.entryPoints=https" # - "traefik.http.routers.api-gateway.entryPoints=https"
@ -32,6 +31,7 @@ services:
hostname: registry.egommerce.pbiernat.dev hostname: registry.egommerce.pbiernat.dev
environment: environment:
- APP_DOMAIN=registry.egommerce.pbiernat.dev - APP_DOMAIN=registry.egommerce.pbiernat.dev
- CONSUL_HTTP_TOKEN=devop
# labels: # labels:
# - "traefik.enable=true" # - "traefik.enable=true"
# - "traefik.http.routers.api-registry.rule=PathPrefix(`/admin/registry`)" # - "traefik.http.routers.api-registry.rule=PathPrefix(`/admin/registry`)"
@ -73,6 +73,11 @@ services:
# volumes: # volumes:
# - ./certs/api-gateway:/certs # - ./certs/api-gateway:/certs
api-cache:
image: git.pbiernat.dev/egommerce/api-cache:dev
environment:
- PASSWORD=12345678
api-logger: api-logger:
image: git.pbiernat.dev/egommerce/api-logger:dev image: git.pbiernat.dev/egommerce/api-logger:dev
hostname: logger.egommerce.pbiernat.dev hostname: logger.egommerce.pbiernat.dev
@ -132,6 +137,16 @@ services:
volumes: volumes:
- ./certs/api-gateway:/certs - ./certs/api-gateway:/certs
pricing-svc:
image: git.pbiernat.dev/egommerce/pricing-svc:dev
environment:
- APP_DOMAIN=pricing.api.egommerce.pbiernat.dev
- DATABASE_URL=postgres://postgres:12345678@db.egommerce.pbiernat.dev:5432/egommerce
- MONGODB_URL=mongodb://mongodb:12345678@mongodb.egommerce.pbiernat.dev:27017
- EVENTBUS_URL=amqp://guest:guest@eventbus.egommerce.pbiernat.dev:5672
volumes:
- ./certs/api-gateway:/certs
order-svc: order-svc:
image: git.pbiernat.dev/egommerce/order-svc:dev image: git.pbiernat.dev/egommerce/order-svc:dev
environment: environment:
@ -145,8 +160,8 @@ services:
# Workers (EventBus) # Workers (EventBus)
basket-worker: basket-worker:
image: git.pbiernat.dev/egommerce/basket-worker:dev image: git.pbiernat.dev/egommerce/basket-worker:dev
deploy: # deploy:
replicas: 2 # replicas: 2
environment: environment:
- DATABASE_URL=postgres://postgres:12345678@db.egommerce.pbiernat.dev:5432/egommerce - DATABASE_URL=postgres://postgres:12345678@db.egommerce.pbiernat.dev:5432/egommerce
- MONGODB_URL=mongodb://mongodb:12345678@mongodb.egommerce.pbiernat.dev:27017 - MONGODB_URL=mongodb://mongodb:12345678@mongodb.egommerce.pbiernat.dev:27017
@ -154,8 +169,17 @@ services:
catalog-worker: catalog-worker:
image: git.pbiernat.dev/egommerce/catalog-worker:dev image: git.pbiernat.dev/egommerce/catalog-worker:dev
deploy: # deploy:
replicas: 2 # replicas: 2
environment:
- DATABASE_URL=postgres://postgres:12345678@db.egommerce.pbiernat.dev:5432/egommerce
- MONGODB_URL=mongodb://mongodb:12345678@mongodb.egommerce.pbiernat.dev:27017
- EVENTBUS_URL=amqp://guest:guest@eventbus.egommerce.pbiernat.dev:5672
pricing-worker:
image: git.pbiernat.dev/egommerce/pricing-worker:dev
# deploy:
# replicas: 2
environment: environment:
- DATABASE_URL=postgres://postgres:12345678@db.egommerce.pbiernat.dev:5432/egommerce - DATABASE_URL=postgres://postgres:12345678@db.egommerce.pbiernat.dev:5432/egommerce
- MONGODB_URL=mongodb://mongodb:12345678@mongodb.egommerce.pbiernat.dev:27017 - MONGODB_URL=mongodb://mongodb:12345678@mongodb.egommerce.pbiernat.dev:27017
@ -163,8 +187,8 @@ services:
order-worker: order-worker:
image: git.pbiernat.dev/egommerce/order-worker:dev image: git.pbiernat.dev/egommerce/order-worker:dev
deploy: # deploy:
replicas: 2 # replicas: 2
environment: environment:
- DATABASE_URL=postgres://postgres:12345678@db.egommerce.pbiernat.dev:5432/egommerce - DATABASE_URL=postgres://postgres:12345678@db.egommerce.pbiernat.dev:5432/egommerce
- MONGODB_URL=mongodb://mongodb:12345678@mongodb.egommerce.pbiernat.dev:27017 - MONGODB_URL=mongodb://mongodb:12345678@mongodb.egommerce.pbiernat.dev:27017

View File

@ -12,10 +12,6 @@ services:
networks: networks:
- api-gateway-network - api-gateway-network
# - api-logger-network # TODO # - api-logger-network # TODO
- identity-svc-network
- basket-svc-network
- catalog-svc-network
- order-svc-network
volumes: volumes:
- /var/run/docker.sock:/var/run/docker.sock - /var/run/docker.sock:/var/run/docker.sock
@ -24,19 +20,13 @@ services:
environment: environment:
- APP_NAME=api-registry - APP_NAME=api-registry
- APP_DOMAIN - APP_DOMAIN
- CONSUL_HTTP_TOKEN=VeryS3cr3tTok3N
volumes: volumes:
- registry_data:/consul/data - registry_data:/consul/data
networks: networks:
- api-registry-network - api-registry-network
# - api-logger-network # TODO # - api-logger-network # TODO
- api-gateway-network - api-gateway-network
- identity-svc-network
- basket-svc-network
- catalog-svc-network
- order-svc-network
- basket-worker-network
- catalog-worker-network
- order-worker-network
api-eventbus: api-eventbus:
image: git.pbiernat.dev/egommerce/api-eventbus:latest image: git.pbiernat.dev/egommerce/api-eventbus:latest
@ -58,6 +48,14 @@ services:
- api-registry-network - api-registry-network
- api-logger-network - api-logger-network
api-cache:
image: git.pbiernat.dev/egommerce/api-cache:latest
environment:
- APP_NAME=api-cache
networks:
- api-cache-network
- api-logger-network
api-logger: api-logger:
image: git.pbiernat.dev/egommerce/api-logger:latest image: git.pbiernat.dev/egommerce/api-logger:latest
environment: environment:
@ -107,13 +105,18 @@ services:
image: git.pbiernat.dev/egommerce/identity-svc:latest image: git.pbiernat.dev/egommerce/identity-svc:latest
environment: environment:
- APP_NAME=identity-svc - APP_NAME=identity-svc
- APP_PATH_PREFIX=/identity
- APP_DOMAIN - APP_DOMAIN
- APP_KV_NAMESPACE - APP_KV_NAMESPACE
- DATABASE_URL - DATABASE_URL
- MONGODB_URL - MONGODB_URL
- EVENTBUS_URL - EVENTBUS_URL
volumes:
- ./db_migrations/identity-svc:/migrations
networks: networks:
- identity-svc-network - identity-svc-network
- api-gateway-network
- api-registry-network
- api-eventbus-network - api-eventbus-network
- api-logger-network - api-logger-network
- postgres-db-network - postgres-db-network
@ -123,13 +126,18 @@ services:
image: git.pbiernat.dev/egommerce/basket-svc:latest image: git.pbiernat.dev/egommerce/basket-svc:latest
environment: environment:
- APP_NAME=basket-svc - APP_NAME=basket-svc
- APP_PATH_PREFIX=/basket
- APP_DOMAIN - APP_DOMAIN
- APP_KV_NAMESPACE - APP_KV_NAMESPACE
- DATABASE_URL - DATABASE_URL
- MONGODB_URL - MONGODB_URL
- EVENTBUS_URL - EVENTBUS_URL
volumes:
- ./db_migrations/basket-svc:/migrations
networks: networks:
- basket-svc-network - basket-svc-network
- api-gateway-network
- api-registry-network
- api-eventbus-network - api-eventbus-network
- api-logger-network - api-logger-network
- postgres-db-network - postgres-db-network
@ -139,13 +147,39 @@ services:
image: git.pbiernat.dev/egommerce/catalog-svc:latest image: git.pbiernat.dev/egommerce/catalog-svc:latest
environment: environment:
- APP_NAME=catalog-svc - APP_NAME=catalog-svc
- APP_PATH_PREFIX=/catalog
- APP_DOMAIN - APP_DOMAIN
- APP_KV_NAMESPACE - APP_KV_NAMESPACE
- DATABASE_URL - DATABASE_URL
- MONGODB_URL - MONGODB_URL
- EVENTBUS_URL - EVENTBUS_URL
volumes:
- ./db_migrations/catalog-svc:/migrations
networks: networks:
- catalog-svc-network - catalog-svc-network
- api-gateway-network
- api-registry-network
- api-eventbus-network
- api-logger-network
- postgres-db-network
- mongodb-db-network
pricing-svc:
image: git.pbiernat.dev/egommerce/pricing-svc:latest
environment:
- APP_NAME=pricing-svc
- APP_PATH_PREFIX=/pricing
- APP_DOMAIN
- APP_KV_NAMESPACE
- DATABASE_URL
- MONGODB_URL
- EVENTBUS_URL
volumes:
- ./db_migrations/pricing-svc:/migrations
networks:
- pricing-svc-network
- api-gateway-network
- api-registry-network
- api-eventbus-network - api-eventbus-network
- api-logger-network - api-logger-network
- postgres-db-network - postgres-db-network
@ -155,13 +189,18 @@ services:
image: git.pbiernat.dev/egommerce/order-svc:latest image: git.pbiernat.dev/egommerce/order-svc:latest
environment: environment:
- APP_NAME=order-svc - APP_NAME=order-svc
- APP_PATH_PREFIX=/order
- APP_DOMAIN - APP_DOMAIN
- APP_KV_NAMESPACE - APP_KV_NAMESPACE
- DATABASE_URL - DATABASE_URL
- MONGODB_URL - MONGODB_URL
- EVENTBUS_URL - EVENTBUS_URL
volumes:
- ./db_migrations/order-svc:/migrations
networks: networks:
- order-svc-network - order-svc-network
- api-gateway-network
- api-registry-network
- api-eventbus-network - api-eventbus-network
- api-logger-network - api-logger-network
- postgres-db-network - postgres-db-network
@ -178,6 +217,8 @@ services:
- EVENTBUS_URL - EVENTBUS_URL
networks: networks:
- basket-worker-network - basket-worker-network
- pricing-svc-network
- api-registry-network
- api-eventbus-network - api-eventbus-network
- api-logger-network - api-logger-network
- postgres-db-network - postgres-db-network
@ -192,6 +233,22 @@ services:
- EVENTBUS_URL - EVENTBUS_URL
networks: networks:
- catalog-worker-network - catalog-worker-network
- api-registry-network
- api-eventbus-network
- api-logger-network
- postgres-db-network
- mongodb-db-network
pricing-worker:
image: git.pbiernat.dev/egommerce/pricing-worker:latest
environment:
- APP_NAME=pricing-worker
- DATABASE_URL
- MONGODB_URL
- EVENTBUS_URL
networks:
- pricing-worker-network
- api-registry-network
- api-eventbus-network - api-eventbus-network
- api-logger-network - api-logger-network
- postgres-db-network - postgres-db-network
@ -206,6 +263,8 @@ services:
- EVENTBUS_URL - EVENTBUS_URL
networks: networks:
- order-worker-network - order-worker-network
- basket-svc-network
- api-registry-network
- api-eventbus-network - api-eventbus-network
- api-logger-network - api-logger-network
- postgres-db-network - postgres-db-network
@ -231,6 +290,10 @@ networks:
driver: overlay driver: overlay
internal: true internal: true
api-cache-network:
driver: overlay
internal: true
api-logger-network: api-logger-network:
driver: overlay driver: overlay
internal: true internal: true
@ -256,6 +319,10 @@ networks:
driver: overlay driver: overlay
internal: true internal: true
pricing-svc-network:
driver: overlay
internal: true
order-svc-network: order-svc-network:
driver: overlay driver: overlay
internal: true internal: true
@ -273,6 +340,10 @@ networks:
driver: overlay driver: overlay
internal: true internal: true
pricing-worker-network:
driver: overlay
internal: true
order-worker-network: order-worker-network:
driver: overlay driver: overlay
internal: true internal: true

View File

@ -1,14 +0,0 @@
{
"node_name": "api-registry",
"server": true,
"bootstrap" : true,
"ui_config": {
"enabled" : true
},
"data_dir": "/consul/data",
"addresses": {
"http" : "0.0.0.0"
},
"bind_addr": "0.0.0.0",
"advertise_addr": "127.0.0.1"
}