merlyn/docker/startup.sh
PQ32 Developer c9c1fea95d Merlyn: initial containerization setup
- Modified Dockerfile: amd64 only, merlyn user (UID 1117), python3/pip, simplified build
- Added _startup.sh: root-level startup, hands off to startup.sh as merlyn user
- Added startup.sh: yarn installs, frontend build, Prisma migrations, start server+collector
- Added server/requirements.txt: Python dependencies for merlyn-server
- Fixed collector/yarn.lock: epub2 git URL SSH->HTTPS with commit hash
- Fixed server/yarn.lock: zod version bumped to 3.25.76 to resolve zod-to-json-schema compatibility
2026-05-10 14:04:54 -07:00

48 lines
1.6 KiB
Bash

#!/bin/bash
# startup.sh - runs as merlyn user
if [ -z "$STORAGE_DIR" ]; then
echo "================================================================"
echo "⚠️ WARNING: STORAGE_DIR environment variable is not set!"
echo "================================================================"
fi
umask 002
# Force git to use HTTPS instead of SSH
git config --global url."https://".insteadOf ssh://
git config --global url."https://github.com/".insteadOf git@github.com:
# Install server dependencies
echo "Installing server dependencies..."
cd /app/server && yarn install --production --frozen-lockfile --no-cache --network-timeout 100000
# Install collector dependencies
echo "Installing collector dependencies..."
cd /app/collector && yarn install --production --frozen-lockfile --no-cache --network-timeout 100000
# NODE_ENV must be set to development for frontend install
# otherwise yarn skips devDependencies (including vite)
# NODE_ENV=production is set in the Dockerfile for the server
# Build frontend if public folder doesn't exist
if [ ! -d "/app/server/public" ]; then
echo "Building frontend..."
cd /app/frontend
NODE_ENV=development yarn install --frozen-lockfile --no-cache --network-timeout 100000
yarn build
cp -r /app/frontend/dist /app/server/public
fi
# Run Prisma migrations and start AnythingLLM
{
cd /app/server/ &&
export CHECKPOINT_DISABLE=1 &&
npx prisma generate --schema=./prisma/schema.prisma &&
npx prisma migrate deploy --schema=./prisma/schema.prisma &&
node /app/server/index.js
} &
{ node /app/collector/index.js; } &
wait -n
exit $?