ocluf / justship

A svelte 5 and sveltekit saas boilerplate. Including database, authentication, email, analytics, and landing page components.
https://justship.today
MIT License
406 stars 30 forks source link

Add Dockerfile #3

Closed ak4zh closed 4 months ago

ak4zh commented 5 months ago

I'm working on integrating a Dockerfile for Docker deployments. The Dockerfile I've created triggers a LibSQLError with the error URL_INVALID. It seems to be trying to establish a database connection during the build phase. Any tips on how to troubleshoot and fix this?

 => ERROR [builder 6/6] RUN npm run build                                                                                  10.5s
------                                                                                                                           
 > [builder 6/6] RUN npm run build:                                                                                              
0.660                                                                                                                            
0.660 > justshipgit@0.0.1 build                                                                                                  
0.660 > vite build                                                                                                               
0.660                                                                                                                            
0.893 ▲ [WARNING] Cannot find base config file "./.svelte-kit/tsconfig.json" [tsconfig.json]
0.893 
0.893     tsconfig.json:2:12:
0.893       2 │   "extends": "./.svelte-kit/tsconfig.json",
0.893         ╵              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0.893 
1.669 10:10:30 AM [vite-plugin-svelte] You are using Svelte 5.0.0-next.103. Svelte 5 support is experimental, breaking changes can occur in any release until this notice is removed.
1.669 work in progress:
1.669  - svelte-inspector is disabled until dev mode implements node to code mapping
1.669 
1.754 vite v5.2.8 building SSR bundle for production...
1.800 transforming...
3.215 10:10:32 AM [vite-plugin-svelte] /app/src/routes/(login)/login/+page.svelte:11:4 email_input is updated, but is not declared with $state(...). Changing its value will not correctly trigger updates.
9.470 ✓ 2153 modules transformed.
9.604 rendering chunks...
10.32 
10.32 node:internal/event_target:1062
10.32   process.nextTick(() => { throw err; });
10.32                            ^
10.33 Error [LibsqlError]: URL_INVALID: The URL is not in a valid format
10.33     at parseUri (file:///app/node_modules/@libsql/core/lib-esm/uri.js:9:15)
10.33     at expandConfig (file:///app/node_modules/@libsql/core/lib-esm/config.js:34:17)
10.33     at createClient (file:///app/node_modules/@libsql/client/lib-esm/node.js:11:26)
10.33     at file:///app/.svelte-kit/output/server/chunks/auth.js:10:16
10.33     at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
10.33     at async ModuleLoader.import (node:internal/modules/esm/loader:337:24)
10.33     at async Promise.all (index 4)
10.33     at async analyse (file:///app/node_modules/@sveltejs/kit/src/core/postbuild/analyse.js:66:16)
10.33     at async MessagePort.<anonymous> (file:///app/node_modules/@sveltejs/kit/src/utils/fork.js:22:16)
10.33 Emitted 'error' event on Worker instance at:
10.33     at [kOnErrorMessage] (node:internal/worker:314:10)
10.33     at [kOnMessage] (node:internal/worker:325:37)
10.33     at MessagePort.<anonymous> (node:internal/worker:225:57)
10.33     at [nodejs.internal.kHybridDispatch] (node:internal/event_target:786:20)
10.33     at exports.emitMessage (node:internal/per_context/messageport:23:28) {
10.33   code: 'URL_INVALID',
10.33   rawCode: undefined,
10.33   [cause]: undefined
10.33 }
10.33 
10.33 Node.js v18.20.2
------
Dockerfile:31
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json .
RUN npm i --force
COPY . .

ARG TURSO_DB_AUTH_TOKEN \
    TURSO_DB_URL \
    RESEND_API_KEY \
    RESEND_EMAIL \
    SMTP_HOST \
    SMTP_PORT \
    SMTP_SECURE \
    SMTP_USER \
    SMTP_PASS \
    PUBLIC_PROJECT_NAME \
    prod

ENV TURSO_DB_AUTH_TOKEN=$TURSO_DB_AUTH_TOKEN \
    TURSO_DB_URL=$TURSO_DB_URL \
    RESEND_API_KEY=$RESEND_API_KEY \
    RESEND_EMAIL=$RESEND_EMAIL \
    SMTP_HOST=$SMTP_HOST \
    SMTP_PORT=$SMTP_PORT \
    SMTP_SECURE=$SMTP_SECURE \
    SMTP_USER=$SMTP_USER \
    SMTP_PASS=$SMTP_PASS \
    PUBLIC_PROJECT_NAME=$PUBLIC_PROJECT_NAME \
    prod=$prod

RUN npm run build

FROM node:18-alpine
WORKDIR /app
COPY --from=builder /app/build build/
COPY --from=builder /app/node_modules node_modules/
COPY package.json .
EXPOSE 3000
ENV NODE_ENV=production
CMD [ "node", "build" ]
ocluf commented 5 months ago

What is the value for TURSO_DB_URL?

To be honest I think I'm going to switch out turso with regular sqlite.

cupcakearmy commented 4 months ago

Cannot find base config file "./.svelte-kit/tsconfig.json"

Thats is a classic one. You need to run svelte-kit sync before building in side the docker container