docker.recipes

Remix + Prisma + PostgreSQL

intermediate

Full-stack Remix application with Prisma ORM and PostgreSQL database.

Overview

Remix is a full-stack web framework that focuses on web standards and modern UX, built by the creators of React Router. It emphasizes server-side rendering, progressive enhancement, and efficient data loading through its nested routing system and built-in data fetching capabilities. Unlike traditional React frameworks, Remix leverages the web platform's native capabilities for forms, caching, and navigation while providing excellent developer experience with TypeScript support and file-based routing. This stack combines Remix's full-stack capabilities with Prisma's type-safe database toolkit and PostgreSQL's robust relational database features. Prisma generates TypeScript types from your database schema, providing end-to-end type safety from database queries to your Remix loaders and actions. Redis handles session storage and caching to improve performance, while PostgreSQL stores your application data with ACID compliance and advanced querying capabilities. NGINX serves as a reverse proxy, handling SSL termination and static file serving in production. This combination is ideal for developers building data-intensive web applications who value type safety, performance, and maintainability. Startups and medium-sized companies will appreciate the rapid development cycle enabled by Prisma's schema-first approach and Remix's convention-over-configuration philosophy. The stack excels for applications requiring complex data relationships, user authentication, and real-time features while maintaining excellent SEO and user experience through server-side rendering.

Key Features

  • Server-side rendering with Remix's nested routing and progressive enhancement
  • Type-safe database operations with Prisma's auto-generated TypeScript client
  • Redis-based session management with automatic expiration and distributed storage
  • PostgreSQL's JSONB support for flexible schema alongside relational data
  • Prisma's database migrations with automatic schema synchronization
  • NGINX reverse proxy with HTTP/2 support and static asset optimization
  • Remix's built-in error boundaries and catch boundaries for robust error handling
  • PostgreSQL's full-text search capabilities integrated with Prisma queries

Common Use Cases

  • 1E-commerce platforms with complex product catalogs and user management
  • 2Content management systems requiring SEO optimization and fast page loads
  • 3SaaS applications with multi-tenant data isolation and real-time features
  • 4Educational platforms with user progress tracking and content delivery
  • 5Dashboard applications with data visualization and user authentication
  • 6Blog platforms with commenting systems and content management
  • 7Booking systems with availability tracking and payment processing

Prerequisites

  • Docker Engine 20.10+ and Docker Compose V2
  • Node.js 18+ knowledge for Remix development and Prisma CLI usage
  • Minimum 2GB RAM (1GB for PostgreSQL, 512MB for Redis, 512MB for applications)
  • Basic understanding of SQL and database schema design
  • Ports 80, 443, 3000, 5432, and 6379 available on host system
  • Familiarity with TypeScript and React for Remix development

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 remix:
3 build:
4 context: .
5 dockerfile: Dockerfile
6 ports:
7 - "3000:3000"
8 environment:
9 DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
10 REDIS_URL: redis://redis:6379
11 SESSION_SECRET: ${SESSION_SECRET}
12 depends_on:
13 postgres:
14 condition: service_healthy
15 redis:
16 condition: service_started
17 networks:
18 - remix-net
19 restart: unless-stopped
20
21 postgres:
22 image: postgres:16-alpine
23 environment:
24 POSTGRES_USER: ${POSTGRES_USER}
25 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
26 POSTGRES_DB: ${POSTGRES_DB}
27 volumes:
28 - postgres_data:/var/lib/postgresql/data
29 healthcheck:
30 test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
31 interval: 10s
32 timeout: 5s
33 retries: 5
34 networks:
35 - remix-net
36 restart: unless-stopped
37
38 redis:
39 image: redis:7-alpine
40 volumes:
41 - redis_data:/data
42 networks:
43 - remix-net
44 restart: unless-stopped
45
46 nginx:
47 image: nginx:alpine
48 ports:
49 - "80:80"
50 - "443:443"
51 volumes:
52 - ./nginx.conf:/etc/nginx/nginx.conf:ro
53 - ./certs:/etc/nginx/certs:ro
54 depends_on:
55 - remix
56 networks:
57 - remix-net
58 restart: unless-stopped
59
60volumes:
61 postgres_data:
62 redis_data:
63
64networks:
65 remix-net:
66 driver: bridge

.env Template

.env
1# PostgreSQL
2POSTGRES_USER=remix
3POSTGRES_PASSWORD=secure_postgres_password
4POSTGRES_DB=remix
5
6# Remix
7SESSION_SECRET=secure_session_secret_at_least_32_chars
8NODE_ENV=production

