Docker Build Failing but Succeeds Locally

larnonHOBBY

3 months ago

My app seems to be failing at building with the provided Dockerfile. But when I build the image locally it builds just fine and also runs fine. I have already tried "docker builder prune" and also tried building the image with --no-cache flag. What could be the issue? I can also provide the Dockerfile and build logs. Thank you.

Awaiting User Response

8 Replies

3 months ago

Hello larron,

Thank you for reaching out. To better understand the issue, could you please provide the Dockerfile and build logs? This will help us investigate the problem and provide a solution.


Status changed to Awaiting User Response railway[bot] 3 months ago


angelo

Hello larron,Thank you for reaching out. To better understand the issue, could you please provide the Dockerfile and build logs? This will help us investigate the problem and provide a solution.

larnonHOBBY

3 months ago

> boragultekin-dev@0.1.0 build

> next build

▲ Next.js 15.0.4

Creating an optimized production build ...

⨯ Failed to find font override values for font Geist

⨯ Failed to find font override values for font Geist Mono

⨯ Failed to find font override values for font Geist

⨯ Failed to find font override values for font Geist Mono

⨯ Failed to find font override values for font Geist

⨯ Failed to find font override values for font Geist Mono

⨯ Failed to find font override values for font Geist

⨯ Failed to find font override values for font Geist Mono

✓ Compiled successfully

Linting and checking validity of types ...

Collecting page data ...

2025-03-13T00:16:59.813Z ERROR [Better Auth]: You are using the default secret. Please set BETTER_AUTH_SECRET in your environment variables or pass secret in your auth config.

Generating static pages (0/8) ...

Error occurred prerendering page "/db-test". Read more: https://nextjs.org/docs/messages/prerender-error

SqliteError: no such table: fakePerson

at Database.prepare (/app/node_modules/better-sqlite3/lib/methods/wrappers.js:5:21)

at a.executeQuery (/app/.next/server/chunks/869.js:1:995)

at /app/.next/server/chunks/869.js:1:140869

at eq.provideConnection (/app/.next/server/chunks/869.js:1:32515)

at async eT.executeQuery (/app/.next/server/chunks/869.js:1:140816)

at async T.execute (/app/.next/server/chunks/869.js:1:92827)

at async p (/app/.next/server/app/db-test/page.js:1:3687)

Export encountered an error on /db-test/page: /db-test, exiting the build.

⨯ Static worker exited with code: 1 and signal: null

Attachments


Status changed to Awaiting Railway Response railway[bot] 3 months ago


3 months ago

So the error is that it can't connect to sqlLite: SqliteError: no such table: fakePerson

You will need to host that on Railway and provide a connection to your DB.


Status changed to Awaiting User Response railway[bot] 3 months ago


larnonHOBBY

3 months ago

Yes but it definitely has the database inside the app files and it definitely has the table as well. That is why the build of the image does not fail when I do it locally and the container runs perfectly fine. But when the image is built on your end it can't find the table. Maybe something to do with docker caching layers on your end?


Status changed to Awaiting Railway Response railway[bot] 3 months ago


larnonHOBBY

3 months ago

Additionally, I uploaded my locally built docker image to docker hub and deployed it from there on Railway using the docker image and it also works perfectly fine. Just as a demonstration you can look at this link to see there truly is a fakePerson table in the sqlite database that is supposedly be inside the docker container: "https://larnon-production.up.railway.app/db-test"


3 months ago

Yea, but we don't have the state of your Sqllite unless it's built- hence the error.


Status changed to Awaiting User Response railway[bot] 3 months ago


larnonHOBBY

3 months ago

Sorry If my lack of knowledge in the matter is the issue, I am just trying to understand the difference here. The Sqlite database is inside the GitHub repo, where the Dockerfile is also located, and Railway is building the container from the repo directly. So the database is copied into the image as it is stated in the Dockerfile while its being built. This is also why it works when I build the image myself, push it to the dockerhub and create a service using that docker image directly. But for some reason, when Railway is building the image, the table is not included. So only the only reason I am able to come up with is that somehow the state of the sqlite is cached with an older version on your end.


Status changed to Awaiting Railway Response railway[bot] 3 months ago


3 months ago

The path you are trying to access the sqlite database file at is likely wrong, the correct path should be ./data/database.sqlite3

But either way, you should be storing the database in a volume and not access it at build time.


Status changed to Awaiting User Response railway[bot] 3 months ago


Docker Build Failing but Succeeds Locally - Railway Help Station