Skip to content

Commit 87bd4e8

Browse files
authored
Merge pull request #2 from digma-ai/feature/ci-cd
Added docker file and github workflows
2 parents 1cd5b73 + 4484d3a commit 87bd4e8

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed

.github/workflows/build.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
paths-ignore:
9+
- README.md
10+
11+
env:
12+
DOTNET_VERSION: '9.0.x'
13+
14+
defaults:
15+
run:
16+
working-directory: ./src/DigmaSSEServer
17+
18+
jobs:
19+
build-and-test:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Setup .NET
25+
uses: actions/setup-dotnet@v4
26+
with:
27+
dotnet-version: ${{ env.DOTNET_VERSION }}
28+
29+
- name: Cache NuGet
30+
uses: actions/cache@v4
31+
with:
32+
path: ~/.nuget/packages
33+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
34+
restore-keys: |
35+
${{ runner.os }}-nuget-
36+
37+
- run: dotnet restore
38+
- run: dotnet build --no-restore --configuration Release
39+
- run: dotnet test --no-build --configuration Release --verbosity normal

.github/workflows/publish.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [released, prereleased]
6+
7+
permissions:
8+
packages: write
9+
contents: read
10+
11+
jobs:
12+
build-and-push:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Docker Buildx
19+
uses: docker/setup-buildx-action@v3
20+
21+
- name: Login to Docker Hub
22+
uses: docker/login-action@v3
23+
with:
24+
username: ${{ secrets.DOCKERHUB_USERNAME }}
25+
password: ${{ secrets.DOCKERHUB_TOKEN }}
26+
27+
- name: Extract Docker metadata
28+
id: meta
29+
uses: docker/metadata-action@v5
30+
with:
31+
images: digmatic/digma-sse-server
32+
tags: |
33+
type=semver,pattern={{version}}
34+
type=raw,value=preview,enable=${{ github.event.release.prerelease }}
35+
type=raw,value=latest,enable=${{ !github.event.release.prerelease }}
36+
37+
- name: Build and push Docker image
38+
uses: docker/build-push-action@v5
39+
with:
40+
context: .
41+
file: ./src/DigmaSSEServer/Dockerfile
42+
push: true
43+
tags: ${{ steps.meta.outputs.tags }}
44+
labels: ${{ steps.meta.outputs.labels }}

src/DigmaSSEServer/Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
2+
WORKDIR /app
3+
EXPOSE 80
4+
EXPOSE 443
5+
6+
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
7+
WORKDIR /src
8+
COPY ["src/DigmaSSEServer/DigmaSSEServer.csproj", "./"]
9+
RUN dotnet restore "DigmaSSEServer.csproj"
10+
COPY src/DigmaSSEServer/. ./
11+
RUN dotnet build "DigmaSSEServer.csproj" -c Release -o /app/build /p:UseAppHost=false
12+
13+
FROM build AS publish
14+
RUN dotnet publish "DigmaSSEServer.csproj" -c Release -o /app/publish /p:UseAppHost=false
15+
16+
FROM base AS final
17+
WORKDIR /app
18+
COPY --from=publish /app/publish .
19+
ENV ASPNETCORE_URLS=http://+:80
20+
ENV ASPNETCORE_ENVIRONMENT=Production
21+
ENTRYPOINT ["dotnet", "DigmaSSEServer.dll"]

0 commit comments

Comments
 (0)