D
Dokploy9mo ago
Hype

Ports not exposed in NextJS app with nixpacks

I couldn't find information on the internet, I have basic nextjs14 app that needs ports exposed as .env variable set in Dokploy is "PORT=3002" and for some reason nixpacks don't detec't the port resulting in making Docker container that has not exposed ports, which means the app is not accessible by anyone. How do I fix that, because I can manually make "docker run [my created docker container here]" but that makes me doing everything from scratch and Dokploy isn't a solution then.
No description
9 Replies
Hype
HypeOP9mo ago
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d9602597ecc0 blog-nextjs-d6fd28:latest "/bin/sh -c 'npx pri…" 7 seconds ago Up 2 seconds blog-nextjs-d6fd28.1.ynt7wcvgi2cz648hdk3an5mwj
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d9602597ecc0 blog-nextjs-d6fd28:latest "/bin/sh -c 'npx pri…" 7 seconds ago Up 2 seconds blog-nextjs-d6fd28.1.ynt7wcvgi2cz648hdk3an5mwj
Harvey Specter
Harvey Specter9mo ago
You don't need to expose the port to the main machine. Go to Domains and create a new random-generated domain, then add the port for your NextJS app.
Hype
HypeOP9mo ago
Thanks, after fixing some issues in my side now I have situation where chat gpt is not so much helpful. Have you got any idea why trafeik makes me result of my website as “bad gateway” when accessing it trought browser but when I acccess it using http:3000 it works perfectly? Not sure even what logs to give you because there are no errors
Hype
HypeOP9mo ago
that's what I get, but when i remove 's' and go for http:[my domain] with the port of app it work flawesly
No description
Hype
HypeOP9mo ago
No description
Hype
HypeOP9mo ago
docker-compose
networks:
dokploy-network:
external: true

services:
db:
image: mysql:8
environment:
MYSQL_ROOT_PASSWORD: 123
MYSQL_DATABASE: blog
ports:
- "0.0.0.0:33060:3306"
healthcheck:
test: ["CMD", "mysqladmin", "ping", "--silent"]
interval: 1s
retries: 60
timeout: 5s
networks:
- dokploy-network
app:
build: .
depends_on:
db:
condition: service_healthy
ports:
- "0.0.0.0:3001:3000"
environment:
DATABASE_URL: mysql://root:123@db:3306/blog
networks:
- dokploy-network
networks:
dokploy-network:
external: true

services:
db:
image: mysql:8
environment:
MYSQL_ROOT_PASSWORD: 123
MYSQL_DATABASE: blog
ports:
- "0.0.0.0:33060:3306"
healthcheck:
test: ["CMD", "mysqladmin", "ping", "--silent"]
interval: 1s
retries: 60
timeout: 5s
networks:
- dokploy-network
app:
build: .
depends_on:
db:
condition: service_healthy
ports:
- "0.0.0.0:3001:3000"
environment:
DATABASE_URL: mysql://root:123@db:3306/blog
networks:
- dokploy-network
found this error in traefik docker container logs, not sure if related: 2024-09-25T00:28:33Z ERR error="service \"dokploy-traefik\" error: port is missing" container=dokploy-traefik-jn5bc5ewkl4o6dhvopoe1zkrk providerName=swarm
Siumauricio
Siumauricio9mo ago
Can you read this ? https://docs.dokploy.com/en/docs/core/troubleshooting/overview in the last version I added the most common questions, the answer to your problem is there
Overview
Solve the most common problems that occur when using Dokploy.
Hype
HypeOP9mo ago
thank you so much the correct solution for those who face similar issue:
networks:
dokploy-network:
external: true

services:
db:
image: mysql:8
environment:
MYSQL_ROOT_PASSWORD: 123
MYSQL_DATABASE: blog
ports:
- 3306
healthcheck:
test: ["CMD", "mysqladmin", "ping", "--silent"]
interval: 1s
retries: 60
timeout: 5s
networks:
- dokploy-network
app:
build: .
depends_on:
db:
condition: service_healthy
ports:
- 3000
environment:
DATABASE_URL: mysql://root:123@db:3306/blog
networks:
- dokploy-network
networks:
dokploy-network:
external: true

services:
db:
image: mysql:8
environment:
MYSQL_ROOT_PASSWORD: 123
MYSQL_DATABASE: blog
ports:
- 3306
healthcheck:
test: ["CMD", "mysqladmin", "ping", "--silent"]
interval: 1s
retries: 60
timeout: 5s
networks:
- dokploy-network
app:
build: .
depends_on:
db:
condition: service_healthy
ports:
- 3000
environment:
DATABASE_URL: mysql://root:123@db:3306/blog
networks:
- dokploy-network
mide
mide2mo ago
hello

Did you find this page helpful?