9 months ago
I'm getting an error when my Astro app tries to build and deploy after a GitHub commit. It was working fine yesterday.
I've not changed anything in Railway, nor in my Dockerfile. The latest commits are minimal changes. So I'm not sure where to look or what to try next.
The log is:
Dockerfile:15
13 |
14 | # Build your application.
15 | >>> RUN npm run build
16 |
17 | # Set environment variables and expose the appropriate port.
ERROR: failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1
ⓘ Deployment information is only viewable by project members and Railway employees.
8 Replies
9 months ago
Here's my Dockerfile:
FROM node:lts-slim as runtime WORKDIR /app # Ensure that both node_modules and package-lock.json are removed. COPY package.json . RUN rm -rf node_modules package-lock.json # Perform a fresh installation of npm dependencies. RUN npm install # Copy the rest of your application files. COPY . . # Build your application. RUN npm run build # Set environment variables and expose the appropriate port. ENV HOST=0.0.0.0 ENV PORT=4321 EXPOSE 4321 # Define the command to run your application. CMD node ./dist/server/entry.mjs
9 months ago
Full build logs please - https://bookmarklets.up.railway.app/log-downloader/
RUN rm -rf node_modules package-lock.json
You should not need this line, do not commit your node_modules folder to GitHub and you don't want to delete the package-lock file.
RUN npm install
This should be `RUN npm ci`
ENV PORT=4321
EXPOSE 4321
You don't need / want these lines and its done automatically for you.
9 months ago
I updated my Dockerfile as suggested, but I'm still getting the same build error.
Dockerfile:
FROM node:lts-slim as runtime
WORKDIR /app
COPY . .
RUN npm ci
RUN npm run build
ENV HOST=0.0.0.0
ENV PORT=4321
EXPOSE 4321
CMD node ./dist/server/entry.mjs
.dockerignore:
.DS_Store
node_modules
dist
.env
.git
.gitignore
Error:
Dockerfile:7
Jul 17 17:41:57
-------------------
Jul 17 17:41:57
5 |
Jul 17 17:41:57
6 | RUN npm ci
Jul 17 17:41:57
7 | >>> RUN npm run build
Jul 17 17:41:57
8 |
Jul 17 17:41:57
9 | ENV HOST=0.0.0.0
Jul 17 17:41:57
-------------------
Jul 17 17:41:57
ERROR: failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1
9 months ago
Ah ha. It looks like I've got something wrong in how I'm handling missing data in pocketbase, which then causes the pre-rendering to fail, which then fails the whole build.
Classic error of it works fine in local so didn't even think to check it.
Thanks for the help
9 months ago
Just in case someone else ends up here in the future - my issue was caused by trying to mix SSR and SSG in Astro.
I solved it by changing my content collection to SSR (https://docs.astro.build/en/guides/content-collections/#building-for-server-output-ssr) which then meant my component calling pocketbase data works, which then means Railway builds.
Status changed to Solved brody • 9 months ago