Build Cannot Publish Image: Deployment Successful

Hello! I am trying to load a build up on railway. However when i try and upload my code, everything builds successfully except for this one step that states build publishing image. I am building a nextjs app with prisma. I have gotten a valid deployment before where the build publishes the image, however this is when i had a seperate server.js file that I deprecated. I changed the package.jsons to have these scripts
"scripts": {
"dev": "next dev",
"build": "CI=false react-scripts next build",
"start": "next start"
},
"scripts": {
"dev": "next dev",
"build": "CI=false react-scripts next build",
"start": "next start"
},
I also have a nixpacks.toml that looks like this
[phases.install]
commands = [
"yarn cache clean",
"yarn install --check-cache",
"npx prisma generate" # Ensure the Prisma client is generated after dependencies are installed
]

[phases.build]
commands = [
"npx prisma migrate deploy", # Apply migrations during the build process
"npx next build" # Build the Next.js application for production
]
[phases.install]
commands = [
"yarn cache clean",
"yarn install --check-cache",
"npx prisma generate" # Ensure the Prisma client is generated after dependencies are installed
]

[phases.build]
commands = [
"npx prisma migrate deploy", # Apply migrations during the build process
"npx next build" # Build the Next.js application for production
]
I have tried doing npx next build and then doing yarn start and see that my project successfully loads on localhost. However, when deploying to railway I get a this successfuly deployment with build publishing an image taking a long time. To be clear there is no actual errors inside of the build. the logs show that the build is successful and I can find no signs of errors anywhere else. Is there a step that I am somehow missing when deploying a nextjs project into railway? Any help with this would be much appreciated. If +30 minutes are actually expected for a build publishing an image, please ignore this.
No description
Solution:
is your domain pointing to the correct port?
Jump to solution
20 Replies
Percy
Percy3mo ago
Project ID: c143cb36-1764-4a8e-8676-e5c1f4a33422
ImaMoonky
ImaMoonkyOP3mo ago
c143cb36-1764-4a8e-8676-e5c1f4a33422
Brody
Brody3mo ago
besides that hanging build step, is your application working fine?
ImaMoonky
ImaMoonkyOP3mo ago
hello! Yes the application is working fine in local development. No crashes or errors.
ImaMoonky
ImaMoonkyOP3mo ago
No description
ImaMoonky
ImaMoonkyOP3mo ago
However when trying to access the url, railway gives me this page without any real way to check for errors or log.
ImaMoonky
ImaMoonkyOP3mo ago
Update: I have removed the react-scripts and now my build is successfully happening. however the application is still failing to respond. When I do yarn build and then yarn start in local development everything works. however my deploy logs are stating that it is starting on localhost:8080 which I believe should not be the case. I did a text search in visual studio code to find any mentions of localhost:8080 and nothing came up. Is there a setting in next.js that I should change? I tried setting the environmental NODE_ENV="production" and mode="production" to see if that was the issue however, this does not seem to work. Any ideas?
No description
No description
Solution
Brody
Brody3mo ago
is your domain pointing to the correct port?
ImaMoonky
ImaMoonkyOP3mo ago
sorry i am new to nextjs and railway deployment. how can i check this?
Brody
Brody3mo ago
from your service settings
ImaMoonky
ImaMoonkyOP3mo ago
No description
ImaMoonky
ImaMoonkyOP3mo ago
i see you are saying that this should be pointing to 8080 correct? i tried changing it and everything seems to be working now! Thank you so much! I feel really silly... I have been trying to get this work for awhile...
Brody
Brody3mo ago
don't feel silly, I'm currently updating the docs to mention this
ImaMoonky
ImaMoonkyOP3mo ago
sounds good! Thanks so much for your help! Is there a mark solution that i need to press for this question/thread?
Brody
Brody3mo ago
hello! we have updated our fixing common errors page to hopefully cover this issue, please give it a read when you have a chance and let me know if the docs page alone would have helped you solve you issue. https://docs.railway.app/guides/fixing-common-errors#solution
ImaMoonky
ImaMoonkyOP3mo ago
Hey Brody! I read the article and believe that these docs would have helped me solve the issue. Especially the part that specifies how to make the next framework set to a specific port. I didint know that before the fix. I just guessed that the port was running on 8080 by the deploy logs since it said deployed on localhost:8080, and changed the custom port to be 8080 on railway. If anything I would add how you can see what port your application is currently running on in nextjs, however this is a nitpick. Thanks for reaching out and asking for my opinion!
ImaMoonky
ImaMoonkyOP3mo ago
Also in the picture i would expand it to show that you are in the settings tab to access the network settings of the project. However this may be overkill since network settings would obviously be in settings. I just got confused since it was my first time interacting with railway and I didint know where to look.
No description
Brody
Brody3mo ago
what if the image was click-able and brought you to this section of our docs? - https://docs.railway.app/overview/the-basics#service-settings perhaps even the image could show a tooltip? just trying to keep the doc and the image feel less cluttered, but I thank you for your feedback!
ImaMoonky
ImaMoonkyOP3mo ago
that's actually great! I love when docs link to previous sections
Brody
Brody3mo ago
perfect, then I will make a note to implement this feedback, thanks again!
Want results from more Discord servers?
Add your server