Problems deploying react application
noium
PROOP

a year ago

I have an isolated monorepo architecture however the frontend application in build process needs backend, so setting root directory doesn't work. So I added build and start commands where we cd into directory and then run npm run build and npm run start at first there was a problem that npm was not found, now after upgrading to pro npm is found but it uses vite build and vite is not found... :D I use default dockerfile provided by railway. Any ideas? I could create my own dockerfile, but as I understood you provide some optimizations that would be useful to have

View Deploy details

ⓘ Deployment information is only viewable by project members and Railway employees.

Solved

5 Replies

a year ago

Hello,

Using cd is a sign of an non-standard architecture or improper configuration, in this case, the first option.

Since this is a non-standard project setup, I would recommend writing a Dockerfile like you mentioned, Nixpacks doesn't do anything super special that you couldn't do in a Dockerfile.

Best,

Brody


Status changed to Awaiting User Response Railway about 1 year ago


brody

Hello, Using `cd` is a sign of an non-standard architecture or improper configuration, in this case, the first option. Since this is a non-standard project setup, I would recommend writing a Dockerfile like you mentioned, Nixpacks doesn't do anything super special that you couldn't do in a Dockerfile. Best, Brody

noium
PROOP

a year ago

Ok now that a huge WTF. I added my dockerfile and custom build and start command, however they're still being run with Nixpacks and my command for build is being run inside the dockerfile?

context: 2163d744f58d8940ab2964e620a05b6c

Mar 02 08:51:45

╔══════════════════ Nixpacks v1.31.0 ═════════════════╗

Mar 02 08:51:45

║ setup │ nodejs_18, npm-9_x ║

Mar 02 08:51:45

║─────────────────────────────────────────────────────║

Mar 02 08:51:45

║ build │ docker build -f frontend/Dockerfile . ║

Mar 02 08:51:45

║─────────────────────────────────────────────────────║

Mar 02 08:51:45

║ start │ docker run -d -p 80:80 frontend:latest ║

Mar 02 08:51:45

╚═════════════════════════════════════════════════════╝

Mar 02 08:51:45

[internal] load build definition from Dockerfile

Mar 02 08:51:45

[internal] load build definition from Dockerfile 0ms

Mar 02 08:51:45

[internal] load build definition from Dockerfile

Mar 02 08:51:45

[internal] load build definition from Dockerfile 10ms

Mar 02 08:51:45

[internal] load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1736208272

Mar 02 08:51:45

[internal] load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1736208272 154ms

Mar 02 08:51:45

[internal] load .dockerignore

Mar 02 08:51:45

[internal] load .dockerignore 0ms

Mar 02 08:51:45

[internal] load .dockerignore

Mar 02 08:51:45

[internal] load .dockerignore 13ms

Mar 02 08:51:45

[stage-0 9/9] COPY . /app

Mar 02 08:51:45

[internal] load build context 1ms

Mar 02 08:51:45

[internal] load build context

Mar 02 08:51:45

[internal] load build context 50ms

Mar 02 08:51:45

[stage-0 4/10] RUN nix-env -if .nixpacks/nixpkgs-5624e1334b26ddc18da37e132b6fa8e93b481468.nix && nix-collect-garbage -d 0ms – CACHED

Mar 02 08:51:45

[stage-0 3/9] COPY .nixpacks/nixpkgs-5624e1334b26ddc18da37e132b6fa8e93b481468.nix .nixpacks/nixpkgs-5624e1334b26ddc18da37e132b6fa8e93b481468.nix 0ms – CACHED

Mar 02 08:51:45

[stage-0 4/9] RUN nix-env -if .nixpacks/nixpkgs-5624e1334b26ddc18da37e132b6fa8e93b481468.nix && nix-collect-garbage -d 0ms – CACHED

Mar 02 08:51:45

[stage-0 5/9] COPY . /app/.

Mar 02 08:51:45

[stage-0 5/9] COPY . /app/. 144ms

Mar 02 08:51:45

[stage-0 6/9] COPY . /app/.

Mar 02 08:51:45

[stage-0 6/9] COPY . /app/. 51ms

Mar 02 08:51:45

[stage-0 7/9] RUN --mount=type=cache,id=s/7629f7ed-9ce8-4ae3-ba7a-720200c7b488-node_modules/cache,target=/app/node_modules/.cache docker build -f frontend/Dockerfile .

Mar 02 08:51:46

/bin/bash: line 1: docker: command not found

Mar 02 08:51:46

✕ [stage-0 7/9] RUN --mount=type=cache,id=s/7629f7ed-9ce8-4ae3-ba7a-720200c7b488-node_modules/cache,target=/app/node_modules/.cache docker build -f frontend/Dockerfile .

process "/bin/bash -ol pipefail -c docker build -f frontend/Dockerfile ." did not complete successfully: exit code: 127

Mar 02 08:51:46

Dockerfile:23

Mar 02 08:51:46

-------------------

Mar 02 08:51:46

21 | # build phase

Mar 02 08:51:46

22 | COPY . /app/.

Mar 02 08:51:46

23 | >>> RUN --mount=type=cache,id=s/7629f7ed-9ce8-4ae3-ba7a-720200c7b488-node_modules/cache,target=/app/node_modules/.cache docker build -f frontend/Dockerfile .

Mar 02 08:51:46

24 |

Mar 02 08:51:46

25 |

Mar 02 08:51:46

-------------------

Mar 02 08:51:46

ERROR: failed to solve: process "/bin/bash -ol pipefail -c docker build -f frontend/Dockerfile ." did not complete successfully: exit code: 127

Mar 02 08:51:46

Error: Docker build failed

What do we do about this? How do I use custom dockerfile? This file is not in root folder btw, it's in frontend folder


Status changed to Awaiting Railway Response Railway about 1 year ago


a year ago

Hello,

We do not support running docker commands, please remove those build and start commands.

Then you would want to add a variable -

RAILWAY_DOCKERFILE_PATH=/frontend/Dockerfile

https://docs.railway.com/guides/dockerfiles#custom-dockerfile-path

Best,

Brody


Status changed to Awaiting User Response Railway about 1 year ago


noium
PROOP

a year ago

Thank you, including dockerfile and configuring nginx to included your provided port worked


Status changed to Awaiting Railway Response Railway about 1 year ago


a year ago

Awsome!


Status changed to Awaiting User Response Railway about 1 year ago


Railway
BOT

9 months ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway 10 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...