#Struggling to deploy to Digital Ocean VPS with Dockerfile ( and dokku )

1 messages · Page 1 of 1 (latest)

final edge
#

some background: Im using postgres 14 as database, and have a DATABASE_URL ENV variable that holds the postgres database connection string.

wanton lagoon
#

do you have dotenv installed and are you calling dotenv.config() in your entry?

final edge
#

Im using an .env with the DATABASE_URL i somehow think the DATABASE_URL value is not available and causing this error.

#

Using this dockerfile: ```FROM node:18-bullseye-slim

ARG DATABASE_URL="postgres://postgres:x@dokku-postgres-lubricate-db:5432/lubricate_db"
ENV DATABASE_URL="postgres://postgres:x@dokku-postgres-lubricate-db:5432/lubricate_db"
RUN echo "DATABASE_URL is ${DATABASE_URL}"

RUN npm install -g npm@latest

RUN mkdir /app
WORKDIR /app

COPY .npmrc package.json package-lock.json ./
RUN npm install --omit=dev
RUN echo "DATABASE_URL is ${DATABASE_URL}"

COPY . .
RUN npx prisma generate
RUN npm run build

CMD ["npm", "run", "start"]

#
=====> Start of lubricate container output (web.1)
       > start
       > cross-env NODE_ENV=production node ./server.js --port 3000
       TypeError: The "password" argument must be of type string or an instance of ArrayBuffer, Buffer, TypedArray, or DataView. Received undefined
           at check (node:internal/crypto/scrypt:89:14)
           at Object.scryptSync (node:internal/crypto/scrypt:70:13)
           at Object.<anonymous> (/app/build/index.js:798:136)
           at Module._compile (node:internal/modules/cjs/loader:1159:14)
           at Object.Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
           at Module.load (node:internal/modules/cjs/loader:1037:32)
           at Function.Module._load (node:internal/modules/cjs/loader:878:12)
           at Module.require (node:internal/modules/cjs/loader:1061:19)
           at require (node:internal/modules/cjs/helpers:103:18)
           at Object.<anonymous> (/app/server.js:40:14)
       > start
       > cross-env NODE_ENV=production node ./server.js --port 3000```
final edge
#

so I cleaned up a lot fixed some issues with package.json upgraded npm and upgraded my dockerfile to be :

#

RUN npm install -g npm@latest

RUN mkdir /app
WORKDIR /app

COPY .npmrc package.json package-lock.json ./
RUN npm install
#RUN npm install cross-env

COPY . .
RUN npx prisma generate
RUN npm run build
RUN npm install --omit=dev

CMD ls node_modules && npm run start

#CMD ["npm", "run", "start"]```
#

problem is it cannot find =====> Start of lubricate container output (web.1)

start
cross-env NODE_ENV=production node ./server.js
sh: 1: cross-env: not found

#

while it is inside my package.json like so: "dev": "cross-env NODE_ENV=development remix dev", "dev:node": "cross-env NODE_ENV=development nodemon --require dotenv/config ./server.js --watch ./server.js", "start": "cross-env NODE_ENV=production node ./server.js", "cross-env": "^7.0.3", "cross-env": "^7.0.3", in both dev and regular dependencies

#

and also it won't work when im trying to RUN npm install cross-env but i should not do that since its already inside package.json

final edge
#

im removing the the cross-env dep

final edge
#

so now it runs all the way true this error: - /app/build/index.js - /app/server.js at Function.Module._resolveFilename (node:internal/modules/cjs/loader:995:15) at Function.Module._load (node:internal/modules/cjs/loader:841:27) at Module.require (node:internal/modules/cjs/loader:1061:19) at require (node:internal/modules/cjs/helpers:103:18) at Object.<anonymous> (/app/build/index.js:409:21) at Module._compile (node:internal/modules/cjs/loader:1159:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1213:10) at Module.load (node:internal/modules/cjs/loader:1037:32) at Function.Module._load (node:internal/modules/cjs/loader:878:12) at Module.require (node:internal/modules/cjs/loader:1061:19)

#

upgraded dockerfile is: ```FROM node:18-bullseye-slim

RUN npm install -g npm@latest

RUN mkdir /app
WORKDIR /app

COPY .npmrc package.json package-lock.json ./
RUN npm install

COPY . .
RUN npx prisma generate
RUN npm run build
RUN npm install --omit=dev
ENV NODE_ENV=production

CMD ["npm", "run", "start"]```

fickle verge
#

has nothing related with the problem but "npm run start" is the same as "npm start"