diff --git a/MoxfieldPriceScraper/Dockerfile b/MoxfieldPriceScraper/Dockerfile index 60a6f22..84fd111 100644 --- a/MoxfieldPriceScraper/Dockerfile +++ b/MoxfieldPriceScraper/Dockerfile @@ -16,7 +16,7 @@ RUN DOTNET_EnableWriteXorExecute=0 dotnet publish -c $BUILD_CONFIGURATION -p:DOC FROM mcr.microsoft.com/dotnet/runtime:8.0 AS runtime WORKDIR /app -# Install chromium and dependencies +# Install chromium, xvfb, and dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ chromium \ chromium-driver \ @@ -31,6 +31,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libxss1 \ libasound2 \ libdbus-glib-1-2 \ + xvfb \ + x11-apps \ + libnss3 \ + libasound2 \ + fonts-noto-color-emoji \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* @@ -40,4 +45,4 @@ HEALTHCHECK --interval=5m --timeout=1m --start-period=30s --retries=3 CMD ["dotn VOLUME ["/app/Data", "/app/Logs"] -ENTRYPOINT ["dotnet", "MoxfieldPriceScraper.dll"] +ENTRYPOINT ["/bin/sh", "-c", "/usr/bin/xvfb-run -a dotnet MoxfieldPriceScraper.dll"] diff --git a/MoxfieldPriceScraper/MoxfieldScraper.cs b/MoxfieldPriceScraper/MoxfieldScraper.cs index f192f14..c655712 100644 --- a/MoxfieldPriceScraper/MoxfieldScraper.cs +++ b/MoxfieldPriceScraper/MoxfieldScraper.cs @@ -111,7 +111,6 @@ private void InitializeWebDriver() Log.Debug("Initializing WebDriver"); var chromeOptions = new ChromeOptions(); chromeOptions.AddArgument("--no-sandbox"); // Bypass OS security model - chromeOptions.AddArgument("--headless=new"); // Run in headless mode, without a GUI chromeOptions.AddArgument("--disable-gpu"); // Disables GPU hardware acceleration chromeOptions.AddArgument("--disable-software-rasterizer"); // Disable software rasterizer chromeOptions.AddArgument("--disable-setuid-sandbox"); // Disable setuid sandbox @@ -139,9 +138,11 @@ private void InitializeWebDriver() chromeOptions.BinaryLocation = "/usr/bin/chromium"; _driver = new ChromeDriver("/usr/bin/chromedriver", chromeOptions, TimeSpan.FromMinutes(5)); # elif LINUX + chromeOptions.AddArgument("--headless=new"); // Run in headless mode, without a GUI chromeOptions.BinaryLocation = "/usr/bin/chromium-browser"; _driver = new ChromeDriver("/usr/bin/chromedriver", chromeOptions, TimeSpan.FromMinutes(5)); #else + chromeOptions.AddArgument("--headless=new"); // Run in headless mode, without a GUI new DriverManager().SetUpDriver(new ChromeConfig()); _driver = new ChromeDriver(chromeOptions); #endif diff --git a/docker-compose.yml b/docker-compose.yml index 0884446..ec28d82 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,12 +14,14 @@ - Sender_EMAIL_PASSWORD=/run/secrets/SENDER_EMAIL_PASSWORD - RECEIVER_EMAIL_ADDRESS=${RECEIVER_EMAIL_ADDRESS} - DECK_LIST=${DECK_LIST} + - DISPLAY=:0 secrets: - MOXFIELD_PASSWORD - SENDER_EMAIL_PASSWORD volumes: - ${PWD}/Data:/app/Data - ${PWD}/Logs:/app/Logs + - /tmp/.X11-unix:/tmp/.X11-unix labels: - "com.centurylinklabs.watchtower.enable=true"