diff --git a/.dockerignore b/.dockerignore index c550055..255730c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -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 diff --git a/Dockerfile b/Dockerfile index ee116a2..f67c294 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/docker-compose.yml b/docker-compose.yml index 60200aa..ce28a35 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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