Skip to content

Conversation

@riba2534
Copy link

Problem

When self-hosting happy-server using Docker, the container starts successfully but fails with database errors:

Invalid `prisma.session.findMany()` invocation:
The table `public.Session` does not exist in the current database.

This happens because the Dockerfile's runner stage doesn't include the prisma directory, making it impossible to run prisma migrate deploy inside the container to initialize the database.

Root Cause

The official Dockerfile only copies these files to the runtime stage:

  • tsconfig.json
  • package.json
  • node_modules
  • sources

But it's missing prisma/, which contains schema.prisma and migration files needed for database setup.

Solution

Add one line to copy the prisma directory in the runtime stage:

COPY --from=builder /app/prisma ./prisma

This allows the container to:

  1. Run prisma migrate deploy to initialize the database
  2. Properly support self-hosted deployments

Testing

After this fix:

  1. Build the Docker image
  2. Run with docker-compose
  3. Execute docker exec <container> yarn prisma migrate deploy
  4. All 36 migrations apply successfully
  5. Service starts without database errors

Impact

  • Minimal change (1 line added)
  • No performance impact
  • Enables proper self-hosting workflow
  • Maintains the multi-stage build optimization

Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com

The prisma directory is required in the runtime stage to run
`prisma migrate deploy` for database initialization when
self-hosting. Without this, the container starts but cannot
access the database schema, causing "table does not exist" errors.

This change is necessary for proper self-hosted deployments
where the database needs to be initialized within the container.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@riba2534 riba2534 force-pushed the fix/dockerfile-missing-prisma branch from 4fe8202 to 03cf5e9 Compare January 15, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant