diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1b4a02b5..8ad79666 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,6 +14,7 @@ variables: PROD_TEMPLATE_DISTRIBOTOR: "parr/parr-template-distributor" PROD_TEMPLATE_ACTIVATOR: "parr/parr-template-activator" PROD_TEMPLATE_GENERATOR: "parr/parr-template-generator" + PROD_TEMPLATE_TASK_GENERATOR: "parr/parr-template-task-generator" PROD_JOB_AUTO_CONTROL: "parr/parr-job-auto-control" stages: @@ -688,7 +689,6 @@ prod_template_generator_build: tags: - docker - prod_template_generator_deploy: stage: deploy environment: @@ -708,6 +708,53 @@ prod_template_generator_deploy: - ${RUNNER} +### TEMPLATE TASK GENERATOR PROD ### +prod_template_task_generator_build: + stage: build + only: + - /^ttg[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 ttg) + - IMAGE_VERSION=$(echo $CI_COMMIT_TAG | sed 's/ttg/v/g') + - docker build -t $REPO/$PROD_TEMPLATE_TASK_GENERATOR:$IMAGE_VERSION -t $REPO/$PROD_TEMPLATE_TASK_GENERATOR:latest -t $PROD_TEMPLATE_TASK_GENERATOR:$IMAGE_VERSION -t $PROD_TEMPLATE_TASK_GENERATOR:latest --build-arg app_version=$APP_VERSION -f PARR.TemplateTaskGeneratorWorker/Dockerfile . + - docker login -u $HARBOR_PUSH_USER -p $HARBOR_PUSH_PASS $REPO + - docker push --all-tags $REPO/$PROD_TEMPLATE_TASK_GENERATOR + tags: + - docker + +prod_template_task_generator_deploy: + stage: deploy + environment: + name: parr-template-task-generator + only: + - /^ttg[0-9]+\.[0-9]+\.[0-9]+$/ + except: + - branches + script: + - IMAGE_VERSION=$(echo $CI_COMMIT_TAG | sed 's/ttg/v/g') + - docker login -u $HARBOR_PULL_USER -p $HARBOR_PULL_PASS $REPO + - tag=$IMAGE_VERSION docker stack deploy -c docker-compose.template-task-enerator.yml parr-template-task-generator --with-registry-auth + parallel: + matrix: + - RUNNER: shell-api-swarm-01 + tags: + - ${RUNNER} + + ### JOB AUTO CONTROL PROD ### prod_job_auto_control_build: stage: build diff --git a/TemplateTaskGeneratorWorker/Dockerfile b/TemplateTaskGeneratorWorker/Dockerfile new file mode 100644 index 00000000..d375d741 --- /dev/null +++ b/TemplateTaskGeneratorWorker/Dockerfile @@ -0,0 +1,33 @@ +# 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. + +# This stage is used when running from VS in fast mode (Default for Debug configuration) +FROM 10.99.253.167:8090/dotnet/runtime:7.0 AS base +WORKDIR /app + + +# This stage is used to build the service project +FROM 10.99.253.167:8090/dotnet/sdk:7.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["NuGet.config", "."] +COPY ["TemplateTaskGeneratorWorker/PARR.TemplateTaskGeneratorWorker.csproj", "TemplateTaskGeneratorWorker/"] +COPY ["TemplateTaskGenerator/PARR.TemplateTaskGenerator.csproj", "TemplateTaskGenerator/"] +COPY ["PARR.BLL/PARR.BLL.csproj", "PARR.BLL/"] +COPY ["PARR.Common/PARR.Common.csproj", "PARR.Common/"] +COPY ["PARR.Constants/PARR.Constants.csproj", "PARR.Constants/"] +COPY ["PARR.DAL/PARR.DAL.csproj", "PARR.DAL/"] +RUN dotnet restore "./TemplateTaskGeneratorWorker/PARR.TemplateTaskGeneratorWorker.csproj" +COPY . . +WORKDIR "/src/TemplateTaskGeneratorWorker" +RUN dotnet build "./PARR.TemplateTaskGeneratorWorker.csproj" -c $BUILD_CONFIGURATION -o /app/build + +# This stage is used to publish the service project to be copied to the final stage +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./PARR.TemplateTaskGeneratorWorker.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false /p:Version=$app_version + +# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration) +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "PARR.TemplateTaskGeneratorWorker.dll"] \ No newline at end of file diff --git a/TemplateTaskGeneratorWorker/PARR.TemplateTaskGeneratorWorker.csproj b/TemplateTaskGeneratorWorker/PARR.TemplateTaskGeneratorWorker.csproj index b9293df5..847cddbc 100644 --- a/TemplateTaskGeneratorWorker/PARR.TemplateTaskGeneratorWorker.csproj +++ b/TemplateTaskGeneratorWorker/PARR.TemplateTaskGeneratorWorker.csproj @@ -5,11 +5,13 @@ enable enable dotnet-TemplateTaskGeneratorWorker-31809d29-599f-4a6d-8700-45ea8d9e7649 + Linux + diff --git a/TemplateTaskGeneratorWorker/Properties/launchSettings.json b/TemplateTaskGeneratorWorker/Properties/launchSettings.json index f349ae0f..e7d4f62a 100644 --- a/TemplateTaskGeneratorWorker/Properties/launchSettings.json +++ b/TemplateTaskGeneratorWorker/Properties/launchSettings.json @@ -1,11 +1,14 @@ -{ +{ "profiles": { "TemplateTaskGeneratorWorker": { "commandName": "Project", - "dotnetRunMessages": true, "environmentVariables": { "DOTNET_ENVIRONMENT": "Development" - } + }, + "dotnetRunMessages": true + }, + "Container (Dockerfile)": { + "commandName": "Docker" } } -} +} \ No newline at end of file diff --git a/docker-compose.dcproj b/docker-compose.dcproj index 556b079f..7c3c379f 100644 --- a/docker-compose.dcproj +++ b/docker-compose.dcproj @@ -9,6 +9,7 @@ parr.api + diff --git a/docker-compose.template-task-generator.yml b/docker-compose.template-task-generator.yml new file mode 100644 index 00000000..1c769831 --- /dev/null +++ b/docker-compose.template-task-generator.yml @@ -0,0 +1,25 @@ +version: '3.4' + +#PARR TEMPLATE TASK GENERATOR +services: + parr-template-task-generator: + image: harbor.dvgd.rzd/parr/parr-template-task-generator:${tag-latest} + environment: + - ASPNETCORE_ENVIRONMENT=Production + - TZ=Europe/Moscow + logging: + driver: fluentd + options: + fluentd-address: dvgd-efk-01.dvgd.oao.rzd:24224 + fluentd-retry-wait: '30s' + fluentd-max-retries: '30' + tag: parr.template-task-generator.serilog + deploy: + replicas: 1 + networks: + parr-network: + +networks: + parr-network: + driver: overlay + external: true \ No newline at end of file