#Build with node then serve static files in `dist`

59 messages · Page 1 of 1 (latest)

uncut jolt
#

I am trying to deploy a somewhat older project made in Vue2 where I produce a static version (found in the dist folder). How should I setup deployment to use the yarn run build command in the build step and then simply serve the contents of the dist directory upon deployment?

The app builds fine with the Nixpacks builder if I set my node version to 14 but it then tries to run the project with node when this is not needed because there is no SSR (also, serving the project doesn't seem to work for me). I simply need the pre-built output to be served which would be much more efficient than running node.

Thanks

uncut jolt
#

I tried the following according to https://nixpacks.com/docs/providers/staticfile :

  • Removed the NIXPACKS_START_CMD env var
  • Added the NIXPACKS_BUILD_CMD env var set to yarn build
  • Removed the start command from the settings tab

I was expecting this to produce a nginx hosted build form the dist folder but apparently it doesn't. I just get a server error when trying to visit the generated domain.
Deploy logs show a single line:
/bin/bash: -c: option requires an argument

uncut jolt
spiral kite
#

@uncut jolt please share your build logs

hasty osprey
#

/bin/bash: -c: option requires an argument
that means a start command wsant foudn

uncut jolt
spiral kite
#

I think they are starting their app in build time

spiral kite
uncut jolt
spiral kite
#

was saying that based on it took 11+ minutes for building

uncut jolt
#

but everything seems to be kinda down now. I get random errors each time

#

failed to dial gRPC: cannot connect to the Docker daemon. Is 'docker daemon' running on this host?: dial unix /var/run/docker.sock: connect: connection refused

spiral kite
#

yeah, so i think you were trying to start your app in build time

#

Please share your build logs.

uncut jolt
#

==============
Using Nixpacks

╔══════════════ Nixpacks v0.4.0 ══════════════╗
║ Setup │ nodejs-14_x, yarn-1_x ║
║─────────────────────────────────────────────║
║ Install │ yarn install --frozen-lockfile ║
║─────────────────────────────────────────────║
║ Build │ yarn run build ║
║─────────────────────────────────────────────║
║ Start │ nginx ║
╚═════════════════════════════════════════════╝

failed to dial gRPC: cannot connect to the Docker daemon. Is 'docker daemon' running on this host?: dial unix /var/run/docker.sock: connect: connection refused

Error: Docker build failed

#

latest logs

spiral kite
#

uh oh

#

please share your project id

uncut jolt
#

62756a8a-33cb-4b21-9987-edb6b82bf724

spiral kite
#

Try redeploying

uncut jolt
#

haven't found a button to manually redeploy

hasty osprey
#

or change env variable

uncut jolt
#

seems hacky

hasty osprey
#

add a dummy env variable

#

yea

uncut jolt
#

a button would be nice

#

launched now let's see

#

you can see my build command is correct in the logs above, i'm not running the app in build

#

same result as before: docker is not running somehow

hasty osprey
#

#🚨|incidents

#

thanks for reporting

uncut jolt
#

Anyway this just got in the way of my initial question: how can i start nginx serving the "dist" folder?

#

is my start command above correct? nginx

hasty osprey
#

this is where multi-staging phases would be good

#

could use node provider to build, and then Staticfile to server

spiral kite
uncut jolt
hasty osprey
#

it's not. only one provider is chosen by default

uncut jolt
#

huh okay.. netlify has this by default that's why i thought surely it must be an option

uncut jolt
#

is it secure for production?

spiral kite
spiral kite
uncut jolt
#

anyway i'll give it a go after the outage is resolved

uncut jolt
#
#11 [stage-0 7/9] RUN --mount=type=cache,id=s/562ff758-43c4-41bd-8807-06c2af9d6022-/usr/local/share/cache/yarn/v6,target=/usr/local/share/.cache/yarn/v6 yarn install --frozen-lockfile
#11 sha256:35c0d33559a985337a4662bd60b44160f4f0da78b7863f7d4432c20f26a31cbe
 
#11 0.647 yarn install v1.22.19
#11 0.667 info No lockfile found.
#11 0.672 [1/4] Resolving packages...
#11 0.673 [2/4] Fetching packages...
#11 0.674 [3/4] Linking dependencies...
#11 0.680 [4/4] Building fresh packages...
#11 0.685 Done in 0.06s.
 
#11 DONE 0.8s
 
#12 [stage-0 8/9] COPY . /app/
#12 sha256:2a8af086a418d50916f73915257a41cacaccb843e915871f84a0b9fcf47b1d94
 
#12 DONE 0.7s
 
#13 [stage-0 9/9] RUN --mount=type=cache,id=s/562ff758-43c4-41bd-8807-06c2af9d6022-node_modules/cache,target=node_modules/.cache yarn run build
#13 sha256:1dd557b38595b708f371a7e4a9746de9797879e9efc0c7be327750627a820aaf
 
#13 0.605 yarn run v1.22.19
 
#13 0.637 error Couldn't find a package.json file in "/app"
uncut jolt
# spiral kite Yup

obviously there is a package.json in my repo, and it was building fine before

spiral kite
#

#11 0.667 info No lockfile found. & It's using yarn 🤔

uncut jolt
spiral kite
#

Ah, cool

uncut jolt
#

gotta hit the hay but i'll try again tomorrow

spiral kite
#

@uncut jolt There was a bit of issue internally, It's fixed now!

#

Very sorry that railway wasn't able to deliver the magical experience you'd have wanted 😦

uncut jolt