html site deployment fails
godsreal
HOBBYOP

2 months ago

A plain html, css and js site keeps deploying forever and eventually fails.

Solved$10 Bounty

Pinned Solution

zuneec
HOBBY

2 months ago

It seems a lot indeed. If you want to go the easy win way, then try to create a new project and deploy the nginx there.
I tried to run it myself to see if I would have the same issue, and everything deployed successfully for me. If by any chance the problem is still actual, try to deploy straight from the repo (if you haven't done that already).

Maybe, just maybe the issue may have happened because Railway had some minor outages 3 days ago, which are listed in here https://status.railway.com/.

eg, experienced deployment issues about 10 hours ago, updated the env variables, and it was infinitely deploying, so to speak, and the status report explains it.

13 Replies

Railway
BOT

2 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


godsreal
HOBBYOP

2 months ago

an nginx static site


Can you share build and/or deployment logs?


godsreal
HOBBYOP

2 months ago

only build logs. there was no deploy logs

Attachments


Can you share your Dockerfile


godsreal
HOBBYOP

2 months ago

okay

Attachments


drelo
HOBBY

2 months ago

did you specify port via env variable? I believe nginx default is 80

EDIT: deploy will not be seen as complete until a successful bind on port is made


godsreal
HOBBYOP

2 months ago

yes port 80 is set in env variable.

This is not my first deploy to that project. Previous deploys have always been successful. I think it's something from railway.


zuneec
HOBBY

2 months ago

i would agree that port is the issue but just port 80 would not be enough...

Railway injects a PORT environment variable that your app must listen on. The default nginx:alpine image listens on port 80, but Railway expects it to listen on the dynamic $PORT.

When nginx ignores the PORT variable and listens on 80 instead, Railway's health checks fail, and the container gets killed before producing any logs.

The fix would be that you need to configure nginx to use the $PORT environment variable.

Here's what may work for you:

1. Create nginx.conf:

server {

listen $PORT;

server_name _;

location / {

root /usr/share/nginx/html;

index index.html;

try_files $uri $uri/ /index.html;

}

}

2. Update your Dockerfile:

FROM nginx:alpine

# Copy custom nginx config

COPY nginx.conf /etc/nginx/templates/default.conf.template

# Copy site files

COPY site /usr/share/nginx/html

# Expose the port (documentation only)

EXPOSE 8080

# nginx:alpine automatically substitutes env vars in .template files

CMD ["nginx", "-g", "daemon off;"]

The nginx:alpine image has built-in support for environment variable substitution in files ending with .template in /etc/nginx/templates/.

project/

/---- Dockerfile

/---- nginx.conf

TL;DR

The application inside the container must listen on the port specified by the $PORT environment variable that Railway injects. EXPOSE in the Dockerfile is optional documentation and doesn't affect functionality (but it gives a good overview of what port you're planning to use). Currently, your Dockerfile does not configure nginx to listen on the correct port, and that's where the .conf comes in.

hope it helps.


zuneec

i would agree that port is the issue but just port 80 would not be enough...Railway injects a PORT environment variable that your app must listen on. The default nginx:alpine image listens on port 80, but Railway expects it to listen on the dynamic $PORT.When nginx ignores the PORT variable and listens on 80 instead, Railway's health checks fail, and the container gets killed before producing any logs.The fix would be that you need to configure nginx to use the $PORT environment variable.Here's what may work for you:1. Create nginx.conf:server {listen $PORT;server_name _;location / {root /usr/share/nginx/html;index index.html;try_files $uri $uri/ /index.html;}}2. Update your Dockerfile:FROM nginx:alpine# Copy custom nginx configCOPY nginx.conf /etc/nginx/templates/default.conf.template# Copy site filesCOPY site /usr/share/nginx/html# Expose the port (documentation only)EXPOSE 8080# nginx:alpine automatically substitutes env vars in .template filesCMD ["nginx", "-g", "daemon off;"]The nginx:alpine image has built-in support for environment variable substitution in files ending with .template in /etc/nginx/templates/.project//---- Dockerfile/---- nginx.confTL;DRThe application inside the container must listen on the port specified by the $PORT environment variable that Railway injects. EXPOSE in the Dockerfile is optional documentation and doesn't affect functionality (but it gives a good overview of what port you're planning to use). Currently, your Dockerfile does not configure nginx to listen on the correct port, and that's where the .conf comes in.hope it helps.

zuneec
HOBBY

2 months ago

.


godsreal
HOBBYOP

2 months ago

Hi, thank you, but this seems like a whole extra. Didn't do all this for my previous deploys to the same project that worked.

https://github.com/railwayapp-templates/nginx
I'm actually using the railway template. It has always worked, except now. Something changed from railway's end.


godsreal

Hi, thank you, but this seems like a whole extra. Didn't do all this for my previous deploys to the same project that worked.https://github.com/railwayapp-templates/nginxI'm actually using the railway template. It has always worked, except now. Something changed from railway's end.

zuneec
HOBBY

2 months ago

It seems a lot indeed. If you want to go the easy win way, then try to create a new project and deploy the nginx there.
I tried to run it myself to see if I would have the same issue, and everything deployed successfully for me. If by any chance the problem is still actual, try to deploy straight from the repo (if you haven't done that already).

Maybe, just maybe the issue may have happened because Railway had some minor outages 3 days ago, which are listed in here https://status.railway.com/.

eg, experienced deployment issues about 10 hours ago, updated the env variables, and it was infinitely deploying, so to speak, and the status report explains it.


godsreal
HOBBYOP

2 months ago

You're right. I just retried it and it worked. It seems to be a railway downtime. Thanks


Status changed to Solved brody about 2 months ago


Loading...