docker.recipes

Remix + PostgreSQL

intermediate

Full-stack React framework with PostgreSQL and Prisma ORM.

Overview

Remix is a full-stack React framework that emphasizes web standards, server-side rendering, and progressive enhancement. Built by the creators of React Router, Remix takes a unique approach by leveraging the platform's native capabilities like HTTP caching, forms, and URLs, while providing modern developer experience through nested routing, error boundaries, and automatic data loading. Unlike traditional SPAs, Remix renders pages on the server by default and progressively enhances with JavaScript, resulting in faster initial page loads and better SEO. This stack combines Remix's server-first architecture with PostgreSQL's robust relational database capabilities and Prisma ORM for type-safe database operations. The integration creates a powerful full-stack solution where Remix's loader and action functions handle server-side data fetching and mutations, while PostgreSQL provides ACID-compliant data storage with advanced querying capabilities. Prisma acts as the bridge, generating type-safe client code from your database schema and handling migrations. This combination is ideal for developers building data-intensive web applications who want React's component model with server-side rendering benefits. E-commerce platforms, content management systems, and SaaS applications particularly benefit from Remix's form handling and PostgreSQL's transaction support. The stack appeals to teams transitioning from traditional server-rendered applications to modern React while maintaining performance and accessibility standards.

Key Features

  • Server-side rendering with progressive enhancement for optimal Core Web Vitals
  • Nested routing with parallel data loading and error boundaries
  • Built-in form handling using web standards without client-side JavaScript
  • Type-safe database operations through Prisma's generated client
  • PostgreSQL's JSONB support for flexible schema evolution alongside relational data
  • Automatic code splitting and prefetching based on route hierarchy
  • Advanced PostgreSQL features like full-text search and window functions
  • Hot module replacement for both client and server code during development

Common Use Cases

  • 1E-commerce platforms requiring complex product catalogs and transaction integrity
  • 2Content management systems with hierarchical page structures and SEO requirements
  • 3SaaS applications needing server-side authentication and data validation
  • 4Multi-tenant applications leveraging PostgreSQL's row-level security
  • 5Real-time dashboards combining PostgreSQL analytics with Remix's streaming responses
  • 6Progressive web apps that work without JavaScript but enhance with it
  • 7Team collaboration tools requiring complex relational data modeling

Prerequisites

  • Docker and Docker Compose installed on your system
  • Node.js 18+ knowledge for Remix development and build processes
  • Basic understanding of React components and modern JavaScript
  • SQL fundamentals for PostgreSQL schema design and querying
  • Minimum 1GB RAM available for PostgreSQL container operations
  • Port 3000 available for the Remix development server

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 container_name: remix
5 environment:
6 DATABASE_URL: postgresql://${DB_USER}:${DB_PASSWORD}@postgres:5432/${DB_NAME}
7 ports:
8 - "3000:3000"
9 depends_on:
10 - postgres
11 networks:
12 - remix-network
13
14 postgres:
15 image: postgres:16-alpine
16 environment:
17 POSTGRES_DB: ${DB_NAME}
18 POSTGRES_USER: ${DB_USER}
19 POSTGRES_PASSWORD: ${DB_PASSWORD}
20 volumes:
21 - postgres_data:/var/lib/postgresql/data
22 networks:
23 - remix-network
24
25volumes:
26 postgres_data:
27
28networks:
29 remix-network:
30 driver: bridge

.env Template

.env
1DB_NAME=remix
2DB_USER=remix
3DB_PASSWORD=changeme

Usage Notes

  1. 1Docs: https://remix.run/docs
  2. 2Access at http://localhost:3000
  3. 3Server-side rendering by default, progressive enhancement
  4. 4Nested routes with layouts and error boundaries
  5. 5Use Prisma or Drizzle for database access
  6. 6Built-in form handling without client-side JavaScript

Individual Services(2 services)

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

remix
remix:
  build: .
  container_name: remix
  environment:
    DATABASE_URL: postgresql://${DB_USER}:${DB_PASSWORD}@postgres:5432/${DB_NAME}
  ports:
    - "3000:3000"
  depends_on:
    - postgres
  networks:
    - remix-network
postgres
postgres:
  image: postgres:16-alpine
  environment:
    POSTGRES_DB: ${DB_NAME}
    POSTGRES_USER: ${DB_USER}
    POSTGRES_PASSWORD: ${DB_PASSWORD}
  volumes:
    - postgres_data:/var/lib/postgresql/data
  networks:
    - remix-network

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 remix:
5 build: .
6 container_name: remix
7 environment:
8 DATABASE_URL: postgresql://${DB_USER}:${DB_PASSWORD}@postgres:5432/${DB_NAME}
9 ports:
10 - "3000:3000"
11 depends_on:
12 - postgres
13 networks:
14 - remix-network
15
16 postgres:
17 image: postgres:16-alpine
18 environment:
19 POSTGRES_DB: ${DB_NAME}
20 POSTGRES_USER: ${DB_USER}
21 POSTGRES_PASSWORD: ${DB_PASSWORD}
22 volumes:
23 - postgres_data:/var/lib/postgresql/data
24 networks:
25 - remix-network
26
27volumes:
28 postgres_data:
29
30networks:
31 remix-network:
32 driver: bridge
33EOF
34
35# 2. Create the .env file
36cat > .env << 'EOF'
37DB_NAME=remix
38DB_USER=remix
39DB_PASSWORD=changeme
40EOF
41
42# 3. Start the services
43docker compose up -d
44
45# 4. View logs
46docker 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-postgres/run | bash

Troubleshooting

  • Database connection refused: Ensure PostgreSQL container is fully started before Remix attempts connection, add healthcheck or wait script
  • Prisma generate fails: Run 'npx prisma generate' after schema changes and rebuild the Docker image to include generated client
  • Hot reload not working: Bind mount your source code directory to the container for development mode file watching
  • PostgreSQL data lost on restart: Verify the postgres_data volume is properly mounted and not being removed between container restarts
  • Environment variables not loading: Ensure .env file is in the correct directory and variables match the docker-compose.yml references
  • Build fails with Prisma errors: Include Prisma generate step in your Dockerfile after copying package.json and schema.prisma files

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