studio
studio copied to clipboard
Prisma + docker + docker compose + NGINX
Bug description
nginx cannot direct port 5555 of the container that is running Prisma Studio Pro https, Prisma Studio only runs on HTTP if you enter the domain name :5555 ex: http://exampledominio.com:5555
How to reproduce
Use a small base image
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
Install OpenSSL
RUN apt-get update && \
apt-get install -y openssl
FROM base AS build
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
COPY . .
RUN pnpm install ts-node-dev -g --global
RUN pnpm install turbo --global
RUN pnpm install
WORKDIR /app/apps/stack-back
RUN if [ ! -d "prisma" ]; then \
pnpm install prisma --save-dev && \
pnpm dlx prisma init && \
pnpm dlx prisma migrate dev --name init && \
pnpm dlx prisma generate; \
else \
pnpm dlx prisma generate; \
fi
Navigate back to the main /app directory
WORKDIR /app
RUN pnpm run build
Add script to start both application and Prisma Studio
COPY start.sh /app/start.sh
RUN chmod +x /app/start.sh
EXPOSE 3000
EXPOSE 5000
EXPOSE 5555
CMD ["./start.sh"]
Docker compose:
version: '3.8'
services:
postgres:
image: postgres:latest
container_name: my_postgres_container
environment:
POSTGRES_USER: user123
POSTGRES_PASSWORD: password123
POSTGRES_DB: mydb
ports:
- "5432:5432"
volumes:
- pg_data:/var/lib/postgresql/data
networks:
- interconsultaV2
application:
build:
context: .
dockerfile: dockerfile.totally
container_name: 'application'
ports:
- "3000:3000"
- "5000:5000"
- "5555:5555"
networks:
- interconsultaV2
depends_on:
- postgres
nginx:
build:
context: .
dockerfile: dockerfile.reverseProxy
container_name: nginx-container
restart: always
ports:
- "80:80"
- "443:443"
depends_on:
- postgres
- application
networks:
- interconsultaV2
volumes:
- ./certbot/conf:/etc/letsencrypt
- ./certbot/www:/var/www/certbot
certbot:
image: certbot/certbot
container_name: certbot
volumes:
- ./certbot/conf:/etc/letsencrypt
- ./certbot/www:/var/www/certbot
depends_on:
- nginx
networks:
- interconsultaV2
networks:
interconsultaV2:
driver: bridge
volumes:
pg_data:
NGINX:
events {}
http {
server {
listen 80;
server_name domain domain;
location ~ /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location / {
return 301 https://domain$request_uri;
}
}
server {
listen 443 ssl;
server_name domain domain;
ssl_certificate /etc/letsencrypt/live/domain/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain/privkey.pem;
client_max_body_size 500M;
location / {
proxy_pass http://application:3000; # Front-end na porta 3000
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /api {
proxy_pass http://application:5000; # Back-end na porta 5000
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /db-studio {
proxy_pass http://application:5555;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}
Expected behavior
nginx would have to direct the prism to the https port, note: the prism on the http port works smoothly
Prisma information
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Lead {
id String @id @default(uuid())
nome String
email String @unique
telefone String
doenca String
date String
status String
UTMsAQ UTMS[]
}
model UTMS {
id String @id @default(uuid())
leadId String
lead Lead @relation(fields: [leadId], references: [id])
referrer String?
funil String?
temp String?
rota String?
source String?
medium String?
campaign String?
term String?
content String?
}
Environment & setup
DATABASE_URL="postgresql://user123:password123@postgres:5432/mydb?schema=public"
Screenshot of page where the problem happened (if applicable)
No response
Prisma logs
Error in HTTP Request (Status: 404)
{}
I am not sure I fully understand. What exactly is the problem @MatheusGxx?
The nginx reverse proxy cannot show Prisma Studio with https even though I set the settings correctly, it does not see port 5555 on https.., is this a blockage on Prisma itself? @janpio