diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..fca25c8 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,81 @@ +kind: pipeline +type: docker +name: HeartTrack-Admin + +trigger: + event: + - push + +steps: + - name: build + image: mcr.microsoft.com/dotnet/sdk:7.0 + commands: + - cd Sources/HeartTrack/ + - dotnet restore HeartTrack.sln + - dotnet build HeartTrack.sln -c Release --no-restore + - dotnet publish HeartTrack.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release + + - name: tests + image: mcr.microsoft.com/dotnet/sdk:7.0 + commands: + - cd Sources/HeartTrack/ + - dotnet restore HeartTrack.sln + - dotnet test HeartTrack.sln --no-restore + depends_on: [build] + + - name: code-analysis + image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet8 + secrets: [ SECRET_SONAR_LOGIN ] + settings: + sonar_host: https://codefirst.iut.uca.fr/sonar/ + sonar_token: + from_secret: SECRET_SONAR_LOGIN + project_key: HeartTrack-API + coverage_exclusions: Tests/**, StubbedContextLib/**, StubAPI/** + duplication_exclusions: Tests/**, StubbedContextLib/** + commands: + - cd Sources/HeartTrack/ + - dotnet restore HeartTrack.sln + - dotnet sonarscanner begin /k:HeartTrack-API /d:sonar.host.url=$${PLUGIN_SONAR_HOST} /d:sonar.login=$${PLUGIN_SONAR_TOKEN} /d:sonar.coverage.exclusions="Tests/**, StubbedContextLib/**, StubAPI/**, HeartTrackAPI/Utils/**" /d:sonar.cpd.exclusions="Tests/**, StubbedContextLib/**, StubAPI/**" /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" + - dotnet build HeartTrack.sln -c Release --no-restore + - dotnet test HeartTrack.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" + - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" + - dotnet publish HeartTrack.sln -c Release --no-restore -o $CI_PROJECT_DIR/build/release + - dotnet sonarscanner end /d:sonar.login=$${PLUGIN_SONAR_TOKEN} + depends_on: [ tests ] + +--- + + +kind: pipeline +type: docker +name: HeartTrack-Admin-CD + +trigger: + event: + - push +steps: + + - name: docker-build-and-push + image: plugins/docker + settings: + dockerfile: Sources/HeartTrack/Dockerfile + context: Sources/HeartTrack/ + registry: hub.codefirst.iut.uca.fr + repo: hub.codefirst.iut.uca.fr/antoine.perederii/Admin + username: + from_secret: SECRET_REGISTRY_USERNAME + password: + from_secret: SECRET_REGISTRY_PASSWORD + + # database container stub + - name: deploy-container-stub + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest + environment: + CODEFIRST_CLIENTDRONE_ENV_TYPE: STUB + IMAGENAME: hub.codefirst.iut.uca.fr/antoine.perederii/Admin:latest + CONTAINERNAME: heart_stub + COMMAND: create + ADMINS: davidd_almeida,kevinmonteiro,antoineperederii,paullevrault,antoinepinagot,nicolasraymond,marcchevaldonne + OVERWRITE: true + depends_on: [ docker-build-and-push ] \ No newline at end of file diff --git a/Sources/HeartTrack/Dockerfile b/Sources/HeartTrack/Dockerfile new file mode 100644 index 0000000..ddc5f2d --- /dev/null +++ b/Sources/HeartTrack/Dockerfile @@ -0,0 +1,17 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +WORKDIR /Sources/HeartTrack +COPY . . + +WORKDIR /Sources/HeartTrack +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "HeartTrack.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +USER $APP_UID +WORKDIR /app + +COPY --from=build /app/publish . + +EXPOSE 8080 + +ENTRYPOINT ["dotnet", "HeartTrackAPI.dll"] \ No newline at end of file