From 23d1f6269d6769f66f4377eb46625d0da15611ef Mon Sep 17 00:00:00 2001 From: nkorporaal Date: Wed, 2 Oct 2024 14:06:38 +0200 Subject: [PATCH] chore(automation) : run in docker --- .docker/historie-data-service.yml | 8 +++--- scripts/containers-build.sh | 11 ++++++++ src/Historie.Data.Service/Dockerfile | 40 ++++++++++++++++++++++++++++ src/docker-compose.yml | 7 +++++ 4 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 scripts/containers-build.sh create mode 100644 src/Historie.Data.Service/Dockerfile create mode 100644 src/docker-compose.yml diff --git a/.docker/historie-data-service.yml b/.docker/historie-data-service.yml index 6f23785..e791394 100644 --- a/.docker/historie-data-service.yml +++ b/.docker/historie-data-service.yml @@ -3,22 +3,20 @@ version: '3.7' services: historie-data-service: container_name: historie-data-service - image: ghcr.io/brp-api/historie-data-service:2.0.4-latest + image: ghcr.io/brp-api/historie-data-service:latest environment: - - ASPNETCORE_URLS=http://+; - Database__Host=postgres - Database__Username=root - Database__Password=root - Database__Database=rvig_haalcentraal_testdata - HaalcentraalApi__MaxSearchResults=10 + - ASPNETCORE_URLS=http://+; - ProtocolleringAuthorization__UseAuthorizationChecks=false - ProtocolleringAuthorization__UseProtocollering=false - Ecs__Path=/var/log/historie-data-service.json - Ecs__SecuredPath=/var/log/historie-data-service-secured.json - Ecs__FileSizeLimitBytes=1073741824 - - Ecs__RetainedFileCountLimit=10 - - Serilog__MinimumLevel__Default=Warning - - Serilog__MinimumLevel__Override__Serilog=Information + # - Ecs__RetainedFileCountLimit=10 ports: - "8000:80" volumes: diff --git a/scripts/containers-build.sh b/scripts/containers-build.sh new file mode 100644 index 0000000..3d40a8b --- /dev/null +++ b/scripts/containers-build.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +MODE=$1 + +if [ "$MODE" = "ci" ]; then + # gebruik docker compose up -d om te forceren dat de container image wordt aangemaakt in de lokale registry + docker compose -f .docker/docker-compose-ci.yml up -d + docker compose -f .docker/docker-compose-ci.yml down +else + docker compose -f src/docker-compose.yml build +fi diff --git a/src/Historie.Data.Service/Dockerfile b/src/Historie.Data.Service/Dockerfile new file mode 100644 index 0000000..51021d4 --- /dev/null +++ b/src/Historie.Data.Service/Dockerfile @@ -0,0 +1,40 @@ +# See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +# This stage is used when running from VS in fast mode (Default for Debug configuration) +FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +WORKDIR /app + + +# This stage is used to build the service project +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["Historie.Data.Service/Historie.Data.Service.csproj", "Historie.Data.Service/"] +COPY ["Rvig.Base.App/Rvig.Base.App.csproj", "Rvig.Base.App/"] +COPY ["Brp.Shared.Infrastructure/Brp.Shared.Infrastructure.csproj", "Brp.Shared.Infrastructure/"] +COPY ["Serilog.Sinks.PersistentFile/Serilog.Sinks.PersistentFile.csproj", "Serilog.Sinks.PersistentFile/"] +COPY ["Rvig.Data.Base.WebApi/Rvig.Data.Base.WebApi.csproj", "Rvig.Data.Base.WebApi/"] +COPY ["Rvig.Data.Base/Rvig.Data.Base.csproj", "Rvig.Data.Base/"] +COPY ["Rvig.HaalCentraalApi.Shared/Rvig.HaalCentraalApi.Shared.csproj", "Rvig.HaalCentraalApi.Shared/"] +COPY ["Rvig.Data.Base.Postgres/Rvig.Data.Base.Postgres.csproj", "Rvig.Data.Base.Postgres/"] +COPY ["Rvig.Data.Historie/Rvig.Data.Historie.csproj", "Rvig.Data.Historieen/"] +COPY ["Rvig.HaalCentraalApi.Historie/Rvig.HaalCentraalApi.Historie.csproj", "Rvig.HaalCentraalApi.Historie/"] +RUN dotnet restore "./Historie.Data.Service/Historie.Data.Service.csproj" +COPY . . +WORKDIR "/src/Historie.Data.Service" +RUN dotnet build "./Historie.Data.Service.csproj" -c "$BUILD_CONFIGURATION" -o /app/build + +# 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 "./Historie.Data.Service.csproj" -c "$BUILD_CONFIGURATION" -o /app/publish /p:UseAppHost=false + +# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration) +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . + +# See https://github.com/Contrast-Security-OSS/agent-operator/blob/master/docs/public/08-tips.md +ENV DOTNET_HOSTBUILDER__RELOADCONFIGONCHANGE=false + +ENTRYPOINT ["dotnet", "Historie.Data.Service.dll"] \ No newline at end of file diff --git a/src/docker-compose.yml b/src/docker-compose.yml new file mode 100644 index 0000000..62ca5c2 --- /dev/null +++ b/src/docker-compose.yml @@ -0,0 +1,7 @@ +services: + historie-data-service: + image: ghcr.io/brp-api/historie-data-service:latest + build: + context: . + dockerfile: Historie.Data.Service/Dockerfile + \ No newline at end of file