Skip to content

Commit

Permalink
Init Repo (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
adelinag08 authored Jun 19, 2024
1 parent a6ccd77 commit 5ec6f9f
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 83 deletions.
46 changes: 30 additions & 16 deletions .container/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 4 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -32,3 +31,5 @@ body:
attributes:
label: System information
placeholder: Arcane version, OS, dotnet version etc.
validations:
required: true
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ body:
description: |
Additional context
Add any other context or screenshots about the feature request here.
validations:
required: false
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ updates:
directory: "src/"
schedule:
interval: "weekly"
day: "monday"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand Down
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Fixes/Implements #<issue number>.
Fixes/Resolves #<issue number>.

## Scope

Expand All @@ -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.
- [ ] Review requested on `latest` commit.
27 changes: 12 additions & 15 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,37 @@ 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/[email protected]
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
- name: Test
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/[email protected]
Expand All @@ -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
Expand Down Expand Up @@ -100,7 +97,7 @@ jobs:
- name: Build and Push Chart
uses: SneaksAndData/github-actions/[email protected]
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 }}
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
176 changes: 139 additions & 37 deletions .helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: "<name of the the kubernetes cluster where the application is deployed>"
# 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
4 changes: 2 additions & 2 deletions DotnetProject.sln → Arcane.Stream.Cdm.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading

0 comments on commit 5ec6f9f

Please sign in to comment.