blitz-js / blitz-js/legacy-framework
Railway deployment failed after updating to latest version of blitz
- Dominant language
- JavaScript
- Stars
- 3
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
### What is the problem?
Deployment on Railway failed because cannot find environment variable DATABASE_URL.
I am deploying using Dockerfile and the error occurs when running **blitz build**
Found a workaround by adding ARG DATABASE_URL to my Dockerfile
### Paste all your error logs here:
```
app/node_modules/@prisma/client/runtime/index.js:36166
throw new PrismaClientInitializationError(error2.message, this.config.clientVersion, error2.error_code);
^
PrismaClientInitializationError: error: Environment variable not found: DATABASE_URL.
--> schema.prisma:6
|
5 | provider = "postgres"
6 | url = env("DATABASE_URL")
|
Validation Error Count: 1
at Object.loadEngine (/app/node_modules/@prisma/client/runtime/index.js:36166:19)
at async Object.instantiateLibrary (/app/node_modules/@prisma/client/runtime/index.js:36095:5) {
clientVersion: '3.6.0',
errorCode: 'P1012'
}
```
### Paste all relevant code snippets here:
**Dockerfile before upgrading blitz ( worked previously )**
```
# Install dependencies only when needed
FROM node:15 AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
# Rebuild the source code only when needed
FROM node:15 AS builder
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
RUN yarn prisma generate
RUN yarn build && yarn install --production --ignore-scripts --prefer-offline
EXPOSE 3000
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry.
# ENV NEXT_TELEMETRY_DISABLED 1
CMD ["yarn", "start:prod"]
```
**Package.json before upgrading blitz ( worked previously )**
```
{
"name": "myapp",
"version": "1.0.0",
"scripts": {
"dev": "blitz dev",
"build": "blitz build",
"start": "blitz start",
"start:prod": "prisma migrate deploy && blitz start",
"studio": "blitz prisma studio",
"lint": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx .",
"test": "jest",
"test:watch": "jest --watch",
"prepare": "husky install"
},
"prisma": {
"schema": "db/schema.prisma"
},
"prettier": {
"semi": false,
"printWidth": 100
},
"lint-staged": {
"*.{js,ts,tsx}": [
"eslint --fix"
]
},
"dependencies": {
"@headlessui/react": "1.4.0",
"@heroicons/react": "1.0.3",
"@prisma/client": "2.29.0",
"@tailwindcss/forms": "0.3.3",
"@tailwindcss/line-clamp": "0.2.1",
"@types/preview-email": "2.0.1",
"node-mailjet": "3.3.4",
"passport-auth0": "1.4.0",
"preview-email": "3.0.4",
"prisma": "2.29.0",
"react": "alpha",
"react-dom": "alpha",
"react-final-form": "6.5.3",
"tailwindcss": "2.2.7",
"typescript": "4.3.5",
"zod": "3.7.1"
},
"devDependencies": {
"@types/react": "17.0.17",
"autoprefixer": "10.3.1",
"eslint": "7.32.0",
"husky": "7.0.1",
"lint-staged": "11.1.2",
"postcss": "8.3.6",
"prettier": "2.3.2",
"prettier-plugin-prisma": "2.29.0",
"pretty-quick": "3.1.1"
},
"private": true
}
```
**New package.json**
```
{
"name": "myapp",
"version": "1.0.0",
"scripts": {
"dev": "blitz dev",
"build": "APP_ENV=production blitz build",
"start": "blitz start",
"start:prod": "prisma migrate deploy && blitz start",
"studio": "blitz prisma studio",
"lint": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx .",
"test": "jest",
"test:watch": "jest --watch",
"prepare": "husky install"
},
"prisma": {
"schema": "db/schema.prisma"
},
"prettier": {
"semi": false,
"printWidth": 100
},
"lint-staged": {
"*.{js,ts,tsx}": [
"eslint --fix"
]
},
"dependencies": {
"@headlessui/react": "1.4.2",
"@heroicons/react": "1.0.5",
"@prisma/client": "3.6.0",
"@tailwindcss/forms": "0.3.4",
"@tailwindcss/line-clamp": "0.2.2",
"blitz": "0.44.3",
"cors": "2.8.5",
"final-form": "4.20.6",
"lodash": "4.17.21",
"moment": "2.29.1",
"node-mailjet": "3.3.4",
"react": "18.0.0-beta-149b420f6-20211119",
"react-dom": "18.0.0-alpha-5ca4b0433-20211020",
"react-final-form": "6.5.7",
"tailwindcss": "2.2.19",
"zod": "3.11.6"
},
"devDependencies": {
"@types/preview-email": "2.0.1",
"@types/react": "17.0.37",
"eslint": "7.32.0",
"husky": "7.0.4",
"lint-staged": "11.3.0-beta.2",
"prettier": "2.5.1",
"prettier-plugin-prisma": "3.6.0",
"pretty-quick": "3.1.2",
"preview-email": "3.0.5",
"prisma": "3.6.0",
"typescript": "~4.5"
},
"private": true
}
```
### What are detailed steps to reproduce this?
1. Upgrade blitz to new version using guides from https://github.com/blitz-js/blitz/discussions/992
2. Deploy to railway using `railway up`
### Run `blitz -v` and paste the output here:
```
Loaded env from /Users/christianto/Project/myapp/.env.local
Loaded env from /Users/christianto/Project/myapp/.env
macOS Monterey | darwin-x64 | Node: v16.13.0
blitz: 0.44.3 (global)
blitz: 0.44.3 (local)
Package manager: yarn
System:
OS: macOS 12.0.1
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Memory: 215.02 MB / 8.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
Yarn: 1.22.5 - /usr/local/bin/yarn
npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
Watchman: Not Found
npmPackages:
@prisma/client: 3.6.0 => 3.6.0
blitz: 0.44.3 => 0.44.3
prisma: 3.6.0 => 3.6.0
react: 18.0.0-beta-149b420f6-20211119 => 18.0.0-beta-149b420f6-20211119
react-dom: 18.0.0-alpha-5ca4b0433-20211020 => 18.0.0-alpha-5ca4b0433-20211020
typescript: ~4.5 => 4.5.2
```
### Please include below any other applicable logs and screenshots that show your problem:
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.