My docker image build is successful locally but fails in railway

theomjonesHOBBY

a year ago

As title really, the build passes in Docker MacOS locally but fails because of a typescript error in Railway. Doesn't make a huge amount of sense as it's the exact Dockerfile in both of course.

Do you guys have any idea?

Cheers,
Theo

View Deploy details

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

3 Replies

a year ago

Please share the specific error.


dobatovkinHOBBY

a year ago

There could be a chance you've installed TypeScript globally on your machine and it is missing from project's dependencies


theomjonesHOBBY

a year ago

Please share the specific error.

Not sure the error is particularly useful but here it is:

> [build 5/5] RUN npm run build:

5.090 src/layouts/main.astro:3:20 - error ts(2307): Cannot find module '../components/footer.astro' or its corresponding type declarations.

5.090

5.090 3 import Footer from '../components/footer.astro';

It's an error in the astro build, but what I don't understand is running the build with Docker locally is fine, but when I push and the image gets built in Railway it fails.

There could be a chance you've installed TypeScript globally on your machine and it is missing from project's dependencies

Here's the dockerfile for reference. TS is not installed globally

FROM node:20-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

FROM caddy:alpine AS runtime
COPY ./Caddyfile /etc/caddy/Caddyfile
COPY --from=build /app/dist /srv

My docker image build is successful locally but fails in railway - Railway Help Station