Chromedriver and Chrome in Nixpacks for Selenium (python)

Hello, I'm migrating to Railway from Heroku. So far Railway is superior, however, I'm still missing one feature which is likely to be possible, but I need some help to implement it there: In Heroku I've been using heroku-buildpacks for the chromedriver and google-chrome for Selenium (webscraping with permission), more specifically the following: https://github.com/heroku/heroku-buildpack-chromedriver https://github.com/heroku/heroku-buildpack-google-chrome Used python like this
from selenium import webdriver
GOOGLE_CHROME_PATH = '/app/.apt/usr/bin/google-chrome'
CHROMEDRIVER_PATH = '/app/.chromedriver/bin/chromedriver'
op = webdriver.ChromeOptions()
op.binary_location = GOOGLE_CHROME_PATH
op.add_argument('--headless')
op.add_argument('--disable-gpu')
op.add_argument('--no-sandbox')
op.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, chrome_options=op)
[...]
from selenium import webdriver
GOOGLE_CHROME_PATH = '/app/.apt/usr/bin/google-chrome'
CHROMEDRIVER_PATH = '/app/.chromedriver/bin/chromedriver'
op = webdriver.ChromeOptions()
op.binary_location = GOOGLE_CHROME_PATH
op.add_argument('--headless')
op.add_argument('--disable-gpu')
op.add_argument('--no-sandbox')
op.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, chrome_options=op)
[...]
Now that I don't have the heroku-buildpacks anymore, what should I change? I heard about Nixpacks and I've read a few things, but I still didn't quite get it. Can anyone please help me setting it up, meaning specifically... 1. What file/code do I need to include to "install" chromedriver and chrome via Nixpacks with python? 2. How do I get the paths to include (as seen above in the code)? / What are the paths? (Optional 3. Any other advice would be appreciated) Thanks in advance!
4 Replies
Percy
Percy3y ago
Project ID: N/A
Azu𝕏orce@シノン教
N/A Not sure if I got the buildpacks "installed", but I simply added a railway.json file in the directory with the content:
{
"build": {
"builder": "NIXPACKS",
"nixpacksPlan": {
"providers": [
"...",
"python"
],
"nixPkgs": [
"...",
"google-chrome",
"chromedriver"
]
}
}
}
{
"build": {
"builder": "NIXPACKS",
"nixpacksPlan": {
"providers": [
"...",
"python"
],
"nixPkgs": [
"...",
"google-chrome",
"chromedriver"
]
}
}
}
I don't actually know if it was successful, but where (path) would that be located? I would need to know where to point
GOOGLE_CHROME_PATH = '/app/.apt/usr/bin/google-chrome'
CHROMEDRIVER_PATH = '/app/.chromedriver/bin/chromedriver'
GOOGLE_CHROME_PATH = '/app/.apt/usr/bin/google-chrome'
CHROMEDRIVER_PATH = '/app/.chromedriver/bin/chromedriver'
these variables to... Sorry, I'm totally new to Nixpacks
jr
jr3y ago
Very close! I think this is more what you are looking for
{
"build": {
"builder": "NIXPACKS",
"nixpacksPlan": {
"providers": ["...", "python"],
"phases": {
"setup": {
"nixPkgs": ["...", "google-chrome", "chromedriver"]
}
}
}
},
"deploy": {
"startCommand": "echo starting"
}
}
{
"build": {
"builder": "NIXPACKS",
"nixpacksPlan": {
"providers": ["...", "python"],
"phases": {
"setup": {
"nixPkgs": ["...", "google-chrome", "chromedriver"]
}
}
}
},
"deploy": {
"startCommand": "echo starting"
}
}
Note the phases object Unfortunatley, I just tested it and I am running into a Nix install error due to the chrome package having a different license. That is something we can fix in Nixpacks itself though! (I'll let you know once it is implemented). In the meantime you can try installing any package with apt-get
Azu𝕏orce@シノン教
Awesome, thanks. How do I install using apt-get? using apt-get instead of nixPkgs? Where would it be installed such that I can point the variable to? I replaced "nixPkgs" with "aptPkgs" to use apt-get, but I get this error:
#9 [stage-0 5/12] RUN apt-get update && apt-get install -y --no-install-recommends google-chrome chromedriver
#9 sha256:fbab041eb8b3b988e75f065ab2e1e4afee757d22cb55d41de6db84681ce896dd

#9 0.618 apt-get: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /nix/store/c8zdsf7csk8msjb914bhccdhq0ycmqys-gcc-11.3.0-lib/lib/libstdc++.so.6)
#9 0.618 apt-get: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /nix/store/c8zdsf7csk8msjb914bhccdhq0ycmqys-gcc-11.3.0-lib/lib/libstdc++.so.6)
#9 0.618 apt-get: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /nix/store/c8zdsf7csk8msjb914bhccdhq0ycmqys-gcc-11.3.0-lib/lib/libstdc++.so.6)
#9 0.618 apt-get: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /nix/store/c8zdsf7csk8msjb914bhccdhq0ycmqys-gcc-11.3.0-lib/lib/libgcc_s.so.1)
#9 ERROR: executor failed running [/bin/bash -ol pipefail -c apt-get update && apt-get install -y --no-install-recommends google-chrome chromedriver]: exit code: 1

-----
> [stage-0 5/12] RUN apt-get update && apt-get install -y --no-install-recommends google-chrome chromedriver:
-----
executor failed running [/bin/bash -ol pipefail -c apt-get update && apt-get install -y --no-install-recommends google-chrome chromedriver]: exit code: 1

Error: Docker build failed
#9 [stage-0 5/12] RUN apt-get update && apt-get install -y --no-install-recommends google-chrome chromedriver
#9 sha256:fbab041eb8b3b988e75f065ab2e1e4afee757d22cb55d41de6db84681ce896dd

#9 0.618 apt-get: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /nix/store/c8zdsf7csk8msjb914bhccdhq0ycmqys-gcc-11.3.0-lib/lib/libstdc++.so.6)
#9 0.618 apt-get: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /nix/store/c8zdsf7csk8msjb914bhccdhq0ycmqys-gcc-11.3.0-lib/lib/libstdc++.so.6)
#9 0.618 apt-get: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /nix/store/c8zdsf7csk8msjb914bhccdhq0ycmqys-gcc-11.3.0-lib/lib/libstdc++.so.6)
#9 0.618 apt-get: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /nix/store/c8zdsf7csk8msjb914bhccdhq0ycmqys-gcc-11.3.0-lib/lib/libgcc_s.so.1)
#9 ERROR: executor failed running [/bin/bash -ol pipefail -c apt-get update && apt-get install -y --no-install-recommends google-chrome chromedriver]: exit code: 1

-----
> [stage-0 5/12] RUN apt-get update && apt-get install -y --no-install-recommends google-chrome chromedriver:
-----
executor failed running [/bin/bash -ol pipefail -c apt-get update && apt-get install -y --no-install-recommends google-chrome chromedriver]: exit code: 1

Error: Docker build failed
Want results from more Discord servers?
Add your server