chore(docker): tighten container build setup

This commit is contained in:
kuekhaoyang
2026-05-01 23:42:50 +08:00
parent a9b4e28b57
commit d80cf3dfcf
3 changed files with 28 additions and 16 deletions
+11
View File
@@ -4,4 +4,15 @@ node_modules
npm-debug.log
README.md
.next
.open-next
.vercel
.git
android-tv
apple-tv
audit-artifacts
docs
playwright
tests
test-results
PROJECT_AUDIT_2026-04-16.md
*.log
+5 -14
View File
@@ -28,18 +28,6 @@ COPY . .
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED 1
# Debug: Show build environment
RUN echo "=== Build Environment ===" && \
pwd && \
echo "=== Files in /app ===" && \
ls -la && \
echo "=== Lockfiles ===" && \
ls -la | grep -E "lock|yarn" || echo "No lockfiles" && \
echo "=== Node version ===" && \
node --version && \
echo "=== NPM version ===" && \
npm --version
# Build Next.js application
RUN set -ex && \
if [ -f yarn.lock ]; then \
@@ -57,6 +45,7 @@ FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1
@@ -66,8 +55,7 @@ RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next
RUN mkdir .next && chown nextjs:nodejs .next
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
@@ -82,4 +70,7 @@ ENV PORT=3000
# set hostname to localhost
ENV HOSTNAME="0.0.0.0"
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD wget --spider --quiet "http://127.0.0.1:${PORT}/" || exit 1
CMD ["node", "server.js"]
+12 -2
View File
@@ -4,8 +4,18 @@ services:
build:
context: .
dockerfile: Dockerfile
target: runner
image: kvideo:latest
init: true
restart: always
ports:
- 3000:3000
- "3000:3000"
environment:
- NODE_ENV=production
NODE_ENV: production
PORT: 3000
healthcheck:
test: ["CMD-SHELL", "wget --spider --quiet http://127.0.0.1:3000/ || exit 1"]
interval: 30s
timeout: 5s
retries: 3
start_period: 30s