Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions .github/workflows/docker-build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ name: Container Image
on:
workflow_dispatch:
workflow_run:
branches: [ "main" ]
branches: [ "main", "**" ]
workflows: ["Sync Service Build and Release"]
types:
- completed
push:
branches:
- main
paths:
# - 'Kepware.Api/**'
- 'KepwareSync.Service/**'
# - '.github/workflows/docker-build-and-push.yml'
- '!**/*.md' # Exclude markdown files
# push:
# branches:
# - main
# paths:
# - 'Kepware.Api/**'
# - 'KepwareSync.Service/**'
# - '.github/workflows/docker-build-and-push.yml'
# - '!**/*.md' Exclude markdown files

jobs:
build:
Expand Down Expand Up @@ -50,7 +50,16 @@ jobs:
id: lowercase
run: echo "REPO_OWNER_LOWER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

- name: Build and export to Docker
uses: docker/build-push-action@v6
with:
load: true
tags: kepware-sync-service:test
- name: Test
run: |
docker run --rm kepware-sync-service:test
- name: Build and push Docker image
if: ${{ github.event_name != 'pull_request'}}
id: docker_build
uses: docker/build-push-action@v4
with:
Expand Down
26 changes: 13 additions & 13 deletions KepwareSync.Service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Unter https://aka.ms/customizecontainer erfahren Sie, wie Sie Ihren Debugcontainer anpassen und wie Visual Studio dieses Dockerfile verwendet, um Ihre Images für ein schnelleres Debuggen zu erstellen.
# Learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging at https://aka.ms/customizecontainer

# Diese ARGs ermöglichen den Austausch der Basis, die zum Erstellen des endgültigen Images beim Debuggen von VS verwendet wird.
# These ARGs allow switching the base used to create the final image when debugging from VS.
ARG LAUNCHING_FROM_VS
# Hiermit wird das Basisimage für "final" festgelegt, jedoch nur, wenn LAUNCHING_FROM_VS definiert wurde.
# This sets the base image for 'final', but only if LAUNCHING_FROM_VS is defined.
ARG FINAL_BASE_IMAGE=${LAUNCHING_FROM_VS:+aotdebug}

# Diese Stufe wird verwendet, wenn sie von VS im Schnellmodus ausgeführt wird (Standardeinstellung für Debugkonfiguration).
FROM mcr.microsoft.com/dotnet/runtime:9.0 AS base
# This stage is used when running from VS in Fast mode (Default for Debug configuration).
FROM mcr.microsoft.com/dotnet/runtime:10.0 AS base
USER $APP_UID
WORKDIR /app


# Diese Stufe wird zum Erstellen des Dienstprojekts verwendet.
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
# Installieren Sie clang/zlib1g-dev-Abhängigkeiten für die Veröffentlichung unter nativ
# This stage is used to build the service project.
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
# Install clang/zlib1g-dev dependencies for native AOT publishing
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
clang zlib1g-dev
Expand All @@ -27,22 +27,22 @@ COPY . .
WORKDIR "/src/KepwareSync.Service"
RUN dotnet build "./Kepware.SyncService.csproj" -c $BUILD_CONFIGURATION -o /app/build

# Diese Stufe wird verwendet, um das Dienstprojekt zu veröffentlichen, das in die letzte Phase kopiert werden soll.
# This stage is used to publish the service project to be copied to the final stage.
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Kepware.SyncService.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=true

# Diese Stufe wird als Basis für die letzte Stufe verwendet, wenn sie von VS gestartet wird, um das Debuggen im regulären Modus zu unterstützen (Standardwert, wenn die Debugkonfiguration nicht verwendet wird).
# This stage is used as the base for the final stage when launched from VS to support debugging in regular mode (Default when not using Debug configuration).
FROM base AS aotdebug
USER root
# Installieren Sie GDB, um natives Debuggen zu unterstützen.
# Install GDB to support native debugging.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
gdb
USER app

# Diese Stufe wird in der Produktion oder bei Ausführung von VS im regulären Modus verwendet (Standard, wenn die Debugkonfiguration nicht verwendet wird).
FROM ${FINAL_BASE_IMAGE:-mcr.microsoft.com/dotnet/runtime-deps:9.0} AS final
# This stage is used in production or when running from VS in regular mode (Default when not using Debug configuration).
FROM ${FINAL_BASE_IMAGE:-mcr.microsoft.com/dotnet/runtime-deps:10.0} AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["./Kepware.SyncService"]
4 changes: 2 additions & 2 deletions KepwareSync.Service/Kepware.SyncService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>Kepware-SyncService-26c7b057-7b28-4930-aade-96e5e6829984</UserSecretsId>
<Nullable>enable</Nullable>
Expand Down Expand Up @@ -31,7 +31,7 @@
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.3" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="10.0.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.3" />
<PackageReference Include="Polly" Version="8.5.1" />
<PackageReference Include="Serilog" Version="4.2.0" />
Expand Down