How to run generate & migrate in production on a VPS for SQLite Database?

So I have a database in development that I run db:generate & db:migrate on to create the database & then run my app that uses it. But how do I do that in production when I can't run direct commands. I'm using https://easypanel.io on a self-hosted VPS. Do I just use pre-scripts or post-scripts? What is the recommended way to go about it?
Easypanel
Manage your server without fighting the terminal. Server control panel based on Docker.
4 Replies
nk
nk•12mo ago
I would make a Docker compose that sets everything up.
Startup Spells 🪄 Newsletter Guy
no, dont wanna do that for 1 script only. im sure its a pretty easy solution. maybe im right about pre-script but have to test & i have another unrelated bug to squash first before i can try it.
Startup Spells 🪄 Newsletter Guy
after a month, i went with docker (had to learn it) but still face an error. i thought this would solve the problem. do you have any idea why this doesn't work? https://stackoverflow.com/q/78031427/6141587 i run it like this at the end of dockerfile:
#!/bin/bash
set -e

ls
npm install
# Creates `data/users.prod.sqlite` using bind volume mount
npm run db:migrate:prod & PID=$!
# Wait for migration to finish
wait $PID

echo "Starting production server..."
node server.js & PID=$!

wait $PID
#!/bin/bash
set -e

ls
npm install
# Creates `data/users.prod.sqlite` using bind volume mount
npm run db:migrate:prod & PID=$!
# Wait for migration to finish
wait $PID

echo "Starting production server..."
node server.js & PID=$!

wait $PID
Stack Overflow
Cannot find package 'drizzle-orm' in Docker Container even though I...
I install all my dependencies in Dockerfile using npm ci below. Dockerfile FROM node:20-alpine AS base 1. Install dependencies only when needed FROM base AS deps Check https://github.com/nodejs/
Startup Spells 🪄 Newsletter Guy
so i finally figured out the solution although it took a week or so. pnpm install in run.sh takes a minute but it works lol -> https://stackoverflow.com/a/78034626/6141587
Stack Overflow
Cannot find package 'drizzle-orm' in Docker Container even though I...
I install all my dependencies in Dockerfile using npm ci below. Dockerfile FROM node:20-alpine AS base 1. Install dependencies only when needed FROM base AS deps Check https://github.com/nodejs/
Want results from more Discord servers?
Add your server