From 1acccf472b0475aa84f621773ae7114efee454e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D1=82=D0=BA=D0=BE=D0=B2=D1=81=D0=BA=D0=B8?= =?UTF-8?q?=D1=85=20=D0=95=D0=B2=D0=B3=D0=B5=D0=BD=D0=B8=D0=B9?= Date: Tue, 15 Jul 2025 11:51:38 +0300 Subject: [PATCH] =?UTF-8?q?=D0=91=D0=94=20=D0=BD=D0=B0=20Postgres=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=B8=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=82?= =?UTF-8?q?=D0=B0=D0=B6=D0=B5=D0=B9=201)=20General?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 + DB/General/Deployment/schema.psql | 3 + DB/General/Deployment/tables.psql | 16 ++++++ DB/General/dbchangelog-master.xml | 23 ++++++++ DB/General/docker-compose.yml | 22 +++++++ DB/General/liquibase.properties | 5 ++ Deploy.ps1 | 18 ++++++ PGServer/docker-compose.yml | 60 ++++++++++++++++++++ PGServer/docker-entrypoint-initdb.d/init.sql | 1 + pgAdmin/docker-compose.yml | 33 +++++++++++ 10 files changed, 183 insertions(+) create mode 100644 .gitignore create mode 100644 DB/General/Deployment/schema.psql create mode 100644 DB/General/Deployment/tables.psql create mode 100644 DB/General/dbchangelog-master.xml create mode 100644 DB/General/docker-compose.yml create mode 100644 DB/General/liquibase.properties create mode 100644 Deploy.ps1 create mode 100644 PGServer/docker-compose.yml create mode 100644 PGServer/docker-entrypoint-initdb.d/init.sql create mode 100644 pgAdmin/docker-compose.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a39c1ad --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +.vs \ No newline at end of file diff --git a/DB/General/Deployment/schema.psql b/DB/General/Deployment/schema.psql new file mode 100644 index 0000000..280bdcc --- /dev/null +++ b/DB/General/Deployment/schema.psql @@ -0,0 +1,3 @@ +CREATE SCHEMA Cabinet; +CREATE SCHEMA Auth; +CREATE SCHEMA Billing; diff --git a/DB/General/Deployment/tables.psql b/DB/General/Deployment/tables.psql new file mode 100644 index 0000000..b6fb051 --- /dev/null +++ b/DB/General/Deployment/tables.psql @@ -0,0 +1,16 @@ +CREATE TABLE IF NOT EXISTS Cabinet.Cabinet +( + id SERIAL PRIMARY KEY, + title text +); + +CREATE TABLE IF NOT EXISTS Auth."user" ( + id SERIAL PRIMARY KEY, + fullname text, + email text, + cabinetid integer DEFAULT 0, + isadmin boolean DEFAULT false, + login TEXT, + password TEXT, + FOREIGN KEY (CabinetId) REFERENCES Cabinet.Cabinet (Id) +); \ No newline at end of file diff --git a/DB/General/dbchangelog-master.xml b/DB/General/dbchangelog-master.xml new file mode 100644 index 0000000..6c9f244 --- /dev/null +++ b/DB/General/dbchangelog-master.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DB/General/docker-compose.yml b/DB/General/docker-compose.yml new file mode 100644 index 0000000..a8e3413 --- /dev/null +++ b/DB/General/docker-compose.yml @@ -0,0 +1,22 @@ +version: '3.8' +name: instructage-database + +services: + instructage-liquibase-accident: + container_name: instructage-liquibase-general + image: liquibase/liquibase:latest-alpine + volumes: + - .:/liquibase/changelog/ + entrypoint: + - "/bin/sh" + - "-c" + - sleep 0s && liquibase --defaultsFile=/liquibase/changelog/liquibase.properties update + + + +# docker network create instructage-network + +networks: + default: + external: true + name: instructage-network \ No newline at end of file diff --git a/DB/General/liquibase.properties b/DB/General/liquibase.properties new file mode 100644 index 0000000..2357de6 --- /dev/null +++ b/DB/General/liquibase.properties @@ -0,0 +1,5 @@ +searchPath: /liquibase/changelog +url: jdbc:postgresql://pg-instructage/general +changeLogFile: dbchangelog-master.xml +username:postgres +password:f0e87ce7-b857-4bbc-907c-ff0ab90514ad \ No newline at end of file diff --git a/Deploy.ps1 b/Deploy.ps1 new file mode 100644 index 0000000..bab2ebb --- /dev/null +++ b/Deploy.ps1 @@ -0,0 +1,18 @@ +docker network create instructage-network + +Set-Location PGServer +docker-compose down -v +docker-compose up --build -d + +Set-Location ../pgAdmin +docker-compose down -v +docker-compose up --build -d + +timeout 5 + +Set-Location ../db +Set-Location General +docker-compose down -v +docker-compose up --build -d + +Set-Location ../../ diff --git a/PGServer/docker-compose.yml b/PGServer/docker-compose.yml new file mode 100644 index 0000000..4fca6b2 --- /dev/null +++ b/PGServer/docker-compose.yml @@ -0,0 +1,60 @@ +version: '3.8' +name: instructage-database + +services: + pg-instructage: + container_name: pg-instructage + image: postgres:latest + restart: always + ports: + - 9999:5432 + environment: + POSTGRES_DB: postgres + POSTGRES_USER: postgres + POSTGRES_PASSWORD: "f0e87ce7-b857-4bbc-907c-ff0ab90514ad" + PGDATA: "/data" + #Включение логирования + command: [ "postgres", "-c", "log_statement=all", "-c", "log_destination=stderr", "-c", "log_duration=off" , "-c", "log_min_duration_statement=1000ms" ] + volumes: + #Путь, по которому будут лежать файлы баз данных + - instructage-db-data:/data + #При первом запуске через точку инициализации создаются пустые базы данных для дальнейшего заполнения через liquibase + - ./docker-entrypoint-initdb.d/:/docker-entrypoint-initdb.d/ + + # pgadmin: + # container_name: pgadmin + # image: dpage/pgadmin4:latest + # ports: + # - 15432:80 + # environment: + # PGADMIN_DEFAULT_EMAIL: sa@sa.sa + # PGADMIN_DEFAULT_PASSWORD: simDev321 + # PGADMIN_LISTEN_PORT: 80 + # volumes: + # - pgadmin:/var/lib/pgadmin + # depends_on: + # - pg-instructage + +volumes: + instructage-db-data: + # driver: local + # driver_opts: + # o: bind + # type: none + # device: C:/Postgres/pgdata + + + # pgadmin: + # name: pgadmin + # driver: local + # driver_opts: + # o: bind + # type: none + # device: C:/Postgres/PgAdmin + +# docker network create instructage-network + +networks: + default: + external: true + name: instructage-network diff --git a/PGServer/docker-entrypoint-initdb.d/init.sql b/PGServer/docker-entrypoint-initdb.d/init.sql new file mode 100644 index 0000000..fcb7171 --- /dev/null +++ b/PGServer/docker-entrypoint-initdb.d/init.sql @@ -0,0 +1 @@ +CREATE DATABASE General; \ No newline at end of file diff --git a/pgAdmin/docker-compose.yml b/pgAdmin/docker-compose.yml new file mode 100644 index 0000000..2289936 --- /dev/null +++ b/pgAdmin/docker-compose.yml @@ -0,0 +1,33 @@ +version: '3.8' +name: instructage-database + +services: + pgadmin: + container_name: pgadmin + image: dpage/pgadmin4:latest + ports: + - 15432:80 + environment: + PGADMIN_DEFAULT_EMAIL: sa@sa.sa + PGADMIN_DEFAULT_PASSWORD: simDev321 + PGADMIN_LISTEN_PORT: 80 + volumes: + - pgadmin:/var/lib/pgadmin + # depends_on: + # - postgres + +volumes: + pgadmin: + # name: pgadmin + # driver: local + # driver_opts: + # o: bind + # type: none + # device: D:/Docker/PostgreSQL/PgAdmin + +# docker network create fgissout-network + +networks: + default: + external: true + name: instructage-network \ No newline at end of file