feat: respect PORT env variable for Coolify preview deployments
Nginx now listens on ${PORT} (default 7575) instead of hardcoded 7575,
so Coolify can inject a unique port per preview container. The internal
Next.js server is pinned to port 3000 to avoid conflicting with nginx.
This commit is contained in:
5 files changed
+12
-7
No files matched your search
@@ -65,5 +65,8 @@ ENV AUTH_PROVIDERS='credentials'
|
||||
ENV REDIS_IS_EXTERNAL='false'
|
||||
ENV NODE_ENV='production'
|
||||
|
||||
ARG PORT=7575
|
||||
EXPOSE ${PORT}
|
||||
|
||||
ENTRYPOINT [ "/app/entrypoint.sh" ]
|
||||
CMD ["sh", "run.sh"]
|
||||
@@ -9,7 +9,7 @@
|
||||
"dev": "pnpm with-env next dev",
|
||||
"format": "oxfmt .",
|
||||
"lint": "oxlint",
|
||||
"start": "pnpm with-env next start",
|
||||
"start": "pnpm with-env next start -p ${PORT:-3000}",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"with-env": "dotenv -e ../../.env --"
|
||||
},
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
:: Please do not run this command in production. It is only for local testing.
|
||||
docker run -p 7575:7575 -e SECRET_ENCRYPTION_KEY=0000000000000000000000000000000000000000000000000000000000000000 homarr:latest
|
||||
docker run -p 7575:7575 -e PORT=7575 -e SECRET_ENCRYPTION_KEY=0000000000000000000000000000000000000000000000000000000000000000 homarr:latest
|
||||
+2
-2
@@ -4,8 +4,8 @@ events {
|
||||
|
||||
http {
|
||||
server {
|
||||
listen 7575;
|
||||
listen [::]:7575;
|
||||
listen ${PORT};
|
||||
listen [::]:${PORT};
|
||||
|
||||
# Route websockets traffic to port 3001
|
||||
location /websockets {
|
||||
|
||||
+5
-3
@@ -17,12 +17,14 @@ fi
|
||||
# Auth secret is generated every time the container starts as it is required, but not used because we don't need JWTs or Mail hashing
|
||||
export AUTH_SECRET=$(openssl rand -base64 32)
|
||||
|
||||
export PORT=${PORT:-7575}
|
||||
|
||||
# Start nginx proxy
|
||||
# 1. Replace the HOSTNAME in the nginx template file
|
||||
# 1. Replace the HOSTNAME and PORT in the nginx template file
|
||||
# 2. Create the nginx configuration file from the template
|
||||
# 3. Start the nginx server
|
||||
export HOSTNAME
|
||||
envsubst '${HOSTNAME}' < /etc/nginx/templates/nginx.conf > /etc/nginx/nginx.conf
|
||||
envsubst '${HOSTNAME} ${PORT}' < /etc/nginx/templates/nginx.conf > /etc/nginx/nginx.conf
|
||||
# Start services in the background and store their PIDs
|
||||
nginx -g 'daemon off;' &
|
||||
NGINX_PID=$!
|
||||
@@ -36,7 +38,7 @@ else
|
||||
REDIS_PID=$!
|
||||
fi
|
||||
|
||||
node apps/nextjs/server.js &
|
||||
PORT=3000 node apps/nextjs/server.js &
|
||||
NEXTJS_PID=$!
|
||||
|
||||
# Function to handle SIGTERM and shut down services
|
||||
|
||||
Reference in new issue
Block a user