R
Railway

✋|help

Deploying without having to do npx playwright install-deps

Aabc2229/1/2023
Hello,
I'm deploying a node.js application that is using playwright, and it needs some dependencies in the container to run playwright well

However, I don't know how to use an image, or a setup that already has those dependencies

For now, I have this in my package.json scripts :
"start": "npx playwright install-deps && vite preview --host 0.0.0.0 --port $PORT"

However, it implies that the command is executed at every deployment, and it may just consume CPU power and slow down deployment, so I'm searching for a more elegant and efficient way of deploying with those playwright dependencies

It would be awesome if I could get some help to solve that issue !
Aabc2229/1/2023
df1ac280-a03b-4213-9495-09597046a130
Bbrody1929/1/2023
honestly, the far bigger issue is that you are running a preview server on railway
but lets fix both
what kind of vite app is this?
Aabc2229/1/2023
Hello, it is a SvelteKit app, I know it's not recommended to run a preview app, but it doesn't affect performance
I could do something like
"start": "node ./build/index.js" or something like that, even if I don't exactly get in which folder my project is built
Bbrody1929/1/2023
oh yes it does, it also effects costs
Aabc2229/1/2023
but I think I should do that when the first issue is fixed

my app is also taking 900 MB of RAM just on deploy, without touching anything
yes
maybe it's because I ran in preview
so you may be right on this
Bbrody1929/1/2023
i am right
Aabc2229/1/2023
yes
Bbrody1929/1/2023
but okay install playwright in the build phase instead of at start
Aabc2229/1/2023
how should I do that ? do i need to make a docker image ?
Bbrody1929/1/2023
add this as a nixpacks.toml file to your project
[phases.playwright]
dependsOn = ['install']
cmds = ['npx playwright install-deps']
Aabc2229/1/2023
okay, i have no nixpacks.toml file for now in my project

can I just write only that in it ?
Bbrody1929/1/2023
and then you can remove the playwright from the start command
Aabc2229/1/2023
Or should I init a nixpacks.toml with a specific command ?
Bbrody1929/1/2023
just make that file with that contents, nothing special
Aabc2229/1/2023
okay thank you it's done
and i removed the command from my start script
Bbrody1929/1/2023
okay, let me know how that goes
Aabc2229/1/2023
Okay, i'll let you know if it works well and try to solve the preview running on my own, if it works i'll mark it as solved

thank you
Bbrody1929/1/2023
the solution to that would require merging two nixpacks.toml files together
Aabc2229/1/2023
Error:

╔══════════════════════════════════════════════════════╗

║ Host system is missing dependencies to run browsers. ║

║ Please install them with the following command: ║

║ ║

║ npx playwright install-deps ║

║ ║

║ Alternatively, use apt: ║

║ apt-get install libnss3\ ║

║ libnspr4\ ║

║ libatk1.0-0\ ║

║ libatk-bridge2.0-0\ ║

║ libcups2\ ║

║ libdrm2\ ║

║ libdbus-1-3\ ║

║ libxcb1\ ║

║ libxkbcommon0\ ║

║ libatspi2.0-0\ ║

║ libx11-6\ ║

║ libxcomposite1\ ║

║ libxdamage1\ ║

║ libxext6\ ║

║ libxfixes3\ ║

║ libxrandr2\ ║

║ libgbm1\ ║

║ libpango-1.0-0\ ║

║ libcairo2\ ║

║ libasound2 ║

║ ║

║ ❤️ Playwright Team ║

╚══════════════════════════════════════════════════════╝ Failed
btw
i didn't saw anything related to playwright during build time
is there a way to know if the nixpacks file was taken into account correctly ?
Bbrody1929/1/2023
❤️ Playwright Team
how cute
show me the build table at the top of the build logs please
Aabc2229/1/2023
yes pretty cute XD feels heartwarming to see
Aabc2229/1/2023
Aabc2229/1/2023
I believe I missed something while creating the file
Bbrody1929/1/2023
no no thats my bad, i made a typo, i have fixed it
recopy into your file
Aabc2229/1/2023
yes it's gonna run now
Aabc2229/1/2023
awesome
i see it executing the install-deps script
you talked about merging two nixpacks files together to solve it

what do you have in mind ?

