diff --git a/.container/Dockerfile b/.container/Dockerfile index bdbb63d..4a2984e 100644 --- a/.container/Dockerfile +++ b/.container/Dockerfile @@ -1,34 +1,48 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env -ARG NUGET_TOKEN -ARG PROJECT_NAME +# The `platform` argument here is required, since dotnet-sdk crashes with segmentation fault +# in case of arm64 builds, see https://github.com/dotnet/dotnet-docker/issues/4225 for details +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env + +ARG INSTALL_DD_TRACER="true" +ARG TRACER_VERSION="2.49.0" +ARG TARGETARCH WORKDIR /app # Copy csproj and restore as distinct layers COPY src/*.csproj ./ -RUN dotnet nuget add source --username USERNAME --password $NUGET_TOKEN --store-password-in-clear-text --name github "https://nuget.pkg.github.com/SneaksAndData/index.json" -RUN dotnet restore +RUN dotnet_arch=$(test "$TARGETARCH" = "amd64" && echo "x64" || echo "$TARGETARCH") && \ + dotnet restore --runtime "linux-$dotnet_arch" # Copy everything else and build COPY src/. ./ -RUN dotnet publish "$PROJECT_NAME.csproj" -c Release -o out +RUN dotnet_arch=$(test "$TARGETARCH" = "amd64" && echo "x64" || echo "$TARGETARCH") && \ + dotnet publish "Arcane.Stream.Cdm.csproj" -c Release -o out --runtime "linux-$dotnet_arch" # Build runtime image -FROM mcr.microsoft.com/dotnet/aspnet:6.0-bullseye-slim -ARG TRACER_VERSION="2.32.0" -ARG PROJECT_NAME -ENV PROJECT_ASSEMBLY=$PROJECT_NAME +FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim + +ARG TRACER_VERSION="2.49.0" +ARG INSTALL_DD_TRACER="true" +ARG TARGETARCH RUN apt-get update -y && apt-get install -y curl jq # Download and install the Datadog Tracer -RUN mkdir -p /opt/datadog \ - && mkdir -p /var/log/datadog \ - && curl -LO https://github.com/DataDog/dd-trace-dotnet/releases/download/v${TRACER_VERSION}/datadog-dotnet-apm_${TRACER_VERSION}_amd64.deb \ - && dpkg -i ./datadog-dotnet-apm_${TRACER_VERSION}_amd64.deb \ - && rm ./datadog-dotnet-apm_${TRACER_VERSION}_amd64.deb +RUN if [ -z "$INSTALL_DD_TRACER" ]; then \ + echo "Datadog tracer installation skipped"; \ + else \ + mkdir -p /opt/datadog \ + && echo $TARGETARCH \ + && mkdir -p /var/log/datadog \ + && curl -LO https://github.com/DataDog/dd-trace-dotnet/releases/download/v${TRACER_VERSION}/datadog-dotnet-apm_${TRACER_VERSION}_${TARGETARCH}.deb \ + && dpkg -i ./datadog-dotnet-apm_${TRACER_VERSION}_${TARGETARCH}.deb \ + && rm ./datadog-dotnet-apm_${TRACER_VERSION}_${TARGETARCH}.deb ; \ + fi; WORKDIR /app COPY --from=build-env /app/out . -ENTRYPOINT "dotnet" "$PROJECT_ASSEMBLY.dll" + +USER app + +ENTRYPOINT "dotnet" "Arcane.Stream.Cdm.dll" diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index ab6576a..a985582 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -5,10 +5,9 @@ labels: - code/bug body: - type: textarea - id: description attributes: - label: Description - description: Briefly describe the problem you are having in a few paragraphs. + label: Description + description: Briefly describe the problem you are having in a few paragraphs. validations: required: true @@ -32,3 +31,5 @@ body: attributes: label: System information placeholder: Arcane version, OS, dotnet version etc. + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml index 8e3eee6..9e8fcf2 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yaml +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -32,3 +32,5 @@ body: description: | Additional context Add any other context or screenshots about the feature request here. + validations: + required: false diff --git a/.github/dependabot.yml b/.github/dependabot.yml index a4c88af..b72903e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,6 +4,7 @@ updates: directory: "src/" schedule: interval: "weekly" + day: "monday" - package-ecosystem: "github-actions" directory: "/" schedule: diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index e07a012..ccccc7f 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,4 +1,4 @@ -Fixes/Implements #. +Fixes/Resolves #. ## Scope @@ -15,4 +15,4 @@ Additional changes: - [ ] GitHub issue exists for this change. - [ ] Unit tests added and they pass. - [ ] Line Coverage is at least 80%. -- [ ] Review requested on `latest` commit. \ No newline at end of file +- [ ] Review requested on `latest` commit. diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 018f4ed..5364f1d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -5,30 +5,29 @@ on: branches: [ main ] pull_request: branches: [ main ] - + # ! Replace DotnetProject and dotnet-project with project name in real repository env: - PROJECT_NAME: DotnetProject - PROJECT_NAME_LOWER: dotnet-project - + PROJECT_NAME: Arcane.Stream.Cdm + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + + jobs: validate_commit: name: Validate commit runs-on: ubuntu-latest if: ${{ github.ref != 'refs/heads/main' }} permissions: - id-token: write # required for dependabot PRs - pull-requests: write # required for dependabot PRs - contents: read # required for dependabot PRs + pull-requests: write + contents: read steps: - uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v4.0.0 with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x - name: Restore dependencies - env: - NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }} run: dotnet restore - name: Build run: dotnet build --no-restore @@ -36,7 +35,7 @@ jobs: working-directory: ./test run: | dotnet add package coverlet.msbuild && - dotnet test ${PROJECT_NAME}Tests.csproj --configuration Debug --runtime linux-x64 /p:CollectCoverage=true /p:CoverletOutput=Coverage/ /p:CoverletOutputFormat=lcov --logger GitHubActions + dotnet test ${PROJECT_NAME}.Tests.csproj --configuration Debug --runtime linux-x64 /p:CollectCoverage=true /p:CoverletOutput=Coverage/ /p:CoverletOutputFormat=lcov --logger GitHubActions - name: Publish Code Coverage if: ${{ github.event_name == 'pull_request' && always() }} uses: romeovs/lcov-reporter-action@v0.4.0 @@ -48,9 +47,7 @@ jobs: name: Build Docker Image and Helm Charts runs-on: ubuntu-latest needs: [ validate_commit ] - # Remove the line below and uncomment the next one - if: ${{ false }} - # if: ${{ always() && (needs.validate_commit.result == 'success' || needs.validate_commit.result == 'skipped') }} + if: ${{ always() && (needs.validate_commit.result == 'success' || needs.validate_commit.result == 'skipped') }} permissions: contents: read packages: write @@ -100,7 +97,7 @@ jobs: - name: Build and Push Chart uses: SneaksAndData/github-actions/build_helm_chart@v0.1.8 with: - application: ${{ github.repository }} + application: arcane-stream-cdm-change-feed app_version: ${{ steps.meta.outputs.version }} container_registry_user: ${{ github.actor }} container_registry_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 7249b65..3f921fe 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -6,9 +6,7 @@ jobs: create_release: name: Create Release runs-on: ubuntu-latest - # Remove the line below and uncomment the next one - if: ${{ false }} - #if: ${{ github.ref == 'refs/heads/main' }} + if: ${{ github.ref == 'refs/heads/main' }} steps: - uses: actions/checkout@v4 diff --git a/.helm/Chart.yaml b/.helm/Chart.yaml index a6d5ea8..4a1135c 100644 --- a/.helm/Chart.yaml +++ b/.helm/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 -name: dotnet-project +name: arcane-stream-cdm-change-feed description: A Helm chart for Kubernetes # A chart can be either an 'application' or a 'library' chart. diff --git a/.helm/values.yaml b/.helm/values.yaml index e6b7a94..4b48e80 100644 --- a/.helm/values.yaml +++ b/.helm/values.yaml @@ -2,9 +2,23 @@ environment: "Development" replicaCount: 1 image: - repository: dotnet-project - # Overrides the image tag whose default is the chart appVersion. - tag: "v0.0.0" + # Repository to pull the image from + repository: "ghcr.io/sneaksanddata/arcane-stream-cdm-change-feed" + + # Tag to pull (defaults to the chart appVersion) + tag: "" + + # Image pull policy + pullPolicy: "IfNotPresent" + +# Image pull secrets for private repositories +imagePullSecrets: [] + +# Override the application name +nameOverride: "" + +# Fullname override +fullnameOverride: "" serviceAccount: # Specifies whether a service account should be created @@ -15,37 +29,125 @@ serviceAccount: # If not set and create is true, a name is generated using the fullname template name: "" -metrics: - statsd_host: "datadog-statsd.datadog.svc.cluster.local" - statsd_port: 8125 -logs: - datadogSite: "https://http-intake.logs.datadoghq.eu" - logLevel: "INFO" - -resources: - cpu: 100m - memory: 128Mi - -apm: - environment: - - name: CORECLR_ENABLE_PROFILING - value: "1" - - name: CORECLR_PROFILER - value: "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}" - - name: CORECLR_PROFILER_PATH - value: "/opt/datadog/Datadog.Trace.ClrProfiler.Native.so" - - name: DD_DOTNET_TRACER_HOME - value: "/opt/datadog" - - name: DD_INTEGRATIONS - value: "/opt/datadog/integrations.json" - - name: LD_PRELOAD - value: "/opt/datadog/continuousprofiler/Datadog.Linux.ApiWrapper.x64.so" - -nodes: - taint: "kubernetes.sneaksanddata.com/servicenodetype" - taintValue: "dotnet-project" - -secretStorage: - address: "https://hashicorp-vault.production.sneaksanddata.com" - roleName: "application" - deploymentClusterName: "" +# CRD configuration +customResourceDefinitions: + + # Set to true to create CRDs for this operator + # Otherwise, the operator will expect the CRDs to be pre-installed + create: true + + rbac: + # Specifies whether RBAC resources should be created + clusterRole: + # This parameter determines whether role binding resources need to be created. + # If you have any roles in your configuration set to 'true', then this parameter for creating role binding resources + # should also be set to 'true'. + clusterRoleBindings: + additionalLabels: { } + additionalAnnotations: { } + create: false + +# Additional labels for the stream classes +additionalLabels: {} +# Example: +# +# app.my-company.com/name: arcane-stream +# app.my-company.com/component: streaming + +# Additional labels for the stream classes +additionalAnnotations: {} +# Example: +# +# app.my-company.com/name: arcane-stream +# app.my-company.com/source: restapi +# app.my-company.com/application: arcane + +jobTemplateSettings: + create: true + + # Job backoff limit + backoffLimit: 3 + + # Additional labels for the streaming jobs and pods + additionalLabels: {} + # Example: + # + # app.my-company.com/name: arcane-stream + # app.my-company.com/component: streaming + + # Additional labels for the streaming jobs and pods + additionalAnnotations: {} + # Example: + # + # app.my-company.com/name: arcane-stream + # app.my-company.com/source: restapi + # app.my-company.com/application: arcane + + # Extra environment variables to set in the the streaming job + extraEnv: [] + # Example: + # + # - name: ASPNETCORE_ENVIRONMENT + # value: production + + # Extra environment variables referencing a ConfigMap or Secret + extraEnvFrom: [] + # Example: + # + # envFrom: + # - configMapRef: + # name: custom-api-access-token + + # Extra volumes to add to the streaming job + extraVolumes: [] + # Example: + # + # - name: data-volume + # emptyDir: + # sizeLimit: 500Mi + + # Extra volumes to add to the streaming job + extraVolumeMounts: [] + # Example: + # + # - mountPath: /data + # name: data-volume + + # Resources constraints. By default, the operator does not specify any constraints to allow for easier deployment + resources: {} + # Example: + # + # requests: + # cpu: 1 + # memory: 1Gi + # limits: + # cpu: 1 + # memory: 1Gi + + # Node labels for pod assignment + tolerations: [] + + # Node labels for pod assignment + affinity: {} + + # Security context settings for the container + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + readOnlyRootFilesystem: true + runAsNonRoot: true + runAsUser: 1000 + seccompProfile: + type: RuntimeDefault + + + # Allows to specify a custom settings for pod failure policy + podFailurePolicySettings: + + # Specifies the list of exit codes that should trigger a retry without incrementing the retry count + retryOnExitCodes: + # The stream container completes with this exit code when a retryable error occurs + # Like rate by the server limiting, transient connection errors etc. + - 2 diff --git a/DotnetProject.sln b/Arcane.Stream.Cdm.sln similarity index 76% rename from DotnetProject.sln rename to Arcane.Stream.Cdm.sln index 9e3e7a8..5aee082 100644 --- a/DotnetProject.sln +++ b/Arcane.Stream.Cdm.sln @@ -1,8 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotnetProject", "src\DotnetProject.csproj", "{67711D50-E64C-4A18-871B-DC6A485DD9E4}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Arcane.Stream.Cdm", "src\Arcane.Stream.Cdm.csproj", "{67711D50-E64C-4A18-871B-DC6A485DD9E4}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotnetProjectTests", "test\DotnetProjectTests.csproj", "{B74A1EEE-CC43-4FFF-A6AB-129387D32F40}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Arcane.Stream.Cdm.Tests", "test\Arcane.Stream.Cdm.Tests.csproj", "{B74A1EEE-CC43-4FFF-A6AB-129387D32F40}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/DotnetProject.csproj b/src/Arcane.Stream.Cdm.csproj similarity index 68% rename from src/DotnetProject.csproj rename to src/Arcane.Stream.Cdm.csproj index 70d34a0..ddeaa98 100644 --- a/src/DotnetProject.csproj +++ b/src/Arcane.Stream.Cdm.csproj @@ -2,7 +2,8 @@ Exe - net6.0 + net8.0 + DotnetProject diff --git a/test/DotnetProjectTests.csproj b/test/Arcane.Stream.Cdm.Tests.csproj similarity index 85% rename from test/DotnetProjectTests.csproj rename to test/Arcane.Stream.Cdm.Tests.csproj index 764ee4d..fe029b0 100644 --- a/test/DotnetProjectTests.csproj +++ b/test/Arcane.Stream.Cdm.Tests.csproj @@ -1,11 +1,11 @@ - net6.0 + net8.0 false - DotnetProject.Tests + Arcane.Stream.Cdm.Tests @@ -26,7 +26,7 @@ - +