From 2dc9689342bd892ec91f5a2cf00133761dc786e2 Mon Sep 17 00:00:00 2001 From: KarmaKamikaze Date: Wed, 25 Sep 2024 17:09:37 +0200 Subject: [PATCH 1/2] Define DOCKER constant --- MoxfieldPriceScraper/MoxfieldPriceScraper.csproj | 4 ++++ MoxfieldPriceScraper/MoxfieldScraper.cs | 10 ++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/MoxfieldPriceScraper/MoxfieldPriceScraper.csproj b/MoxfieldPriceScraper/MoxfieldPriceScraper.csproj index 405e46b..b63bbe2 100644 --- a/MoxfieldPriceScraper/MoxfieldPriceScraper.csproj +++ b/MoxfieldPriceScraper/MoxfieldPriceScraper.csproj @@ -1,5 +1,9 @@  + + DOCKER + + Exe net8.0 diff --git a/MoxfieldPriceScraper/MoxfieldScraper.cs b/MoxfieldPriceScraper/MoxfieldScraper.cs index 96bc162..465f4d8 100644 --- a/MoxfieldPriceScraper/MoxfieldScraper.cs +++ b/MoxfieldPriceScraper/MoxfieldScraper.cs @@ -1,6 +1,5 @@ using System.Drawing; using System.Globalization; -using System.Runtime.InteropServices; using OpenQA.Selenium; using OpenQA.Selenium.Chrome; using Serilog; @@ -121,12 +120,11 @@ private void InitializeWebDriver() }; chromeOptions.AddUserProfilePreference("prefs", preferences); +#if DOCKER // Skip driver setup for ARM architecture - if (!(RuntimeInformation.OSArchitecture == Architecture.Arm && - RuntimeInformation.OSArchitecture == Architecture.Arm64)) - { - new DriverManager().SetUpDriver(new ChromeConfig()); - } +#else + new DriverManager().SetUpDriver(new ChromeConfig()); +#endif _driver = new ChromeDriver(chromeOptions); _driver.Manage().Timeouts().ImplicitWait = _elementSeekTimeout; From e0681873979526f9ed721c3ca77018fc12fdd551 Mon Sep 17 00:00:00 2001 From: KarmaKamikaze Date: Wed, 25 Sep 2024 17:10:51 +0200 Subject: [PATCH 2/2] Use DOCKER constant in Dockerfile --- MoxfieldPriceScraper/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MoxfieldPriceScraper/Dockerfile b/MoxfieldPriceScraper/Dockerfile index 4fa075b..3078f9a 100644 --- a/MoxfieldPriceScraper/Dockerfile +++ b/MoxfieldPriceScraper/Dockerfile @@ -11,7 +11,7 @@ COPY *.csproj ./ RUN DOTNET_EnableWriteXorExecute=0 dotnet restore COPY . ./ -RUN DOTNET_EnableWriteXorExecute=0 dotnet publish -c $BUILD_CONFIGURATION -o out --no-restore +RUN DOTNET_EnableWriteXorExecute=0 dotnet publish -c $BUILD_CONFIGURATION -o out --no-restore -p:DOCKER_BUILD=true FROM mcr.microsoft.com/dotnet/runtime:8.0 AS runtime WORKDIR /app