Skip to content

Instantly share code, notes, and snippets.

@1hue
1hue / README.md
Last active November 30, 2025 23:22
Next.js errors

When encountering the next.js build error below, ensure that all of your environment variables are available at build-time of the container (Docker or other).

Env vars available may be available at run-time only. This happens with docker-compose.yml env_file for example - env vars won't be available until after the container is built and ready, so shelling into the container and running echo $NEXT_PUBLIC_FOO will work, but RUN echo $NEXT_PUBLIC_FOO inside Dockerfile won't work.

💡 To fix it, all env vars must be explicitly listed inside the Dockerfile - this enables docker to leverage layer caching. This way, if an env var changes, docker knows that everything below the corresponding ARG must be rebuilt.

ARG NEXT_PUBLIC_FOO
ARG NEXT_PUBLIC_BAR
ARG NEXT_PUBLIC_BAZ
@1hue
1hue / Dockerfile
Last active November 13, 2025 09:48
PNPM / Node local development server using Docker and Alpine
FROM node:25-alpine AS base
# Ensure HTTPS sources in Alpine Package Keeper (APK)
RUN awk '/http:\/\// {print "ERROR: Non-HTTPS repo:", $0; exit 1}' /etc/apk/repositories
# Verify base image integrity
RUN apk --no-cache info ca-certificates && \
test -d /etc/apk/keys/ && \
test $(ls /etc/apk/keys/*.pub | wc -l) -gt 0
@1hue
1hue / .prettierignore
Last active November 4, 2025 22:40
Better ESLint flat config for Next.js 16
package-lock.json
pnpm-lock.yaml
/.pnpm-store