From 722a394d03773f966836a96884ee9e99e26bd780 Mon Sep 17 00:00:00 2001 From: Serghei Cebotari Date: Sun, 14 Jan 2024 15:07:03 +0300 Subject: Docker files update --- .dockerignore | 1 - Database/Dockerfile | 6 ++++ Database/init-database.sql | 25 +++++++++++++++++ Dockerfile | 1 - RhSolutions.Api/Deploy/Database/Dockerfile | 6 ---- RhSolutions.Api/Deploy/Database/init-database.sql | 25 ----------------- RhSolutions.Api/Deploy/docker-compose.yml | 27 ------------------ docker-compose.yml | 34 +++++++++++++++++++++++ 8 files changed, 65 insertions(+), 60 deletions(-) delete mode 100644 .dockerignore create mode 100644 Database/Dockerfile create mode 100644 Database/init-database.sql delete mode 100644 RhSolutions.Api/Deploy/Database/Dockerfile delete mode 100644 RhSolutions.Api/Deploy/Database/init-database.sql delete mode 100644 RhSolutions.Api/Deploy/docker-compose.yml create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index a1670e1..0000000 --- a/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -[Dd]eploy/ \ No newline at end of file diff --git a/Database/Dockerfile b/Database/Dockerfile new file mode 100644 index 0000000..a5b3787 --- /dev/null +++ b/Database/Dockerfile @@ -0,0 +1,6 @@ +FROM postgres:16.1 AS build +ADD ./init-database.sql /docker-entrypoint-initdb.d +RUN chmod 644 /docker-entrypoint-initdb.d/init-database.sql +EXPOSE 5432 +ENTRYPOINT [ "docker-entrypoint.sh" ] +CMD [ "postgres" ] \ No newline at end of file diff --git a/Database/init-database.sql b/Database/init-database.sql new file mode 100644 index 0000000..91e9f95 --- /dev/null +++ b/Database/init-database.sql @@ -0,0 +1,25 @@ +CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" ( + "MigrationId" character varying(150) NOT NULL, + "ProductVersion" character varying(32) NOT NULL, + CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId") +); + +START TRANSACTION; + +CREATE TABLE "Products" ( + "Id" text NOT NULL, + "Name" text NOT NULL, + "ProductSku" text NOT NULL, + "DeprecatedSkus" text[] NOT NULL, + "ProductLines" text[] NOT NULL, + "IsOnWarehouse" boolean NOT NULL, + "ProductMeasure" integer NOT NULL, + "DeliveryMakeUp" double precision NULL, + "Price" numeric NOT NULL, + CONSTRAINT "PK_Products" PRIMARY KEY ("Id") +); + +INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") +VALUES ('20230511043408_Init', '7.0.5'); + +COMMIT; \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index db24e34..3b8aef5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,6 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /app COPY . ./ -RUN dotnet restore RUN dotnet publish -c Release -o out FROM mcr.microsoft.com/dotnet/aspnet:8.0 diff --git a/RhSolutions.Api/Deploy/Database/Dockerfile b/RhSolutions.Api/Deploy/Database/Dockerfile deleted file mode 100644 index 5d76b63..0000000 --- a/RhSolutions.Api/Deploy/Database/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM postgres:latest AS build -ADD ./init-database.sql /docker-entrypoint-initdb.d -RUN chmod 644 /docker-entrypoint-initdb.d/init-database.sql -EXPOSE 5432 -ENTRYPOINT [ "docker-entrypoint.sh" ] -CMD [ "postgres" ] \ No newline at end of file diff --git a/RhSolutions.Api/Deploy/Database/init-database.sql b/RhSolutions.Api/Deploy/Database/init-database.sql deleted file mode 100644 index 91e9f95..0000000 --- a/RhSolutions.Api/Deploy/Database/init-database.sql +++ /dev/null @@ -1,25 +0,0 @@ -CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" ( - "MigrationId" character varying(150) NOT NULL, - "ProductVersion" character varying(32) NOT NULL, - CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId") -); - -START TRANSACTION; - -CREATE TABLE "Products" ( - "Id" text NOT NULL, - "Name" text NOT NULL, - "ProductSku" text NOT NULL, - "DeprecatedSkus" text[] NOT NULL, - "ProductLines" text[] NOT NULL, - "IsOnWarehouse" boolean NOT NULL, - "ProductMeasure" integer NOT NULL, - "DeliveryMakeUp" double precision NULL, - "Price" numeric NOT NULL, - CONSTRAINT "PK_Products" PRIMARY KEY ("Id") -); - -INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") -VALUES ('20230511043408_Init', '7.0.5'); - -COMMIT; \ No newline at end of file diff --git a/RhSolutions.Api/Deploy/docker-compose.yml b/RhSolutions.Api/Deploy/docker-compose.yml deleted file mode 100644 index 12759a8..0000000 --- a/RhSolutions.Api/Deploy/docker-compose.yml +++ /dev/null @@ -1,27 +0,0 @@ -version: '3' - -services: - rhsolutions-api: - image: gitea.cebotari.ru/chebser/rhsolutions-api:latest - container_name: rhsolutions-api - ports: - - 5000:5000 - environment: - - DB_HOST=rhsolutions-db - - DB_PORT=5432 - - DB_DATABASE=rhsolutions - - DB_USER=chebser - - DB_PASSWORD=Rehau-987 - depends_on: - - rhsolutions-db - restart: unless-stopped - rhsolutions-db: - image: gitea.cebotari.ru/chebser/rhsolutions-db:latest - container_name: rhsolutions-db - ports: - - 5432:5432 - environment: - - POSTGRES_USER=chebser - - POSTGRES_PASSWORD=Rehau-987 - - POSTGRES_DB=rhsolutions - restart: unless-stopped \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1c01b58 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,34 @@ +version: '3' +services: + app: + build: . + container_name: app + ports: + - 5000:5000 + environment: + - DB_HOST=db + - DB_PORT=5432 + - DB_DATABASE=rhsolutions + - DB_USER=chebser + - DB_PASSWORD=Rehau-987 + networks: + - rhsolutions + volumes: + - ./RhSolutions.Api/MLModels:/app/MLModels + depends_on: + - db + db: + build: Database/. + container_name: db + environment: + - POSTGRES_USER=chebser + - POSTGRES_PASSWORD=Rehau-987 + - POSTGRES_DB=rhsolutions + volumes: + - db-data:/var/lib/postgresql/data + networks: + - rhsolutions +networks: + rhsolutions: +volumes: + db-data: \ No newline at end of file -- cgit v1.2.3