I was planning on just replacing something in the "start" script in package.json, do you have a better solution ?
Bbrody1929/1/2023
I do but I'm about to go cut grass, I'll send you the new nixpacks.toml file when I'm back
Aabc2229/1/2023
Okay sure, take your time and thank you for your help, I wouldn't solve this building issue this quickly without you
Bbrody1929/1/2023
heres your new nixpacks.toml file
https://gist.github.com/brody192/3e83905dd4af8e0810cc1a5574d424ee
and then you will need to include this Caddyfile in your project too
https://github.com/brody192/vue-3-template/blob/main/Caddyfile
dont worry about that being a vue template, it uses vite so it should be all the same
Aabc2229/3/2023
Thank you for helping me !

I have a question : why do I need to use caddy as my server instead of using a native standalone node server ?

SvelteKit provide a way of generating that with building :
https://kit.svelte.dev/docs/adapter-node

Do you think using their Node Adapter way of hosting my app would have drawbacks instead of using Caddy ?
Bbrody1929/3/2023
well of course you don't need to, but caddy is gonna use sub 20mb of ram where as the node server may use around 60-70mb
do you do any ssr? if so caddy wont work anyway
Aabc2229/3/2023
Oh okay so it's just consuming less RAM

I didn't know about that !

Yes I do use some SSR, Caddy is some sort of static hosting ?

I think 60mb is okay if it's just that, since it's gonna be a RAM intensive app when some tasks are running with Playwright

I also use SvelteKit as my "server" btw, i have routes with SvelteKit, so it may not work at all with Caddy
https://caddy.community/t/help-getting-started-with-caddyserver-sveltekit-app/19346
It's talking about the "static adapter"
Bbrody1929/3/2023
yeah wont work for you, forget about the caddy stuff lol
youll want to install the node adapter and then set your start script to node build/index.js
Aabc2229/3/2023
Okay, i'll try with that

I'll notice you if it uses more RAM than expected, but that should do it
Bbrody1929/3/2023
sounds good

Looking for more? Join the community!

Recommended Posts
Nuxt 3 DeployHi, has anyone done nuxt 3 deploy yet? What do I have to set? Is there a specific setting in nuxt.co'The information you’re about to submit is not secure'I have a very simple fastAPI page that I just began hosting through github on railway. It has a textPayment shows unsuccessful even though it's notHello, I got an email today morning about last month usage (1 Aug - 1 Sep) payment shows unsuccessfDeployment issues in Spring Boot projectHello, I am a newcomer using the Hobby Plan. My project is built on the Spring Boot platform and runBackup DatabaseHi, is it possible to perform or schedule database backups on railway? If so, could you explain howIssuing TLS certificate ongoing for 4 days nowHey folks, I've added a CNAME dns on my domain on Monday, and then it changed the status on the railfrontend web app making requests to wrong endpointOn my frontend web app I have a env variable configured to be the endpoint of my application but wheI have run graphql api for railway, I want to know how I can add custom domain by using this api.from the graph ql api, I can query project info and add plugins to project. But I do not know how toIs there an easy way to pause a project?Hello, we have a secondary development environment that we need for testing every once in a while. Ideployed flowise bot, no url generatedI have deployed a flowise bot and I have a hobby tier on railway. The issue is that after the deployDoes anyone know how to enable mongoDB drivers in a php/laravel project?Y tried to added with this command in the env tab NIXPACKS_PKGS=php81Extensions.mongodb But it stillInstalling php-gd extensionIs there a way for me to use Nixpacks to install php-gd in the setup stage of the build process. Or bind [::1]:5433: Cannot assign requested addressI'm trying to use an SSH tunnel and need to bind to my local port 5433 but keep getting this error. charged for hobby plan ?I have been charged 5 dollars for the hobby plan whilst my usage was below it and every month i had Custom Domain - Waiting for DNS updateI have deployed an app on Railway and set up a custom domain. I've tried to get the custom domain tDeployment has crashed with FileNotFoundError: [Errno 2]Hi. I am have problem with my JSON file. I try to deploy my flask chatbot project the have function nocodb - update failedHi I am testing the railway nocodb hosting, I was informed by the nocodb that there is an update thaDoes waived hobby plan fee expire?I am on hobby plan (previously developer) and I have the hobby plan waived. I would like to confirm Deployment issues in Golang projectProject id : 4e543459-a744-4198-970b-be420281426a I am trying to deploy a go lang application, it's Using a custom domain with cloudflarehi! I'm ready to deploy my project to my domain, and now railway has detected my cname record, but i