From de5a380928d133e18e676714db875fb20ae3a478 Mon Sep 17 00:00:00 2001 From: Collin Barrett <6483057+collinbarrett@users.noreply.github.com> Date: Sun, 15 Jun 2025 16:18:25 -0500 Subject: [PATCH] refactor(web): tweak docker build --- web/.dockerignore | 9 +++++++++ web/Dockerfile | 25 +++++++++---------------- 2 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 web/.dockerignore diff --git a/web/.dockerignore b/web/.dockerignore new file mode 100644 index 000000000..67f91f7de --- /dev/null +++ b/web/.dockerignore @@ -0,0 +1,9 @@ +# https://github.com/vercel/next.js/blob/canary/examples/with-docker/.dockerignore + +Dockerfile +.dockerignore +node_modules +npm-debug.log +README.md +.next +.git \ No newline at end of file diff --git a/web/Dockerfile b/web/Dockerfile index a8ecf0303..ea22462a8 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -10,13 +10,11 @@ FROM base AS deps RUN apk add --no-cache libc6-compat WORKDIR /app -# Install dependencies based on the preferred package manager -COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./ -RUN --mount=type=cache,target=/app/.next/cache \ - if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ - elif [ -f package-lock.json ]; then npm ci; \ - elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ - else echo "Lockfile not found." && exit 1; \ +# Install dependencies based on npm +COPY package.json package-lock.json* .npmrc* ./ +RUN \ + if [ -f package-lock.json ]; then npm ci; \ + else echo "package-lock.json not found." && exit 1; \ fi @@ -26,16 +24,12 @@ WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . -# Next.js collects completely anonymous telemetry data about general usage. -# Learn more here: https://nextjs.org/telemetry -# Uncomment the following line in case you want to disable telemetry during the build. +# https://nextjs.org/telemetry ENV NEXT_TELEMETRY_DISABLED=1 -RUN \ - if [ -f yarn.lock ]; then yarn run build; \ - elif [ -f package-lock.json ]; then npm run build; \ - elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \ - else echo "Lockfile not found." && exit 1; \ +RUN --mount=type=cache,target=/app/.next/cache \ + if [ -f package-lock.json ]; then npm run build; \ + else echo "package-lock.json not found." && exit 1; \ fi # Production image, copy all the files and run next @@ -43,7 +37,6 @@ FROM base AS runner WORKDIR /app ENV NODE_ENV=production -# Uncomment the following line in case you want to disable telemetry during runtime. ENV NEXT_TELEMETRY_DISABLED=1 RUN addgroup --system --gid 1001 nodejs