Spaces:
Sleeping
Sleeping
Commit ·
40f42c0
1
Parent(s): 86bd8df
feat(docker): add start.sh to honor (default 7860) and log bind; expose 7860/3000; stop port flapping
Browse files- Dockerfile +10 -3
- start.sh +9 -0
Dockerfile
CHANGED
|
@@ -11,15 +11,22 @@ RUN npm ci
|
|
| 11 |
# Copy the rest of the application
|
| 12 |
COPY --chown=1000 . .
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
# Build the app
|
| 15 |
RUN npm run build
|
| 16 |
|
| 17 |
-
# Expose
|
|
|
|
| 18 |
EXPOSE 3000
|
| 19 |
|
| 20 |
ENV HOST=0.0.0.0
|
|
|
|
| 21 |
# Disable telemetry and ensure production env
|
| 22 |
ENV NEXT_TELEMETRY_DISABLED=1
|
| 23 |
ENV NODE_ENV=production
|
| 24 |
-
#
|
| 25 |
-
CMD ["
|
|
|
|
| 11 |
# Copy the rest of the application
|
| 12 |
COPY --chown=1000 . .
|
| 13 |
|
| 14 |
+
# Ensure start script is executable
|
| 15 |
+
USER root
|
| 16 |
+
RUN chmod +x /usr/src/app/start.sh
|
| 17 |
+
USER 1000
|
| 18 |
+
|
| 19 |
# Build the app
|
| 20 |
RUN npm run build
|
| 21 |
|
| 22 |
+
# Expose both common ports (Space sets $PORT; we honor it at runtime)
|
| 23 |
+
EXPOSE 7860
|
| 24 |
EXPOSE 3000
|
| 25 |
|
| 26 |
ENV HOST=0.0.0.0
|
| 27 |
+
ENV PORT=7860
|
| 28 |
# Disable telemetry and ensure production env
|
| 29 |
ENV NEXT_TELEMETRY_DISABLED=1
|
| 30 |
ENV NODE_ENV=production
|
| 31 |
+
# Start via script that logs and honors $PORT
|
| 32 |
+
CMD ["/usr/src/app/start.sh"]
|
start.sh
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -e
|
| 3 |
+
|
| 4 |
+
# Honor Space-provided PORT, default to 7860 for Docker Spaces
|
| 5 |
+
PORT_TO_USE="${PORT:-7860}"
|
| 6 |
+
HOST_TO_USE="${HOST:-0.0.0.0}"
|
| 7 |
+
|
| 8 |
+
echo "Starting Next.js on ${HOST_TO_USE}:${PORT_TO_USE}"
|
| 9 |
+
exec node node_modules/next/dist/bin/next start -H "${HOST_TO_USE}" -p "${PORT_TO_USE}"
|