Giter VIP home page Giter VIP logo

Comments (13)

kentcdodds avatar kentcdodds commented on April 28, 2024 1

It's so you can import things using the ~ feature common to most Remix app setups.

from blues-stack.

graysonhicks avatar graysonhicks commented on April 28, 2024 1

For now I am getting around it this way:

  1. create a tsconfig.seed.json for compiling the prisma/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/*"]
      }
    }
  }
  1. Add this script to my package.json:
    "seed:build": "tsc --project ./tsconfig.seed.json && tsc-alias -p ./tsconfig.seed.json"

  2. Run the script to generated a compiled JS seed file at the seed-dist/seed.js path.

  3. Commit and deploy.

  4. After deploy fly ssh to the app, and run node 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.

mcansh avatar mcansh commented on April 28, 2024

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.

zabirauf avatar zabirauf commented on April 28, 2024

@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.

github-actions avatar github-actions commented on April 28, 2024

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.

graysonhicks avatar graysonhicks commented on April 28, 2024

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.

MichaelDeBoey avatar MichaelDeBoey commented on April 28, 2024

@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.

rubys avatar rubys commented on April 28, 2024

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.

MichaelDeBoey avatar MichaelDeBoey commented on April 28, 2024

@kentcdodds Can you remember why --require tsconfig-paths/register was added to the seed script in the first place?

from blues-stack.

MichaelDeBoey avatar MichaelDeBoey commented on April 28, 2024

@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.

rubys avatar rubys commented on April 28, 2024

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.

MichaelDeBoey avatar MichaelDeBoey commented on April 28, 2024

@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.

rubys avatar rubys commented on April 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.