Having huge problems trying to seed my prod Database using remix and prisma. I have tried moving my ts-node and typescript to dev dependencies - and everything on here:
If I ssh into my fly instance and run
npx prisma db seed Running seed command
ts-node prisma/seed.ts` …
An error occurred while running the seed command:
Error: Command failed with ENOENT: ts-node prisma/seed.ts
spawn ts-node ENOENT`
I install ts node and i get error where it doesnt recognise ts files - i have tried installing typescript a million times but it still never appears in my package json?
npm i -g ts-node
added 20 packages, and audited 21 packages in 2s
found 0 vulnerabilities
root@6e82539c51e387:/app# npx prisma db seed
Running seed command `ts-node prisma/seed.ts` ...
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /app/prisma/seed.ts
at new NodeError (node:internal/errors:372:5)
at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:80:11)
at defaultGetFormat (node:internal/modules/esm/get_format:122:38)
at defaultLoad (node:internal/modules/esm/load:21:20)
at ESMLoader.load (node:internal/modules/esm/loader:431:26)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:350:22)
at new ModuleJob (node:internal/modules/esm/module_job:66:26)
at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:369:17)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:328:34)
at async Promise.all (index 0) {
code: 'ERR_UNKNOWN_FILE_EXTENSION'
}
An error occurred while running the seed command:
Error: Command failed with exit code 1: ts-node prisma/seed.ts
root@6e82539c51e387:/app#
this is my package json
{
"name": "ticketc",
"private": true,
"sideEffects": false,
"type": "module",
"imports": {
"#*": "./*"
},
"scripts": {
"build": "run-s build:*",
"build:icons": "tsx ./other/build-icons.ts",
"build:remix": "remix build --sourcemap",
"build:server": "tsx ./other/build-server.ts",
"predev": "npm run build:icons --silent",
"dev": "remix dev -c \"node ./server/dev-server.js\" --manual",
"prisma:studio": "prisma studio",
"format": "prettier --write .",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"setup": "npm run build && prisma generate && prisma migrate deploy && prisma db seed && playwright install",
"start": "cross-env NODE_ENV=production node .",
"start:mocks": "cross-env NODE_ENV=production MOCKS=true tsx .",
"test": "vitest",
"coverage": "vitest run --coverage",
"test:e2e": "npm run test:e2e:dev --silent",
"test:e2e:dev": "playwright test --ui",
"pretest:e2e:run": "npm run build",
"test:e2e:run": "cross-env CI=true playwright test",
"test:e2e:install": "npx playwright install --with-deps chromium",
"typecheck": "tsc",
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run"
},
"eslintIgnore": [
"/node_modules",
"/build",
"/public/build",
"/playwright-report",
"/server-build"
],
"dependencies": {
"@conform-to/react": "^0.9.0",
"@conform-to/zod": "^0.9.0",
"@epic-web/remember": "^1.0.2",
"@epic-web/totp": "^1.1.1",
"@nasa-gcn/remix-seo": "^2.0.0",
"@paralleldrive/cuid2": "^2.2.2",
"@prisma/client": "^5.3.1",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-toast": "^1.1.5",
"@radix-ui/react-tooltip": "^1.0.7",
"@react-email/components": "^0.0.7",
"@remix-run/css-bundle": "^2.1.0",
"@remix-run/express": "^2.1.0",
"@remix-run/node": "^2.1.0",
"@remix-run/react": "^2.1.0",
"@remix-run/server-runtime": "^2.1.0",
"@sentry/remix": "^7.70.0",
"address": "^2.0.1",
"autoprefixer": "^10.4.16",
"bcryptjs": "^2.4.3",
"better-sqlite3": "^8.6.0",
"cachified": "^3.5.4",
"chalk": "^5.3.0",
"class-variance-authority": "^0.7.0",
"close-with-grace": "^1.2.0",
"clsx": "^2.0.0",
"compression": "^1.7.4",
"confetti-react": "^2.5.0",
"cross-env": "^7.0.3",
"crypto-js": "^4.1.1",
"date-fns": "^2.30.0",
"dotenv": "^16.3.1",
"eslint-plugin-remix-react-routes": "^1.0.5",
"execa": "^8.0.1",
"express": "^4.18.2",
"express-rate-limit": "^7.0.1",
"get-port": "^7.0.0",
"glob": "^10.3.7",
"helmet": "^7.0.0",
"intl-parse-accept-language": "^1.0.0",
"isbot": "^3.7.0",
"litefs-js": "^1.1.2",
"lru-cache": "^10.0.1",
"lucide-react": "0.293.0",
"morgan": "^1.10.0",
"prisma": "^5.3.1",
"qrcode": "^1.5.3",
"react": "^18.2.0",
"react-day-picker": "^8.9.1",
"react-dom": "^18.2.0",
"remix-auth": "^3.5.1",
"remix-auth-form": "^1.3.0",
"remix-auth-github": "^1.6.0",
"remix-utils": "^7.1.0",
"set-cookie-parser": "^2.6.0",
"sonner": "^1.0.3",
"source-map-support": "^0.5.21",
"spin-delay": "^1.2.0",
"tailwind-merge": "^1.14.0",
"tailwindcss": "^3.3.3",
"tailwindcss-animate": "^1.0.7",
"tailwindcss-radix": "^2.8.0",
"uuid": "9.0.1",
"xlsx": "0.18.5",
"zod": "^3.22.2"
},
"devDependencies": {
"@faker-js/faker": "^8.1.0",
"@playwright/test": "^1.38.1",
"@remix-run/dev": "^2.1.0",
"@remix-run/eslint-config": "^2.1.0",
"@remix-run/serve": "^2.1.0",
"@remix-run/testing": "^2.1.0",
"@sly-cli/sly": "^1.4.10",
"@testing-library/jest-dom": "^6.1.3",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.5.1",
"@total-typescript/ts-reset": "^0.5.1",
"@types/bcryptjs": "^2.4.4",
"@types/better-sqlite3": "^7.6.5",
"@types/compression": "^1.7.3",
"@types/cookie": "^0.5.2",
"@types/eslint": "^8.44.3",
"@types/express": "^4.17.18",
"@types/fs-extra": "^11.0.2",
"@types/glob": "^8.1.0",
"@types/morgan": "^1.9.5",
"@types/node": "^20.6.5",
"@types/qrcode": "^1.5.2",
"@types/react": "^18.2.22",
"@types/react-dom": "^18.2.7",
"@types/set-cookie-parser": "^2.4.3",
"@types/source-map-support": "^0.5.7",
"@types/uuid": "^9.0.7",
"@vitejs/plugin-react": "^4.1.0",
"@vitest/coverage-v8": "^0.34.5",
"chokidar": "^3.5.3",
"cookie": "^0.5.0",
"enforce-unique": "^1.1.1",
"esbuild": "^0.19.3",
"esbuild-register": "^3.5.0",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"fs-extra": "^11.1.1",
"jsdom": "^22.1.0",
"msw": "0.0.0-fetch.rc-20",
"node-html-parser": "^6.1.10",
"npm-run-all": "^4.1.5",
"prettier": "^3.0.3",
"prettier-plugin-sql": "^0.15.1",
"prettier-plugin-tailwindcss": "^0.5.4",
"remix-flat-routes": "^0.5.11",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"tsx": "^3.14.0",
"typescript": "^5.2.2",
"vite": "^4.4.9",
"vitest": "^0.34.5"
},
"engines": {
"node": "18"
},
"epic-stack": true,
"prisma": {
"seed": "tsx prisma/seed.js"
}
}
Docker file
# syntax = docker/dockerfile:1
# Adjust NODE_VERSION as desired
ARG NODE_VERSION=18.0
FROM node:${NODE_VERSION}-slim as base
LABEL fly_launch_runtime="Remix/Prisma"
# Remix/Prisma app lives here
WORKDIR /app
# Set production environment
ENV NODE_ENV="production"
# Throw-away build stage to reduce size of final image
FROM base as build
# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install -y build-essential openssl pkg-config python
# Install node modules
COPY --link .npmrc package-lock.json package.json ./
RUN npm ci --include=dev
# Generate Prisma Client
COPY --link prisma .
RUN npx prisma generate
# Copy application code
COPY --link . .
# Build application
RUN npm run build
# Remove development dependencies
RUN npm prune --omit=dev
# Final stage for app image
FROM base
# Install, configure litefs
COPY --from=flyio/litefs:0.4.0 /usr/local/bin/litefs /usr/local/bin/litefs
COPY --link other/litefs.yml /etc/litefs.yml
# Install packages needed for deployment and Consul
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y ca-certificates fuse3 openssl sqlite3 unzip && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives
# Install Consul
ADD https://releases.hashicorp.com/consul/1.14.1/consul_1.14.1_linux_amd64.zip /tmp/
RUN unzip /tmp/consul_1.14.1_linux_amd64.zip -d /usr/local/bin/ && \
rm /tmp/consul_1.14.1_linux_amd64.zip
# Copy built application
COPY --from=build /app /app
# Setup sqlite3 on a separate volume
RUN mkdir -p /data /litefs
VOLUME /data
# add shortcut for connecting to database CLI
RUN echo "#!/bin/sh\nset -x\nsqlite3 \$DATABASE_URL" > /usr/local/bin/database-cli && chmod +x /usr/local/bin/database-cli
# Entrypoint prepares the database and starts Consul agent (update this as per your requirements)
ENTRYPOINT [ "litefs", "mount", "--", "/app/other/docker-entrypoint.js" ]
# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
ENV DATABASE_FILENAME="sqlite.db"
ENV LITEFS_DIR="/litefs"
ENV DATABASE_PATH="$LITEFS_DIR/$DATABASE_FILENAME"
ENV DATABASE_URL="file://$DATABASE_PATH"
ENV CACHE_DATABASE_FILENAME="cache.db"
ENV CACHE_DATABASE_PATH="$LITEFS_DIR/$CACHE_DATABASE_FILENAME"
ENV PORT=3000
CMD [ “npm”, “run”, “start” ]
type or paste code here
fly .toml
# fly.toml app configuration file generated for my-remix-app-2 on 2023-12-03T13:59:41Z
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#
app = "marcus-app"
primary_region = "lhr"
[build]
[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
[[vm]]
cpu_kind = "shared"
cpus = 1
memory_mb = 1024