Skip to content

Commit

Permalink
Merge tag '2.1.0' into dev
Browse files Browse the repository at this point in the history
Use xvfb instead of headless mode in docker
  • Loading branch information
KarmaKamikaze committed Oct 11, 2024
2 parents 9e24600 + ebf4137 commit 8c50b5b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
9 changes: 7 additions & 2 deletions MoxfieldPriceScraper/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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/*

Expand All @@ -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"]
3 changes: 2 additions & 1 deletion MoxfieldPriceScraper/MoxfieldScraper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 8c50b5b

Please sign in to comment.