diff --git a/.dockerignore b/.dockerignore index e3ba81e97..b6764a50f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -15,7 +15,8 @@ TODO.md # Sibling projects / test harness - not part of the webmail image examples/ # Unit tests: `next build` type-checks every .ts file, and some tests import -# routes the Dockerfile deletes (app/api/dev-jmap) +# routes the Dockerfile deletes (app/api/dev-jmap). The Dockerfile deletes the +# tests as well, since a remote Git context skips this file. **/__tests__ **/*.test.ts **/*.test.tsx diff --git a/Dockerfile b/Dockerfile index b36abc8fd..c9efc1cfa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,14 @@ ARG GIT_COMMIT=unknown ENV GIT_COMMIT=$GIT_COMMIT # The mock JMAP server (DEV_MOCK_JMAP) accepts any password and is for # `npm run dev` only; images ship without it. -RUN rm -rf "app/api/dev-jmap" && npx next build --webpack +# `next build` type-checks every .ts file, and some unit tests import the +# deleted route, so the tests go too. .dockerignore already drops them from a +# local context, but a remote Git context never applies .dockerignore (#1118). +RUN rm -rf "app/api/dev-jmap" && \ + find . -path ./node_modules -prune -o \ + \( -name __tests__ -o -name "*.test.ts" -o -name "*.test.tsx" \) \ + -prune -exec rm -rf {} \; && \ + npx next build --webpack FROM node:24-alpine AS runner