From f65fa8e99ff49c6b779cd605c45f69730ab2b670 Mon Sep 17 00:00:00 2001 From: Mikhail Trubnikov Date: Mon, 25 Sep 2023 16:34:14 +1000 Subject: [PATCH] docker gt --- .gitlab-ci.yml | 49 +++++++++++++++++++ PARR.GeneratorTemplatesWorker/Dockerfile | 25 ++++++++++ .../PARR.GeneratorTemplatesWorker.csproj | 2 + .../Properties/launchSettings.json | 11 +++-- README.md | 7 ++- docker-compose.geterator-templates.yml | 11 +++++ 6 files changed, 99 insertions(+), 6 deletions(-) create mode 100644 PARR.GeneratorTemplatesWorker/Dockerfile create mode 100644 docker-compose.geterator-templates.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aeee4280..54e6c01d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,7 @@ variables: PROD_NAME_API: "parr/parr-api" PROD_NAME_AIHIT: "parr/parr-aihit-syncher" PROD_NAME_ESPP_TEMPLATE: "parr/parr-espp-template-sync" + PROD_NAME_GENERATOR_TEMPLATES: "parr/parr-generator-templates" stages: - build @@ -160,5 +161,53 @@ prod_espp-template_deploy: matrix: - RUNNER: shell-api-swarm-01 #- RUNNER: shell-et-1 + tags: + - ${RUNNER} + + +### GENERATOR TEMPLATES PROD ### +prod_generator_templates_build: + stage: build + only: + - /^gt[0-9]+\.[0-9]+\.[0-9]+$/ + except: + - branches + services: + - name: docker:20.10.21-dind + command: [ + "--insecure-registry=10.99.253.167:8090", + "--registry-mirror=http://10.99.253.167:8090", + "--insecure-registry=harbor.dvgd.rzd", + "--tls=false" + ] + variables: + DOCKER_HOST: tcp://docker:2375 + DOCKER_DRIVER: overlay2 + DOCKER_TLS_CERTDIR: "" + script: + - APP_VERSION=$(echo $CI_COMMIT_TAG | tr -d gt) + - IMAGE_VERSION=$(echo $CI_COMMIT_TAG | sed 's/gt/v/g') + - docker build -t $REPO/$PROD_NAME_GENERATOR_TEMPLATES:$IMAGE_VERSION -t $REPO/$PROD_NAME_GENERATOR_TEMPLATES:latest -t $PROD_NAME_GENERATOR_TEMPLATES:$IMAGE_VERSION -t $PROD_NAME_GENERATOR_TEMPLATES:latest --build-arg app_version=$APP_VERSION -f PARR.GeneratorTemplatesWorker/Dockerfile . + - docker login -u $HARBOR_PUSH_USER -p $HARBOR_PUSH_PASS $REPO + - docker push --all-tags $REPO/$PROD_NAME_GENERATOR_TEMPLATES + tags: + - docker + + +prod_generator_templates_deploy: + stage: deploy + environment: + name: parr-generator-templates-sync + only: + - /^gt[0-9]+\.[0-9]+\.[0-9]+$/ + except: + - branches + script: + - IMAGE_VERSION=$(echo $CI_COMMIT_TAG | sed 's/gt/v/g') + - docker login -u $HARBOR_PULL_USER -p $HARBOR_PULL_PASS $REPO + - tag=$IMAGE_VERSION docker stack deploy -c docker-compose.generator-templates.yml parr-generator-templates --with-registry-auth + parallel: + matrix: + - RUNNER: shell-api-swarm-01 tags: - ${RUNNER} \ No newline at end of file diff --git a/PARR.GeneratorTemplatesWorker/Dockerfile b/PARR.GeneratorTemplatesWorker/Dockerfile new file mode 100644 index 00000000..1933f127 --- /dev/null +++ b/PARR.GeneratorTemplatesWorker/Dockerfile @@ -0,0 +1,25 @@ +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM 10.99.253.167:8090/dotnet/runtime:7.0 AS base +WORKDIR /app + +FROM 10.99.253.167:8090/dotnet/sdk:7.0 AS build +WORKDIR /src +COPY ["NuGet.config", "."] +COPY ["PARR.GeneratorTemplatesWorker/PARR.GeneratorTemplatesWorker.csproj", "PARR.GeneratorTemplatesWorker/"] +COPY ["PARR.GeneratorTemplates/PARR.GeneratorTemplates.csproj", "PARR.GeneratorTemplates/"] +COPY ["PARR.BLL/PARR.BLL.csproj", "PARR.BLL/"] +COPY ["PARR.DAL/PARR.DAL.csproj", "PARR.DAL/"] +RUN dotnet restore "PARR.GeneratorTemplatesWorker/PARR.GeneratorTemplatesWorker.csproj" +COPY . . +WORKDIR "/src/PARR.GeneratorTemplatesWorker" +RUN dotnet build "PARR.GeneratorTemplatesWorker.csproj" -c Release -o /app/build + +FROM build AS publish +ARG app_version=0.0.0-default +RUN dotnet publish "PARR.GeneratorTemplatesWorker.csproj" -c Release -o /app/publish /p:UseAppHost=false /p:Version=$app_version + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "PARR.GeneratorTemplatesWorker.dll"] \ No newline at end of file diff --git a/PARR.GeneratorTemplatesWorker/PARR.GeneratorTemplatesWorker.csproj b/PARR.GeneratorTemplatesWorker/PARR.GeneratorTemplatesWorker.csproj index bb916995..aae195a0 100644 --- a/PARR.GeneratorTemplatesWorker/PARR.GeneratorTemplatesWorker.csproj +++ b/PARR.GeneratorTemplatesWorker/PARR.GeneratorTemplatesWorker.csproj @@ -5,11 +5,13 @@ enable enable dotnet-PARR.GeneratorTemplatesWorker-deb14157-f207-44e0-8d4b-963c6066a75e + Linux + diff --git a/PARR.GeneratorTemplatesWorker/Properties/launchSettings.json b/PARR.GeneratorTemplatesWorker/Properties/launchSettings.json index 06416c77..71e7a731 100644 --- a/PARR.GeneratorTemplatesWorker/Properties/launchSettings.json +++ b/PARR.GeneratorTemplatesWorker/Properties/launchSettings.json @@ -1,11 +1,14 @@ -{ +{ "profiles": { "PARR.GeneratorTemplatesWorker": { "commandName": "Project", - "dotnetRunMessages": true, "environmentVariables": { "DOTNET_ENVIRONMENT": "Development" - } + }, + "dotnetRunMessages": true + }, + "Docker": { + "commandName": "Docker" } } -} +} \ No newline at end of file diff --git a/README.md b/README.md index 5fff5646..bf7e0e2f 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,15 @@ ## Структура - PARR.AIHIT - логика синхронизации АИХ ИТ с БД PARR +- PARR.AIHITWorker - worker для PARR.AIHIT - PARR.API - API - PARR.BLL - общие методы и настройки для проектов - PARR.DAL - модели, сервисы по работе с БД PARR - PARR.EsppTemplateSync - логика синхронизации шаблонов ESPP с БД PARR - PARR.EsppTemplateSyncWorker - worker для PARR.EsppTemplateSync +- PARR.GeneratorTemplates - логика генерации шаблонов в ПАРР +- PARR.GeneratorTemplatesWorker - Worker для PARR.GeneratorTemplates - PARR.Mail - сервис по работе с почтой -- PARR.Worker - worker для PARR.AIHIT - PARR.MockData - загрузка тестовых данных ## CICD @@ -21,7 +23,8 @@ - v1.0.0 - PARR.API - et1.0.0 - PARR.EsppTemplateSyncWorker -- as1.0.0 - PARR.Worker (AIHIT) +- as1.0.0 - PARR.AIHITWorker +- gt1.0.0 - PARR.GeneratorTemplates ## Настройка хранилища diff --git a/docker-compose.geterator-templates.yml b/docker-compose.geterator-templates.yml new file mode 100644 index 00000000..2ed964c8 --- /dev/null +++ b/docker-compose.geterator-templates.yml @@ -0,0 +1,11 @@ +version: '3.4' + +#PARR GENERATOR TEMPLATES +services: + parr-generator-templates: + image: harbor.dvgd.rzd/parr/parr-generator-templates:${tag-latest} + environment: + - ASPNETCORE_ENVIRONMENT=Production + - TZ=Europe/Moscow + deploy: + replicas: 1 \ No newline at end of file