From 494081950cee292a954a505d2aa0a0624bc9c721 Mon Sep 17 00:00:00 2001 From: Dominic Burger Date: Mon, 19 Aug 2024 09:34:02 +0200 Subject: [PATCH 01/10] Update to .NET 8 --- .github/workflows/ci.yml | 2 +- .vscode/launch.json | 2 +- Directory.Build.props | 2 +- src/ILICheck.Web/ILICheck.Web.csproj | 8 ++++---- tests/ILICheck.Web.Test/ILICheck.Web.Test.csproj | 6 ++---- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bae89f2..fbb5678 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v3 with: - dotnet-version: '7.0' + dotnet-version: '8.0' # Run the npm ci command before building # the dotnet project, because the project diff --git a/.vscode/launch.json b/.vscode/launch.json index bd7babc..32b23a2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -6,7 +6,7 @@ "type": "coreclr", "request": "launch", "preLaunchTask": "build", - "program": "${workspaceFolder}/src/ILICheck.Web/bin/Debug/net7.0/ILICheck.Web.dll", + "program": "${workspaceFolder}/src/ILICheck.Web/bin/Debug/net8.0/ILICheck.Web.dll", "args": [], "cwd": "${workspaceFolder}/src/ILICheck.Web", "stopAtEntry": false, diff --git a/Directory.Build.props b/Directory.Build.props index 16b6f88..4e0e4d0 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -10,7 +10,7 @@ https://github.com/GeoWerkstatt/interlis-check-service https://github.com/GeoWerkstatt/interlis-check-service.git git - 7.0-recommended + 8.0-recommended diff --git a/src/ILICheck.Web/ILICheck.Web.csproj b/src/ILICheck.Web/ILICheck.Web.csproj index 44ca2c4..be58d57 100644 --- a/src/ILICheck.Web/ILICheck.Web.csproj +++ b/src/ILICheck.Web/ILICheck.Web.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 true true Latest @@ -13,9 +13,9 @@ - - - + + + diff --git a/tests/ILICheck.Web.Test/ILICheck.Web.Test.csproj b/tests/ILICheck.Web.Test/ILICheck.Web.Test.csproj index 9614a56..bafd004 100644 --- a/tests/ILICheck.Web.Test/ILICheck.Web.Test.csproj +++ b/tests/ILICheck.Web.Test/ILICheck.Web.Test.csproj @@ -1,13 +1,11 @@ - net7.0 - + net8.0 false - ILICheck.Web.Test - ILICheck.Web + CA1861 From 9119cbf6530baedd92845bfff60fdc32a91446c7 Mon Sep 17 00:00:00 2001 From: Dominic Burger Date: Mon, 19 Aug 2024 09:38:20 +0200 Subject: [PATCH 02/10] Fix code analysis warnings of .NET 8 --- .../Controllers/DownloadController.cs | 6 +++--- .../Controllers/SettingsController.cs | 2 +- .../Controllers/StatusController.cs | 6 +++--- .../Controllers/UploadController.cs | 4 ++-- .../Exceptions/GeoPackageException.cs | 10 ---------- .../Exceptions/InvalidXmlException.cs | 10 ---------- .../MultipleTransferFileFoundException.cs | 20 ------------------- .../TransferFileNotFoundException.cs | 10 ---------- .../Exceptions/UnknownExtensionException.cs | 20 ------------------- .../Exceptions/ValidationFailedException.cs | 10 ---------- src/ILICheck.Web/Extensions.cs | 8 ++++---- src/ILICheck.Web/Startup.cs | 5 +++-- src/ILICheck.Web/Validator.cs | 6 +++--- 13 files changed, 19 insertions(+), 98 deletions(-) diff --git a/src/ILICheck.Web/Controllers/DownloadController.cs b/src/ILICheck.Web/Controllers/DownloadController.cs index 8f2dbdc..aee0149 100644 --- a/src/ILICheck.Web/Controllers/DownloadController.cs +++ b/src/ILICheck.Web/Controllers/DownloadController.cs @@ -32,7 +32,7 @@ public DownloadController(ILogger logger, IFileProvider file /// The ilivalidator log file. [HttpGet] [SwaggerResponse(StatusCodes.Status200OK, "Returns the ilivalidator log file.", ContentTypes = new[] { "text/xml; charset=utf-8", "application/geo+json" })] - [SwaggerResponse(StatusCodes.Status400BadRequest, "The server cannot process the request due to invalid or malformed request.", typeof(ProblemDetails), new[] { "application/json" })] + [SwaggerResponse(StatusCodes.Status400BadRequest, "The server cannot process the request due to invalid or malformed request.", typeof(ProblemDetails), "application/json")] [SwaggerResponse(StatusCodes.Status404NotFound, "The log file for the requested jobId cannot be found.", ContentTypes = new[] { "application/json" })] public IActionResult Download(Guid jobId, LogType logType) { @@ -63,8 +63,8 @@ public IActionResult Download(Guid jobId, LogType logType) /// The job identifier. /// The log data for the specified . [HttpGet("json")] - [SwaggerResponse(StatusCodes.Status200OK, "Returns the ilivalidator log data in JSON format.", typeof(IEnumerable), new[] { "application/json" })] - [SwaggerResponse(StatusCodes.Status400BadRequest, "The server cannot process the request due to invalid or malformed request.", typeof(ValidationProblemDetails), new[] { "application/json" })] + [SwaggerResponse(StatusCodes.Status200OK, "Returns the ilivalidator log data in JSON format.", typeof(IEnumerable), "application/json")] + [SwaggerResponse(StatusCodes.Status400BadRequest, "The server cannot process the request due to invalid or malformed request.", typeof(ValidationProblemDetails), "application/json")] [SwaggerResponse(StatusCodes.Status404NotFound, "The log file for the requested jobId cannot be found.", ContentTypes = new[] { "application/json" })] public IActionResult GetJsonLog(Guid jobId) { diff --git a/src/ILICheck.Web/Controllers/SettingsController.cs b/src/ILICheck.Web/Controllers/SettingsController.cs index 19fa176..52dff01 100644 --- a/src/ILICheck.Web/Controllers/SettingsController.cs +++ b/src/ILICheck.Web/Controllers/SettingsController.cs @@ -25,7 +25,7 @@ public SettingsController(ILogger logger, IConfiguration con /// /// JSON-formatted client application settings. [HttpGet] - [SwaggerResponse(StatusCodes.Status200OK, "The the application settings which can be used to configure a client.", typeof(SettingsResponse), new[] { "application/json" })] + [SwaggerResponse(StatusCodes.Status200OK, "The the application settings which can be used to configure a client.", typeof(SettingsResponse), "application/json")] public IActionResult GetSettings() { logger.LogTrace("Application configuration requested."); diff --git a/src/ILICheck.Web/Controllers/StatusController.cs b/src/ILICheck.Web/Controllers/StatusController.cs index 6955c93..81208f9 100644 --- a/src/ILICheck.Web/Controllers/StatusController.cs +++ b/src/ILICheck.Web/Controllers/StatusController.cs @@ -30,9 +30,9 @@ public StatusController(ILogger logger, IValidatorService vali /// The job identifier. /// The status information for the specified . [HttpGet("{jobId}")] - [SwaggerResponse(StatusCodes.Status200OK, "The job with the specified jobId was found.", typeof(StatusResponse), new[] { "application/json" })] - [SwaggerResponse(StatusCodes.Status400BadRequest, "The server cannot process the request due to invalid or malformed request.", typeof(ValidationProblemDetails), new[] { "application/json" })] - [SwaggerResponse(StatusCodes.Status404NotFound, "The job with the specified jobId cannot be found.", typeof(ProblemDetails), new[] { "application/json" })] + [SwaggerResponse(StatusCodes.Status200OK, "The job with the specified jobId was found.", typeof(StatusResponse), "application/json")] + [SwaggerResponse(StatusCodes.Status400BadRequest, "The server cannot process the request due to invalid or malformed request.", typeof(ValidationProblemDetails), "application/json")] + [SwaggerResponse(StatusCodes.Status404NotFound, "The job with the specified jobId cannot be found.", typeof(ProblemDetails), "application/json")] public IActionResult GetStatus(ApiVersion version, Guid jobId) { logger.LogTrace("Status for job <{JobId}> requested.", jobId); diff --git a/src/ILICheck.Web/Controllers/UploadController.cs b/src/ILICheck.Web/Controllers/UploadController.cs index 7c6b94b..7f3f947 100644 --- a/src/ILICheck.Web/Controllers/UploadController.cs +++ b/src/ILICheck.Web/Controllers/UploadController.cs @@ -75,8 +75,8 @@ public UploadController(ILogger logger, IConfiguration configu /// /// Information for a newly created validation job. [HttpPost] - [SwaggerResponse(StatusCodes.Status201Created, "The validation job was successfully created and is now scheduled for execution.", typeof(UploadResponse), new[] { "application/json" })] - [SwaggerResponse(StatusCodes.Status400BadRequest, "The server cannot process the request due to invalid or malformed request.", typeof(ProblemDetails), new[] { "application/json" })] + [SwaggerResponse(StatusCodes.Status201Created, "The validation job was successfully created and is now scheduled for execution.", typeof(UploadResponse), "application/json")] + [SwaggerResponse(StatusCodes.Status400BadRequest, "The server cannot process the request due to invalid or malformed request.", typeof(ProblemDetails), "application/json")] [SwaggerResponse(StatusCodes.Status413PayloadTooLarge, "The transfer file is too large. Max allowed request body size is 200 MB.")] [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1629:DocumentationTextMustEndWithAPeriod", Justification = "Not applicable for code examples.")] [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1028:CodeMustNotContainTrailingWhitespace", Justification = "Not applicable for code examples.")] diff --git a/src/ILICheck.Web/Exceptions/GeoPackageException.cs b/src/ILICheck.Web/Exceptions/GeoPackageException.cs index 34fd003..b888b1f 100644 --- a/src/ILICheck.Web/Exceptions/GeoPackageException.cs +++ b/src/ILICheck.Web/Exceptions/GeoPackageException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; namespace ILICheck.Web { @@ -37,14 +36,5 @@ public GeoPackageException(string message, Exception innerException) : base(message, innerException) { } - - /// - /// Initializes a new instance of the class - /// with serialized data. - /// - protected GeoPackageException(SerializationInfo info, StreamingContext streamingContext) - : base(info, streamingContext) - { - } } } diff --git a/src/ILICheck.Web/Exceptions/InvalidXmlException.cs b/src/ILICheck.Web/Exceptions/InvalidXmlException.cs index 4e6384f..9e4f62c 100644 --- a/src/ILICheck.Web/Exceptions/InvalidXmlException.cs +++ b/src/ILICheck.Web/Exceptions/InvalidXmlException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; namespace ILICheck.Web { @@ -37,14 +36,5 @@ public InvalidXmlException(string message, Exception innerException) : base(message, innerException) { } - - /// - /// Initializes a new instance of the class - /// with serialized data. - /// - protected InvalidXmlException(SerializationInfo info, StreamingContext streamingContext) - : base(info, streamingContext) - { - } } } diff --git a/src/ILICheck.Web/Exceptions/MultipleTransferFileFoundException.cs b/src/ILICheck.Web/Exceptions/MultipleTransferFileFoundException.cs index d0fc5e3..2f53ce6 100644 --- a/src/ILICheck.Web/Exceptions/MultipleTransferFileFoundException.cs +++ b/src/ILICheck.Web/Exceptions/MultipleTransferFileFoundException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; namespace ILICheck.Web { @@ -46,24 +45,5 @@ public MultipleTransferFileFoundException(string fileExtension, string message, { FileExtension = fileExtension; } - - /// - /// Initializes a new instance of the class - /// with serialized data. - /// - protected MultipleTransferFileFoundException(SerializationInfo info, StreamingContext streamingContext) - : base(info, streamingContext) - { - FileExtension = info.GetString(nameof(FileExtension)); - } - - /// - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - if (info == null) throw new ArgumentNullException(nameof(info)); - - info.AddValue(nameof(FileExtension), FileExtension); - base.GetObjectData(info, context); - } } } diff --git a/src/ILICheck.Web/Exceptions/TransferFileNotFoundException.cs b/src/ILICheck.Web/Exceptions/TransferFileNotFoundException.cs index 9291fff..7c3a83b 100644 --- a/src/ILICheck.Web/Exceptions/TransferFileNotFoundException.cs +++ b/src/ILICheck.Web/Exceptions/TransferFileNotFoundException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; namespace ILICheck.Web { @@ -37,14 +36,5 @@ public TransferFileNotFoundException(string message, Exception innerException) : base(message, innerException) { } - - /// - /// Initializes a new instance of the class - /// with serialized data. - /// - protected TransferFileNotFoundException(SerializationInfo info, StreamingContext streamingContext) - : base(info, streamingContext) - { - } } } diff --git a/src/ILICheck.Web/Exceptions/UnknownExtensionException.cs b/src/ILICheck.Web/Exceptions/UnknownExtensionException.cs index 397d009..a1e26fc 100644 --- a/src/ILICheck.Web/Exceptions/UnknownExtensionException.cs +++ b/src/ILICheck.Web/Exceptions/UnknownExtensionException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; namespace ILICheck.Web { @@ -46,24 +45,5 @@ public UnknownExtensionException(string fileExtension, string message, Exception { FileExtension = fileExtension; } - - /// - /// Initializes a new instance of the class - /// with serialized data. - /// - protected UnknownExtensionException(SerializationInfo info, StreamingContext streamingContext) - : base(info, streamingContext) - { - FileExtension = info.GetString(nameof(FileExtension)); - } - - /// - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - if (info == null) throw new ArgumentNullException(nameof(info)); - - info.AddValue(nameof(FileExtension), FileExtension); - base.GetObjectData(info, context); - } } } diff --git a/src/ILICheck.Web/Exceptions/ValidationFailedException.cs b/src/ILICheck.Web/Exceptions/ValidationFailedException.cs index 9bb0d07..9efd271 100644 --- a/src/ILICheck.Web/Exceptions/ValidationFailedException.cs +++ b/src/ILICheck.Web/Exceptions/ValidationFailedException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; namespace ILICheck.Web { @@ -37,14 +36,5 @@ public ValidationFailedException(string message, Exception innerException) : base(message, innerException) { } - - /// - /// Initializes a new instance of the class - /// with serialized data. - /// - protected ValidationFailedException(SerializationInfo info, StreamingContext streamingContext) - : base(info, streamingContext) - { - } } } diff --git a/src/ILICheck.Web/Extensions.cs b/src/ILICheck.Web/Extensions.cs index c5044b5..3c0b27b 100644 --- a/src/ILICheck.Web/Extensions.cs +++ b/src/ILICheck.Web/Extensions.cs @@ -30,7 +30,7 @@ public static class Extensions /// If is null or empty. public static string JoinNonEmpty(this IEnumerable values, string separator) { - if (values == null) throw new ArgumentNullException(nameof(values)); + ArgumentNullException.ThrowIfNull(values); if (string.IsNullOrEmpty(separator)) throw new InvalidOperationException($"Null or empty {nameof(separator)} value is not allowed."); return string.Join(separator, values.Where(x => !string.IsNullOrWhiteSpace(x))); @@ -81,7 +81,7 @@ public static IEnumerable CleanupGpkgModelNames(this IEnumerable /// If multiple transfer files were found in . public static string GetTransferFileExtension(this IEnumerable extensions, IConfiguration configuration) { - if (extensions == null) throw new ArgumentNullException(nameof(extensions)); + ArgumentNullException.ThrowIfNull(extensions); // Check for unknown transfer file extensions foreach (var extension in extensions) @@ -130,7 +130,7 @@ public static string GetTransferFileExtension(this IEnumerable extension /// The transfer file name. public static IEnumerable GetFilesToDelete(this IEnumerable fileNames, IConfiguration configuration, string transferFile) { - if (fileNames == null) throw new ArgumentNullException(nameof(fileNames)); + ArgumentNullException.ThrowIfNull(fileNames); if (configuration.GetValue("DELETE_TRANSFER_FILES")) { @@ -183,7 +183,7 @@ public static string GetSanitizedFileExtension(this string unsafeFileName, IEnum /// If the log file could not be found. public static string GetLogFile(this IFileProvider fileProvider, LogType logType) { - if (fileProvider == null) throw new ArgumentNullException(nameof(fileProvider)); + ArgumentNullException.ThrowIfNull(fileProvider); try { diff --git a/src/ILICheck.Web/Startup.cs b/src/ILICheck.Web/Startup.cs index 5fbfad9..3bf9ae2 100644 --- a/src/ILICheck.Web/Startup.cs +++ b/src/ILICheck.Web/Startup.cs @@ -38,6 +38,8 @@ public Startup(IConfiguration configuration) public string ApplicationName => Configuration.GetValue("CUSTOM_APP_NAME") ?? "INTERLIS Web-Check-Service"; + private static readonly string[] swaggerCustomOrder = new[] { "Upload", "Status", "Download", "Settings" }; + // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { @@ -95,9 +97,8 @@ public void ConfigureServices(IServiceCollection services) // Custom order in Swagger UI. options.OrderActionsBy(apiDescription => { - var customOrder = new[] { "Upload", "Status", "Download", "Settings" }; var controllerName = (apiDescription.ActionDescriptor as ControllerActionDescriptor)?.ControllerName; - return $"{Array.IndexOf(customOrder, controllerName)}"; + return $"{Array.IndexOf(swaggerCustomOrder, controllerName)}"; }); options.EnableAnnotations(); diff --git a/src/ILICheck.Web/Validator.cs b/src/ILICheck.Web/Validator.cs index 455e250..3231c64 100644 --- a/src/ILICheck.Web/Validator.cs +++ b/src/ILICheck.Web/Validator.cs @@ -56,7 +56,7 @@ public Validator(ILogger logger, IConfiguration configuration, IFileP /// public async Task ExecuteAsync(string transferFile, CancellationToken cancellationToken) { - if (transferFile == null) throw new ArgumentNullException(nameof(transferFile)); + ArgumentNullException.ThrowIfNull(transferFile); if (string.IsNullOrWhiteSpace(transferFile)) throw new ArgumentException("Transfer file name cannot be empty.", nameof(transferFile)); if (!fileProvider.Exists(transferFile)) throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Transfer file with the specified name <{0}> not found in <{1}>.", transferFile, fileProvider.HomeDirectory)); @@ -135,7 +135,7 @@ await Task.Run(() => /// If is not found. public async Task ValidateXmlAsync() { - if (TransferFile == null) throw new ArgumentNullException(nameof(TransferFile)); + ArgumentNullException.ThrowIfNull(TransferFile); if (string.IsNullOrWhiteSpace(TransferFile)) throw new ArgumentException("Transfer file name cannot be empty.", nameof(TransferFile)); logger.LogInformation("Validating xml structure for transfer file <{TransferFile}>", TransferFile); @@ -170,7 +170,7 @@ public async Task ValidateXmlAsync() /// If is not found. internal async Task ReadGpkgModelNamesAsync() { - if (TransferFile == null) throw new ArgumentNullException(nameof(TransferFile)); + ArgumentNullException.ThrowIfNull(TransferFile); if (string.IsNullOrWhiteSpace(TransferFile)) throw new ArgumentException("Transfer file name cannot be empty.", nameof(TransferFile)); logger.LogInformation("Reading model names from GeoPackage <{TransferFile}>", TransferFile); From 447e4b83832ffc3e6fdcdb5c6d0d2682de14339c Mon Sep 17 00:00:00 2001 From: Dominic Burger Date: Tue, 20 Aug 2024 11:50:46 +0200 Subject: [PATCH 03/10] Update Dockerfile to .NET 8 Uses port 8080 and runs ilicheck as app user. --- Dockerfile | 17 ++++------- README.md | 24 ++++----------- docker-compose.yml | 22 ++++---------- docker-entrypoint.sh | 30 ++++++++----------- ilivalidator-wrapper.sh | 3 -- src/ILICheck.Web/appsettings.Development.json | 2 +- 6 files changed, 30 insertions(+), 68 deletions(-) diff --git a/Dockerfile b/Dockerfile index caa41f1..bfb1c11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /src ARG VERSION ARG REVISION @@ -38,7 +38,7 @@ RUN npx license-checker --json --production \ --customPath licenseCustomFormat.json \ --out ${PUBLISH_DIR}/ClientApp/build/license.json -FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS final +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final ARG VERSION ARG REVISION ENV HOME=/app @@ -62,13 +62,11 @@ RUN \ DEBIAN_FRONTEND=noninteractive && \ mkdir -p /usr/share/man/man1 /usr/share/man/man2 && \ apt-get update && \ - apt-get install -y curl unzip default-jre-headless sudo vim htop cron libcap2-bin && \ + apt-get install -y curl unzip default-jre-headless sudo vim htop cron && \ rm -rf /var/lib/apt/lists/* -# Add non-root user and create our folders +# Create our folders RUN \ - useradd --uid 941 --user-group --home $HOME --shell /bin/bash abc && \ - usermod --groups users abc && \ mkdir -p \ $ILICHECK_APP_HOME_DIR \ $ILICHECK_APP_LOG_DIR \ @@ -80,7 +78,7 @@ RUN \ $ILITOOLS_MODELS_DIR \ $ILITOOLS_PLUGINS_DIR -EXPOSE 80 +EXPOSE 8080 VOLUME $ILICHECK_APP_LOG_DIR VOLUME $ILICHECK_UPLOADS_DIR VOLUME $ILITOOLS_CONFIG_DIR @@ -92,13 +90,10 @@ VOLUME $ILITOOLS_PLUGINS_DIR ENV LANG=C.UTF-8 ENV LC_ALL=C.UTF-8 -# Allow dotnet to bind to well known ports -RUN setcap CAP_NET_BIND_SERVICE=+eip /usr/share/dotnet/dotnet - COPY --from=build /app/publish $ILICHECK_APP_HOME_DIR COPY docker-entrypoint.sh /entrypoint.sh COPY ilivalidator-wrapper.sh /usr/local/bin/ilivalidator -HEALTHCHECK CMD curl --fail http://localhost/health || exit 1 +HEALTHCHECK CMD curl --fail http://localhost:8080/health || exit 1 ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index d958993..3f9d2a2 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Mit [Docker](https://www.docker.com/) kann der *INTERLIS Web-Check-Service* in e Um einen ersten Augenschein der Applikation zu nehmen, kann der Container in der Kommandozeile wie folgt gestartet werden: ```bash -docker run -it --rm -p 8080:80 ghcr.io/geowerkstatt/interlis-check-service:latest +docker run -it --rm -p 8080:8080 ghcr.io/geowerkstatt/interlis-check-service:latest ``` `docker-compose.yml` @@ -106,16 +106,6 @@ services: # Add environment variables # # environment: - # - PUID=1000 - # Optional, Default user id 941 - # Using PUID and PGID allows to map the container's internal user to a user on the - # host machine which prevents permisson issues when writing files to the mounted volume - # - # - PGID=1000 - # Optional, Default group id 941 - # Using PUID and PGID allows to map the container's internal user to a user on the - # host machine which prevents permisson issues when writing files to the mounted volume - # # - DELETE_TRANSFER_FILES=true # Optional, If set to true, transfer files get deleted right after ilivalidator # has completed validation @@ -173,17 +163,15 @@ services: # - CUSTOM_VENDOR_LINK=https://www.example.com # Optional link to the vendors webpage # The link is only taken into account if there is a corresponding vendor.png - environment: - - PUID=1000 - - PGID=1000 + # Expose ports (HOST:CONTAINER) # # ports: - # - 3080:80 - # Map port 80 in the container to any desired port on the Docker host - # INTERLIS Web-Check-Service web app runs on port 80 inside the container + # - 3080:8080 + # Map port 8080 in the container to any desired port on the Docker host + # INTERLIS Web-Check-Service web app runs on port 8080 inside the container ports: - - 3080:80 + - 3080:8080 ``` ## Individuelle Anpassung diff --git a/docker-compose.yml b/docker-compose.yml index bf199e5..e7d7cd3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -73,16 +73,6 @@ services: # Add environment variables # # environment: - # - PUID=1000 - # Optional, Default user id 941 - # Using PUID and PGID allows to map the container's internal user to a user on the - # host machine which prevents permisson issues when writing files to the mounted volume - # - # - PGID=1000 - # Optional, Default group id 941 - # Using PUID and PGID allows to map the container's internal user to a user on the - # host machine which prevents permisson issues when writing files to the mounted volume - # # - DELETE_TRANSFER_FILES=true # Optional, If set to true, transfer files get deleted right after ilivalidator # has completed validation @@ -140,14 +130,12 @@ services: # - CUSTOM_VENDOR_LINK=https://www.example.com # Optional link to the vendors webpage # The link is only taken into account if there is a corresponding vendor.png - environment: - - PUID=1000 - - PGID=1000 + # Expose ports (HOST:CONTAINER) # # ports: - # - 3080:80 - # Map port 80 in the container to any desired port on the Docker host - # INTERLIS Web-Check-Service web app runs on port 80 inside the container + # - 3080:8080 + # Map port 8080 in the container to any desired port on the Docker host + # INTERLIS Web-Check-Service web app runs on port 8080 inside the container ports: - - 3080:80 + - 3080:8080 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index e50323f..4bde93d 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -40,23 +40,17 @@ download_and_configure_ilitool ilivalidator $ILIVALIDATOR_VERSION $ILITOOLS_HOME cp -f $ILICHECK_WEB_ASSETS_DIR/* $ILICHECK_APP_HOME_DIR/ClientApp/build/ && \ echo "done!" -# Use default user:group if no $PUID and/or $PGID is provided. -groupmod -o -g ${PUID:-941} abc && \ - usermod -o -u ${PGID:-941} abc &> /dev/null && \ - usermod -aG sudo abc && \ - echo "abc ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers - # Change owner for our folders echo -n "Fix permissions for mounted volumes ..." && \ - chown -R abc:abc $ILICHECK_APP_HOME_DIR && \ - chown -R abc:abc $ILICHECK_APP_LOG_DIR && \ - chown -R abc:abc $ILICHECK_UPLOADS_DIR && \ - chown -R abc:abc $ILICHECK_WEB_ASSETS_DIR && \ - chown -R abc:abc $ILITOOLS_HOME_DIR && \ - chown -R abc:abc $ILITOOLS_CONFIG_DIR && \ - chown -R abc:abc $ILITOOLS_CATALOGUES_DIR && \ - chown -R abc:abc $ILITOOLS_MODELS_DIR && \ - chown -R abc:abc $ILITOOLS_PLUGINS_DIR && \ + chown -R app:app $ILICHECK_APP_HOME_DIR && \ + chown -R app:app $ILICHECK_APP_LOG_DIR && \ + chown -R app:app $ILICHECK_UPLOADS_DIR && \ + chown -R app:app $ILICHECK_WEB_ASSETS_DIR && \ + chown -R app:app $ILITOOLS_HOME_DIR && \ + chown -R app:app $ILITOOLS_CONFIG_DIR && \ + chown -R app:app $ILITOOLS_CATALOGUES_DIR && \ + chown -R app:app $ILITOOLS_MODELS_DIR && \ + chown -R app:app $ILITOOLS_PLUGINS_DIR && \ echo "done!" # Export current environment for all users and cron jobs @@ -82,11 +76,11 @@ ilivalidator model repositories: $ILIVALIDATOR_MODEL_DIR ilivalidator trace messages: $([[ $ILIVALIDATOR_ENABLE_TRACE = true ]] && echo enabled || echo disabled) http proxy: ${PROXY:-no proxy set} http proxy exceptions: $([[ -n $NO_PROXY ]] && echo $NO_PROXY || echo undefined) -user uid: $(id -u abc) -user gid: $(id -g abc) +user uid: $(id -u app) +user gid: $(id -g app) timezone: $TZ -------------------------------------------------------------------------- " echo -e "INTERLIS web check service app is up and running!\n" && \ - sudo -H --preserve-env --user abc dotnet ILICheck.Web.dll + sudo -H --preserve-env --user app dotnet ILICheck.Web.dll diff --git a/ilivalidator-wrapper.sh b/ilivalidator-wrapper.sh index 83e98c5..22060c7 100755 --- a/ilivalidator-wrapper.sh +++ b/ilivalidator-wrapper.sh @@ -22,9 +22,6 @@ proxy_host=${proxy_host#*://} # remove protocol [[ $ILIVALIDATOR_ENABLE_TRACE = true ]] && options+=" --trace" [[ $(find $ILITOOLS_PLUGINS_DIR -maxdepth 1 -type f -iname "*.jar" | grep .) ]] && [[ $is_gpkg = false ]] && options+=" --plugins $ILITOOLS_PLUGINS_DIR" -# Print executed commands to the Docker container log output -exec {BASH_XTRACEFD}> >(sudo tee /proc/1/fd/2) - # Execute ilivalidator/ili2gpkg with the given options if [[ $ENABLE_GPKG_VALIDATION = true && $is_gpkg = true ]] then diff --git a/src/ILICheck.Web/appsettings.Development.json b/src/ILICheck.Web/appsettings.Development.json index 67f7766..260c0d1 100644 --- a/src/ILICheck.Web/appsettings.Development.json +++ b/src/ILICheck.Web/appsettings.Development.json @@ -9,6 +9,6 @@ }, "Validation": { "ShellExecutable": "powershell.exe", - "CommandFormat": "docker compose exec --user abc web bash -l -c '{0}'" + "CommandFormat": "docker compose exec --user app web bash -l -c '{0}'" } } From 4b73d3f7138777f081d11b8e89aac6e11d9283a2 Mon Sep 17 00:00:00 2001 From: Dominic Burger Date: Tue, 20 Aug 2024 15:31:39 +0200 Subject: [PATCH 04/10] Update nuget dependencies --- src/ILICheck.Web/ILICheck.Web.csproj | 8 ++++---- tests/ILICheck.Web.Test/ILICheck.Web.Test.csproj | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ILICheck.Web/ILICheck.Web.csproj b/src/ILICheck.Web/ILICheck.Web.csproj index be58d57..ab01092 100644 --- a/src/ILICheck.Web/ILICheck.Web.csproj +++ b/src/ILICheck.Web/ILICheck.Web.csproj @@ -12,15 +12,15 @@ - + - - - + + + diff --git a/tests/ILICheck.Web.Test/ILICheck.Web.Test.csproj b/tests/ILICheck.Web.Test/ILICheck.Web.Test.csproj index bafd004..4da7766 100644 --- a/tests/ILICheck.Web.Test/ILICheck.Web.Test.csproj +++ b/tests/ILICheck.Web.Test/ILICheck.Web.Test.csproj @@ -9,10 +9,10 @@ - - - - + + + + From 515c10d37365633e36cb01b01dc1bc63dea61f34 Mon Sep 17 00:00:00 2001 From: Dominic Burger Date: Tue, 20 Aug 2024 15:36:23 +0200 Subject: [PATCH 05/10] Bump version --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index f398a20..06a4457 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.0 \ No newline at end of file +3.1 \ No newline at end of file From a772d4895a436a02765abda22a5cc74534598f2b Mon Sep 17 00:00:00 2001 From: Dominic Burger Date: Tue, 20 Aug 2024 16:13:09 +0200 Subject: [PATCH 06/10] Update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6d5133..9ed72ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## [Unreleased] +### Changed + +- Updated to .NET 8.0. +- The app now runs on port 8080 inside the docker container. + ## v3.0.110 - 2024-05-16 ### Added From e798fb6ccebc6455d72e4371ef268e0cf83d716c Mon Sep 17 00:00:00 2001 From: Dominic Burger Date: Thu, 22 Aug 2024 13:25:46 +0200 Subject: [PATCH 07/10] Re-add uid and gid override for docker container New default id 1654 matching dotnet app user defaults. --- CHANGELOG.md | 1 + README.md | 14 +++++++++++++- docker-compose.yml | 14 +++++++++++++- docker-entrypoint.sh | 4 ++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ed72ff..aa406e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Updated to .NET 8.0. - The app now runs on port 8080 inside the docker container. +- Default uid & gid of container user changed to 1654. ## v3.0.110 - 2024-05-16 diff --git a/README.md b/README.md index 3f9d2a2..217409d 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,16 @@ services: # Add environment variables # # environment: + # - PUID=1000 + # Optional, Default user id 1654 + # Using PUID and PGID allows to map the container's internal user to a user on the + # host machine which prevents permisson issues when writing files to the mounted volume + # + # - PGID=1000 + # Optional, Default group id 1654 + # Using PUID and PGID allows to map the container's internal user to a user on the + # host machine which prevents permisson issues when writing files to the mounted volume + # # - DELETE_TRANSFER_FILES=true # Optional, If set to true, transfer files get deleted right after ilivalidator # has completed validation @@ -163,7 +173,9 @@ services: # - CUSTOM_VENDOR_LINK=https://www.example.com # Optional link to the vendors webpage # The link is only taken into account if there is a corresponding vendor.png - + environment: + - PUID=1000 + - PGID=1000 # Expose ports (HOST:CONTAINER) # # ports: diff --git a/docker-compose.yml b/docker-compose.yml index e7d7cd3..2469d7e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -73,6 +73,16 @@ services: # Add environment variables # # environment: + # - PUID=1000 + # Optional, Default user id 1654 + # Using PUID and PGID allows to map the container's internal user to a user on the + # host machine which prevents permisson issues when writing files to the mounted volume + # + # - PGID=1000 + # Optional, Default group id 1654 + # Using PUID and PGID allows to map the container's internal user to a user on the + # host machine which prevents permisson issues when writing files to the mounted volume + # # - DELETE_TRANSFER_FILES=true # Optional, If set to true, transfer files get deleted right after ilivalidator # has completed validation @@ -130,7 +140,9 @@ services: # - CUSTOM_VENDOR_LINK=https://www.example.com # Optional link to the vendors webpage # The link is only taken into account if there is a corresponding vendor.png - + environment: + - PUID=1000 + - PGID=1000 # Expose ports (HOST:CONTAINER) # # ports: diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 4bde93d..2cff8e8 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -40,6 +40,10 @@ download_and_configure_ilitool ilivalidator $ILIVALIDATOR_VERSION $ILITOOLS_HOME cp -f $ILICHECK_WEB_ASSETS_DIR/* $ILICHECK_APP_HOME_DIR/ClientApp/build/ && \ echo "done!" +# Use default user:group if no $PUID and/or $PGID is provided. +groupmod -o -g ${PUID:-1654} app && \ + usermod -o -u ${PGID:-1654} app &> /dev/null + # Change owner for our folders echo -n "Fix permissions for mounted volumes ..." && \ chown -R app:app $ILICHECK_APP_HOME_DIR && \ From 3ec355b34a38f59f8b86a723417b90085146c012 Mon Sep 17 00:00:00 2001 From: Dominic Burger Date: Mon, 26 Aug 2024 08:25:45 +0200 Subject: [PATCH 08/10] Bump version --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 06a4457..389f774 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.1 \ No newline at end of file +4.0 \ No newline at end of file From bd112ad148f226c0d21894a96dafc6a1e74b74cf Mon Sep 17 00:00:00 2001 From: Dominic <18161827+domi-b@users.noreply.github.com> Date: Mon, 26 Aug 2024 08:28:07 +0200 Subject: [PATCH 09/10] Add note for changed port Co-authored-by: Oliver Gut --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa406e0..07d2366 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ### Changed - Updated to .NET 8.0. -- The app now runs on port 8080 inside the docker container. +- The app now runs on port 8080 inside the docker container. Please update your Docker compose! - Default uid & gid of container user changed to 1654. ## v3.0.110 - 2024-05-16 From 14a78b9e78305dc73d23bc9193ee9b16d525c3a1 Mon Sep 17 00:00:00 2001 From: Dominic Burger Date: Mon, 26 Aug 2024 13:22:33 +0200 Subject: [PATCH 10/10] Move NoWarn rule to editorconfig --- tests/.editorconfig | 1 + tests/ILICheck.Web.Test/ILICheck.Web.Test.csproj | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/.editorconfig b/tests/.editorconfig index 35fd037..db4c92b 100644 --- a/tests/.editorconfig +++ b/tests/.editorconfig @@ -15,4 +15,5 @@ # Configure code analysis according to current standards by default. [*.cs] dotnet_diagnostic.CA1001.severity = none +dotnet_diagnostic.CA1861.severity = none dotnet_diagnostic.SA0001.severity = none diff --git a/tests/ILICheck.Web.Test/ILICheck.Web.Test.csproj b/tests/ILICheck.Web.Test/ILICheck.Web.Test.csproj index 4da7766..40319bc 100644 --- a/tests/ILICheck.Web.Test/ILICheck.Web.Test.csproj +++ b/tests/ILICheck.Web.Test/ILICheck.Web.Test.csproj @@ -5,7 +5,6 @@ false ILICheck.Web.Test ILICheck.Web - CA1861