#Help Debugging SeleniumBase UC Mode Failure in Nixpacks Deployment (uc_driver not found)

38 messages · Page 1 of 1 (latest)

proven bramble
#

Hi Railway/Nixpacks team! Need help getting SeleniumBase(uc=True) working in a Nixpacks deployment.

Goal: Headless Chromium logs into Google, gets cookies.
Problem: Driver(uc=True, headless=True) fails during init in Railway deployment. Base FastAPI app works fine.
Environment: Railway, Nixpacks (Python), python:3.9-slim base, seleniumbase, fastapi, uvicorn, supabase.

nixpacks.toml:

[phases.setup]
nixPkgs = ["chromium", "nss"]

(Dockerfile apt-get install chrome is commented out).

Status & What Fails:

  • SSH confirms Nix-installed chromium runs, network/permissions seem OK.
  • Error shifted after adding nss: Previously uc_driver exited (Status 127 - likely missing libs, friend saw libnss3.so error). Now uc_driver file isn't found/saved in seleniumbase/drivers/ at all.
  • Crucially: Adding a larger list of potential libs (e.g., gtk+3, libX11) to nixPkgs caused the Nixpacks build itself to fail.

Questions:

  1. What's the correct way to include all required shared libraries for chromium & uc_driver via nixPkgs?
  2. Why might adding many common libs break the Nixpacks build? (Known conflicts/issues?)
  3. How best to debug the uc_driver startup failure within the Nixpacks runtime?

Using seleniumbase.Driver(uc=True, headless=True) in Python. Any pointers on the Nixpacks config for headless browsers would be great! Thanks!

slate beaconBOT
#

Project ID: N/A

proven bramble
#

c273ff49-d38d-48f7-afbe-925a93b75499

#

I've removed nss from nixpkgs for now - didnt see a reason to keep it

uneven field
proven bramble
#

Did not know this was a thing, I'll try it today, will keep this thread updated

proven bramble
#

Now it doesnt work locally, as when i use browserless google detects that its a selenium based browser. The point of using selenium base with undetectable mode was so that i am able to sign into a google account. The old code still works locally, just fails to deploy due to missing libraries. Does browserless support seleniumbase?

proven bramble
#

Deployment to Render has succeeded. Still no luck on railway. Is there a way to just fix this missing libraries error? Its extremely specific to railway and the way railway initializes chromium/selenium. works like butter deploying locally, even works on render with a couple of minor adjustments

uneven field
#

you could write a Dockerfile

proven bramble
#

thats exactly what im doing, works perfectly fine locally but fails to deploy on railway despite working fine locally

here's the current dockerfile:

# Base image with Python
FROM python:3.9-slim

# Set environment variables
ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PIP_NO_CACHE_DIR=1

# Install system dependencies
RUN apt-get update && apt-get install -y \
    wget \
    gnupg \
    unzip \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Install Google Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
    && apt-get update \
    && apt-get install -y google-chrome-stable \
    && rm -rf /var/lib/apt/lists/*

# Set up working directory
WORKDIR /app

# Install Python dependencies
COPY requirements.txt .
RUN pip install --upgrade pip && \
    pip install -r requirements.txt && \
    pip install python-dotenv  # Add python-dotenv for .env support

# Copy application code and .env file
COPY . .
# No need to copy .env separately since it's already included in the previous COPY command

# Expose port
EXPOSE 8000

# Command to run the application
CMD ["python", "main.py"]
uneven field
#

may i ask why nixpacks was mentioned then? nixpacks and dockerfiles are mutually exclusive

proven bramble
#

I'm not a super experienced dev, when i was facing this issue with docker i did a bunch of debugging with ai, it told me to use dockerfile for everything (except chromium) and add chromium only via nixpacks
do you suggest running locally with nixpacks? as local docker works fine and fails in deployment - and im assuming since railway uses nixpacks it'd be more productive to run what railway runs locally?

uneven field
#

if you have a working dockerfile locally then using that on railway is going to be most productive.. does your dockerfile work locally?

proven bramble
#

Exactly what im thinking! Dockerfile works perfectly locally, sent it to a friend, and it worked like a charm on his machine as well! However deployment to railway shows drivers missing error

uneven field
#

are you building with buildkit locally too?

proven bramble
#

Nope, locally its pure dockerfile

uneven field
#

try with buildkit, since thats what we build with

proven bramble
#

Is buildkit enabled by default if i build using a dockerfile?

proven bramble
#

To resend the message i sent on general, since mods asked me to keep my questions contained to this thread:

#

What about caching? Suppose im building a custom docker image
Does the build get cached? The build time initially on my local machine is 2 minutes, and subsequent builds are <2s
Will the same be reflected on railway?
Or should i upload this to a public registry and pull from there

#

Thank you so much for the help so far, this has been incredibly helpful

I managed to get the server deployed - just need to optimise for build times now

uneven field
#

awsome, im glad you solved it, but what was the issue if you dont mind me asking?

proven bramble
#

it was incredibly stupid, get this: i never realised railway wasnt using the dockerfile. after you mentioned the buildkit thing i figured out that you have to explicitly define the dockerfile path to use it to build
so sorry 😭

uneven field
proven bramble
#

yeah it was at root but named dockerfile not Dockerfile, so ig thts why it didnt pick it up

uneven field
proven bramble
#

sorry yeah i meant custom dockerfile

uneven field
#

then yes, layers are still cached, but your build could end up on a machine that doesn't have the cache and thus no cache will be used for that particular build since we don't yet have a global cache

proven bramble
#

So what's the best approach for minimising build times if the build ending up on a different machine is a possiblity? ghcr?

uneven field
#

yeah you could build your image on ghcr, but it's really not worth it with what you lose imo

proven bramble
#

wait what do you lose if you push to ghcr? what do you recommend?

uneven field
#

you lose the auto deploys on push, i recommend keep deploying from github as you have been

proven bramble
#

Oh cool got it, ig i can deal with 2min build times

uneven field
#

sounds good!

#

good to mark this as solved?

proven bramble
#

yep. thanks a ton!

uneven field
#

!s