cicd
This commit is contained in:
93
.gitlab-ci.yml
Normal file
93
.gitlab-ci.yml
Normal file
@@ -0,0 +1,93 @@
|
||||
variables:
|
||||
REPO: "10.99.253.167:8088"
|
||||
PROD_NAME_API: "parr/parr-api"
|
||||
PROD_NAME_AIHIT: "parr/parr-aihit-syncher"
|
||||
|
||||
stages:
|
||||
- build
|
||||
- deploy
|
||||
|
||||
|
||||
### API PROD ###
|
||||
prod_build:
|
||||
stage: build
|
||||
only:
|
||||
- /^v[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=10.99.253.167:8088","--registry-mirror=http://10.99.253.167:8088"]
|
||||
variables:
|
||||
DOCKER_HOST: tcp://docker:2375
|
||||
DOCKER_DRIVER: overlay2
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
script:
|
||||
- IMAGE_VERSION=$(echo $CI_COMMIT_TAG | tr -d v)
|
||||
- docker build -t $REPO/$PROD_NAME_API:$CI_COMMIT_TAG -t $REPO/$PROD_NAME_API:latest -t $PROD_NAME_API:$CI_COMMIT_TAG -t $PROD_NAME_API:latest --build-arg app_version=$IMAGE_VERSION -f PARR.API/Dockerfile .
|
||||
- docker login -u $NEXUS_PUSH_USER -p $NEXUS_PUSH_PASS $REPO
|
||||
- docker push --all-tags $REPO/$PROD_NAME_API
|
||||
tags:
|
||||
- docker
|
||||
|
||||
|
||||
prod_deploy:
|
||||
stage: deploy
|
||||
environment:
|
||||
name: prod
|
||||
url: http://10.99.253.215:8090/api/v1/version
|
||||
only:
|
||||
- /^v[0-9]+\.[0-9]+\.[0-9]+$/
|
||||
except:
|
||||
- branches
|
||||
script:
|
||||
- tag=$CI_COMMIT_TAG docker compose up -d
|
||||
parallel:
|
||||
matrix:
|
||||
- RUNNER: shell-1
|
||||
tags:
|
||||
- ${RUNNER}
|
||||
|
||||
|
||||
|
||||
|
||||
### AIHIT PROD ###
|
||||
prod_aihit_build:
|
||||
stage: build
|
||||
only:
|
||||
- /^as[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=10.99.253.167:8088","--registry-mirror=http://10.99.253.167:8088"]
|
||||
variables:
|
||||
DOCKER_HOST: tcp://docker:2375
|
||||
DOCKER_DRIVER: overlay2
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
script:
|
||||
- IMAGE_VERSION=$(echo $CI_COMMIT_TAG | tr wl v)
|
||||
- docker build -t $REPO/$PROD_NAME_AIHIT:$IMAGE_VERSION -t $REPO/$PROD_NAME_AIHIT:latest -t $PROD_NAME_AIHIT:$IMAGE_VERSION -t $PROD_NAME_AIHIT:latest -f PARR.Worker/Dockerfile .
|
||||
- docker login -u $NEXUS_PUSH_USER -p $NEXUS_PUSH_PASS $REPO
|
||||
- docker push --all-tags $REPO/$PROD_NAME_AIHIT
|
||||
tags:
|
||||
- docker
|
||||
|
||||
|
||||
prod_aihit_deploy:
|
||||
stage: deploy
|
||||
environment:
|
||||
name: parr-aihit-syncher
|
||||
only:
|
||||
- /^as[0-9]+\.[0-9]+\.[0-9]+$/
|
||||
except:
|
||||
- branches
|
||||
script:
|
||||
- IMAGE_VERSION=$(echo $CI_COMMIT_TAG | tr as v)
|
||||
- tag=$IMAGE_VERSION docker compose -f docker-compose.aihit-syncher.yml up -d
|
||||
parallel:
|
||||
matrix:
|
||||
- RUNNER: shell-as-1
|
||||
tags:
|
||||
- ${RUNNER}
|
||||
|
||||
12
NuGet.config
Normal file
12
NuGet.config
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||
<add key="Nexus" value="http://10.99.253.167:8081/repository/nuget-group/index.json" />
|
||||
<add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
|
||||
</packageSources>
|
||||
<disabledPackageSources>
|
||||
<add key="nuget.org" value="true" />
|
||||
<add key="Microsoft Visual Studio Offline Packages" value="true" />
|
||||
</disabledPackageSources>
|
||||
</configuration>
|
||||
@@ -3,17 +3,23 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.4.33213.308
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.API", "PARR_API\PARR.API.csproj", "{82C57299-DA04-4A99-9C04-614FDDCE7AA1}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.API", "PARR.API\PARR.API.csproj", "{82C57299-DA04-4A99-9C04-614FDDCE7AA1}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.DAL", "PARR.DAL\PARR.DAL.csproj", "{CBC557EE-382E-4386-B4D2-2EE3DC9A7CBE}"
|
||||
EndProject
|
||||
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{AF6BD539-34B2-4D57-AEB3-F6FDE26B98ED}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.Mail", "PARR.Mail\PARR.Mail\PARR.Mail.csproj", "{228C8124-69E4-4AE0-8C33-0438E54FF1BA}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.Worker", "PARR.Worker\PARR.Worker\PARR.Worker.csproj", "{D15F308C-9F63-4D69-B06E-DDA26FEE9BAB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PARR.AIHIT", "PARR.AIHIT\AIHIT\PARR.AIHIT.csproj", "{3ED4E1CE-2AF5-4EB3-B7DF-B77CCC242B9E}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.AIHIT", "PARR.AIHIT\AIHIT\PARR.AIHIT.csproj", "{3ED4E1CE-2AF5-4EB3-B7DF-B77CCC242B9E}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C170A32C-5A9D-4F1C-B6FF-FAE12736ED17}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.gitlab-ci.yml = .gitlab-ci.yml
|
||||
NuGet.config = NuGet.config
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{AB278172-BFB4-4D54-9022-2D2A5B3338D7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -29,9 +35,6 @@ Global
|
||||
{CBC557EE-382E-4386-B4D2-2EE3DC9A7CBE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CBC557EE-382E-4386-B4D2-2EE3DC9A7CBE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CBC557EE-382E-4386-B4D2-2EE3DC9A7CBE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AF6BD539-34B2-4D57-AEB3-F6FDE26B98ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AF6BD539-34B2-4D57-AEB3-F6FDE26B98ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AF6BD539-34B2-4D57-AEB3-F6FDE26B98ED}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{228C8124-69E4-4AE0-8C33-0438E54FF1BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{228C8124-69E4-4AE0-8C33-0438E54FF1BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{228C8124-69E4-4AE0-8C33-0438E54FF1BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -44,6 +47,9 @@ Global
|
||||
{3ED4E1CE-2AF5-4EB3-B7DF-B77CCC242B9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3ED4E1CE-2AF5-4EB3-B7DF-B77CCC242B9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3ED4E1CE-2AF5-4EB3-B7DF-B77CCC242B9E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AB278172-BFB4-4D54-9022-2D2A5B3338D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AB278172-BFB4-4D54-9022-2D2A5B3338D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AB278172-BFB4-4D54-9022-2D2A5B3338D7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -1,11 +1,12 @@
|
||||
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
|
||||
FROM 10.99.253.167:8090/dotnet/aspnet:7.0 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
|
||||
FROM 10.99.253.167:8090/dotnet/sdk:7.0 AS build
|
||||
WORKDIR /src
|
||||
COPY ["NuGet.config", "."]
|
||||
COPY ["PARR_API/PARR.API.csproj", "PARR_API/"]
|
||||
COPY ["PARR.DAL/PARR.DAL.csproj", "PARR.DAL/"]
|
||||
RUN dotnet restore "PARR_API/PARR.API.csproj"
|
||||
@@ -14,9 +15,14 @@ WORKDIR "/src/PARR_API"
|
||||
RUN dotnet build "PARR.API.csproj" -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "PARR.API.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||
ARG app_version=0.0.0-default
|
||||
RUN dotnet publish "PARR.API.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.API.dll"]
|
||||
|
||||
|
||||
### EXAMPLE ###
|
||||
# docker build -t parr-api:v1.0.0 --build-arg app_version=1.0.0 -f PARR.API/Dockerfile .
|
||||
29
PARR.Worker/PARR.Worker/Dockerfile
Normal file
29
PARR.Worker/PARR.Worker/Dockerfile
Normal file
@@ -0,0 +1,29 @@
|
||||
#See https://aka.ms/containerfastmode to understand 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.Worker/PARR.Worker/PARR.Worker.csproj", "PARR.Worker/PARR.Worker/"]
|
||||
COPY ["PARR.AIHIT/AIHIT/PARR.AIHIT.csproj", "PARR.AIHIT/AIHIT/"]
|
||||
COPY ["PARR.DAL/PARR.DAL.csproj", "PARR.DAL/"]
|
||||
COPY ["PARR.Mail/PARR.Mail/PARR.Mail.csproj", "PARR.Mail/PARR.Mail/"]
|
||||
RUN dotnet restore "PARR.Worker/PARR.Worker/PARR.Worker.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/PARR.Worker/PARR.Worker"
|
||||
RUN dotnet build "PARR.Worker.csproj" -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
ARG app_version=0.0.0-default
|
||||
RUN dotnet publish "PARR.Worker.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.Worker.dll"]
|
||||
|
||||
|
||||
### EXAMPLE ###
|
||||
# docker build -t parr-aihit-syncher:v1.0.0 --build-arg app_version=1.0.0 -f PARR.Worker/Dockerfile .
|
||||
@@ -5,11 +5,14 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>dotnet-PARR.Worker-87bfa085-3c62-4b97-b25f-bdece8fc03df</UserSecretsId>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<DockerfileContext>..\..</DockerfileContext>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
{
|
||||
{
|
||||
"profiles": {
|
||||
"PARR.Worker": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"environmentVariables": {
|
||||
"DOTNET_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"dotnetRunMessages": true
|
||||
},
|
||||
"Docker": {
|
||||
"commandName": "Docker"
|
||||
}
|
||||
}
|
||||
}
|
||||
20
docker-compose.aihit-syncher.yml
Normal file
20
docker-compose.aihit-syncher.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
version: '3.4'
|
||||
|
||||
#AIHIT SYNCHER
|
||||
services:
|
||||
mail-reader:
|
||||
image: 10.99.253.167:8090/parr/parr-aihit-syncher:${tag:-latest}
|
||||
container_name: parr-aihit-syncher
|
||||
restart: always
|
||||
environment:
|
||||
- ASPNETCORE_ENVIRONMENT=Production
|
||||
- TZ=Europe/Moscow
|
||||
volumes:
|
||||
- /var/log/parr-aihit-syncher:/app/log
|
||||
|
||||
|
||||
# последняя версия
|
||||
#docker compose -f docker-compose.aihit-syncher.yml up -d
|
||||
# указанная версия
|
||||
#tag=v1.0.0 docker compose -f docker-compose.aihit-syncher.yml up -d
|
||||
|
||||
@@ -3,15 +3,13 @@
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectVersion>2.1</ProjectVersion>
|
||||
<DockerTargetOS>Linux</DockerTargetOS>
|
||||
<ProjectGuid>af6bd539-34b2-4d57-aeb3-f6fde26b98ed</ProjectGuid>
|
||||
<ProjectGuid>ab278172-bfb4-4d54-9022-2d2a5b3338d7</ProjectGuid>
|
||||
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
|
||||
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}/swagger</DockerServiceUrl>
|
||||
<DockerServiceName>parr.api</DockerServiceName>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="docker-compose.override.yml">
|
||||
<DependentUpon>docker-compose.yml</DependentUpon>
|
||||
</None>
|
||||
<None Include="docker-compose.aihit-syncher.yml" />
|
||||
<None Include="docker-compose.yml" />
|
||||
<None Include=".dockerignore" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
#version: '3.4'
|
||||
|
||||
#services:
|
||||
# parr.api:
|
||||
# environment:
|
||||
# - ASPNETCORE_ENVIRONMENT=Development
|
||||
# ports:
|
||||
# - "80"
|
||||
@@ -1,8 +1,18 @@
|
||||
#version: '3.4'
|
||||
version: '3.4'
|
||||
|
||||
#services:
|
||||
# parr.api:
|
||||
# image: ${DOCKER_REGISTRY-}parrapi
|
||||
# build:
|
||||
# context: .
|
||||
# dockerfile: PARR_API/Dockerfile
|
||||
#API
|
||||
services:
|
||||
rzdi-api:
|
||||
image: 10.99.253.167:8090/parr/parr-api:${tag:-latest}
|
||||
container_name: parr-api
|
||||
restart: always
|
||||
environment:
|
||||
- ASPNETCORE_ENVIRONMENT=Production
|
||||
- TZ=Europe/Moscow
|
||||
ports:
|
||||
- 8082:80
|
||||
volumes:
|
||||
- /var/log/parr-api:/app/log
|
||||
|
||||
|
||||
#tag=v1.0.0 docker compose up -d
|
||||
Reference in New Issue
Block a user