Comments (13)
It's so you can import things using the ~
feature common to most Remix app setups.
from blues-stack.
For now I am getting around it this way:
- create a
tsconfig.seed.json
for compiling theprisma/seed.ts
to JS
"include": ["./prisma/seed.ts"],
"compilerOptions": {
"lib": ["ES2019"],
"target": "ES2019",
"moduleResolution": "node",
"module": "CommonJS",
"esModuleInterop": true,
"resolveJsonModule": false,
"skipLibCheck": true,
"experimentalDecorators": true,
"outDir": "./seed-dist",
"baseUrl": ".",
"paths": {
"~/*": ["./app/*"]
}
}
}
-
Add this script to my
package.json
:
"seed:build": "tsc --project ./tsconfig.seed.json && tsc-alias -p ./tsconfig.seed.json"
-
Run the script to generated a compiled JS seed file at the
seed-dist/seed.js
path. -
Commit and deploy.
-
After deploy
fly ssh
to the app, and runnode myapp/seed-dist/seed.js
.
This could probably be automated, but I still consider it a workaround and not a long term solution. The reason this compilation is necessary is because trying to fly ssh
and run ts-node prisma/seed.ts
leads to OOM and other dependency errors. Hope this is helpful for anyone until the stack is updated to automate it.
from blues-stack.
prisma db seed
will automagically run when prisma does migrations https://www.prisma.io/docs/guides/database/seed-database#integrated-seeding-with-prisma-migrate
from blues-stack.
@mcansh the main issue I see is the following.
Error: Command failed with ENOENT: ts-node --require tsconfig-paths/register prisma/seed.ts
I think that seems to happen because the Dockerfile only copies the node_modules that are in production dependency while the ts-node
is in devDependencies
. I tried changing that in docker file and that fixed the issue.
FROM base
WORKDIR /myapp
COPY --from=production-deps /myapp/node_modules /myapp/node_modules
from blues-stack.
This issue has been automatically marked stale because we haven't received a response from the original author in a while 🙈. This automation helps keep the issue tracker clean from issues that are not actionable. Please reach out if you have more information for us or you think this issue shouldn't be closed! 🙂 If you don't do so within 7 days, this issue will be automatically closed.
from blues-stack.
I can confirm that Fly is not automatically seeding the DB when deploying with this stack. I've reached out to Fly support to see what can be changed. I believe the Indie Stack had a similar issue and a change was made that got it working.
from blues-stack.
@rubys and I are already collaborating on smoothing out the deploy path with Remix in superfly/flyctl#2092, which should fix all these problems normally
from blues-stack.
From my testing so far, removing --require tsconfig-paths/register
allows the seeding to proceed for at least the example provided by this stack. If, for some reason, tsconfig-paths
is really required for seeding, it should no longer be a devDependency. Either way, it is likely that some change to this stack is required in addition to the changes I'm making to fly.
from blues-stack.
@kentcdodds Can you remember why --require tsconfig-paths/register
was added to the seed script in the first place?
from blues-stack.
@kentcdodds So I guess we should move tsconfig-paths
to dependencies
then?
Although I don't think seeding is happening in production, so it's fine to have it in devDependencies
🤔
from blues-stack.
Although I don't think seeding is happening in production, so it's fine to have it in devDependencies 🤔
With fly.io, seeding is run using the same image as what will be used in production.
from blues-stack.
@rubys Should we create another build for doing so?
All tsconfig-paths
docs are referring to installing it as a dev dependency
from blues-stack.
On fly.io, build machines don't have access to secrets or postgres databases. Looking at the prisma documentation, it looks like seeds aren't applied on the first prisma migrate deploy
, and I don't see any information on the bluestack readme on how to apply seeds in production - am I just missing it?
In any case, the way it works out is that the only place where you can run your seed script on fly.io machines is on a machine that is set up for production.
from blues-stack.
Related Issues (20)
- Wrong http status code (500) returned instead of 404 or any response thrown from a loader. HOT 9
- Hydration error: Initial UI does not match server HOT 3
- New Defer API does not work with blues-stack HOT 11
- When Using Express Adapter Throwing Responses will break the app HOT 1
- great repro
- Race condition in npm run dev HOT 5
- Base Repo OOMs on Fly.io HOT 7
- Fly.io -> Error: Can't reach database server HOT 7
- `npm run typecheck` fails on fresh project HOT 7
- blues-stack 2.0.0-pre.5 - LiveReload is not working HOT 2
- v2_dev leaves one node process behind after shutdown HOT 1
- Scripts variant in README to support the Yarn inclined
- Deployment issue. Node version >18 needed
- Update server.ts to watch version.txt
- Error when trying to run the docker image HOT 3
- Latest server.js code breaks HDR HOT 1
- Some URLs in the `/build` path were 404 not found after making changes in development mode HOT 1
- Vite support
- Build failed while running npm run build on blues stack HOT 2
- Install an esm package dependency
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blues-stack.