Usage Notes

  1. 1Create Remix app: npx create-remix
  2. 2Remix app at http://localhost:3000
  3. 3Run migrations: npx prisma migrate deploy
  4. 4Configure nginx.conf for production

Individual Services(4 services)

Copy individual services to mix and match with your existing compose files.

remix
remix:
  build:
    context: .
    dockerfile: Dockerfile
  ports:
    - "3000:3000"
  environment:
    DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
    REDIS_URL: redis://redis:6379
    SESSION_SECRET: ${SESSION_SECRET}
  depends_on:
    postgres:
      condition: service_healthy
    redis:
      condition: service_started
  networks:
    - remix-net
  restart: unless-stopped
postgres
postgres:
  image: postgres:16-alpine
  environment:
    POSTGRES_USER: ${POSTGRES_USER}
    POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    POSTGRES_DB: ${POSTGRES_DB}
  volumes:
    - postgres_data:/var/lib/postgresql/data
  healthcheck:
    test:
      - CMD-SHELL
      - pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}
    interval: 10s
    timeout: 5s
    retries: 5
  networks:
    - remix-net
  restart: unless-stopped
redis
redis:
  image: redis:7-alpine
  volumes:
    - redis_data:/data
  networks:
    - remix-net
  restart: unless-stopped
nginx
nginx:
  image: nginx:alpine
  ports:
    - "80:80"
    - "443:443"
  volumes:
    - ./nginx.conf:/etc/nginx/nginx.conf:ro
    - ./certs:/etc/nginx/certs:ro
  depends_on:
    - remix
  networks:
    - remix-net
  restart: unless-stopped

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 remix:
5 build:
6 context: .
7 dockerfile: Dockerfile
8 ports:
9 - "3000:3000"
10 environment:
11 DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
12 REDIS_URL: redis://redis:6379
13 SESSION_SECRET: ${SESSION_SECRET}
14 depends_on:
15 postgres:
16 condition: service_healthy
17 redis:
18 condition: service_started
19 networks:
20 - remix-net
21 restart: unless-stopped
22
23 postgres:
24 image: postgres:16-alpine
25 environment:
26 POSTGRES_USER: ${POSTGRES_USER}
27 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
28 POSTGRES_DB: ${POSTGRES_DB}
29 volumes:
30 - postgres_data:/var/lib/postgresql/data
31 healthcheck:
32 test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
33 interval: 10s
34 timeout: 5s
35 retries: 5
36 networks:
37 - remix-net
38 restart: unless-stopped
39
40 redis:
41 image: redis:7-alpine
42 volumes:
43 - redis_data:/data
44 networks:
45 - remix-net
46 restart: unless-stopped
47
48 nginx:
49 image: nginx:alpine
50 ports:
51 - "80:80"
52 - "443:443"
53 volumes:
54 - ./nginx.conf:/etc/nginx/nginx.conf:ro
55 - ./certs:/etc/nginx/certs:ro
56 depends_on:
57 - remix
58 networks:
59 - remix-net
60 restart: unless-stopped
61
62volumes:
63 postgres_data:
64 redis_data:
65
66networks:
67 remix-net:
68 driver: bridge
69EOF
70
71# 2. Create the .env file
72cat > .env << 'EOF'
73# PostgreSQL
74POSTGRES_USER=remix
75POSTGRES_PASSWORD=secure_postgres_password
76POSTGRES_DB=remix
77
78# Remix
79SESSION_SECRET=secure_session_secret_at_least_32_chars
80NODE_ENV=production
81EOF
82
83# 3. Start the services
84docker compose up -d
85
86# 4. View logs
87docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/remix-prisma-stack/run | bash

Troubleshooting

  • Prisma Client not found: Run 'npx prisma generate' to regenerate the client after schema changes
  • Database connection refused: Ensure PostgreSQL is healthy with 'docker-compose ps' and check DATABASE_URL format
  • Redis connection timeout: Verify Redis container is running and REDIS_URL matches service name 'redis:6379'
  • Remix build failures: Clear node_modules and run 'npm install' then 'npm run build' to resolve dependency conflicts
  • NGINX 502 Bad Gateway: Check that Remix service is running on port 3000 and nginx.conf upstream configuration is correct
  • Prisma migration failures: Reset database with 'npx prisma migrate reset' and reapply migrations in development

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space