Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set binary path to Chromium #15

Merged
merged 2 commits into from
Sep 25, 2024
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
2 changes: 1 addition & 1 deletion MoxfieldPriceScraper/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 -p:DOCKER_BUILD=true
RUN DOTNET_EnableWriteXorExecute=0 dotnet publish -c $BUILD_CONFIGURATION -p:DOCKER_BUILD=true -o out --no-restore

FROM mcr.microsoft.com/dotnet/runtime:8.0 AS runtime
WORKDIR /app
Expand Down
6 changes: 3 additions & 3 deletions MoxfieldPriceScraper/MoxfieldScraper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,14 @@ private void InitializeWebDriver()
chromeOptions.AddArgument("--window-size=2560,1440"); // Set window size
chromeOptions.AddArgument("--log-level=3"); // Disable logging
chromeOptions.AddExcludedArguments("enable-logging"); // Disable logging
chromeOptions.BinaryLocation = GetChromeLocation();
var preferences = new Dictionary<string, object>
{
{ "profile.managed_default_content_settings.images", 2 } // Disable image loading
};
chromeOptions.AddUserProfilePreference("prefs", preferences);

#if DOCKER
// Skip driver setup for ARM architecture
chromeOptions.BinaryLocation = GetChromeLocation();
#else
new DriverManager().SetUpDriver(new ChromeConfig());
#endif
Expand All @@ -139,7 +138,8 @@ private static string GetChromeLocation()
{
var options = new ChromeOptions
{
BrowserVersion = "stable"
BrowserVersion = "stable",
BinaryLocation = "/usr/bin/chromium"
};
return new DriverFinder(options).GetBrowserPath();
}
Expand Down