make test no longer runs the frontend's production build (refs #118)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
yarn build moves out of the stage that runs the frontend's unit tests, now named frontend-test, into a frontend-build stage of its own. It starts from frontend-test for its yarn packages and source, installs the git that vite.config.js reads the commit with, and copies from the lint and test phases as builder does, so it cannot run unless they passed. The runtime stage copies dist/ from it. The Go compile, most of make test's time, is unchanged and waits on the ruling asked for in sneak/prompts#113; no build cache is added. Model: opus-5-5
This commit is contained in:
+29
-21
@@ -5,11 +5,11 @@
|
||||
#
|
||||
# The lint and test phases are the gates: `make lint` (script/lint)
|
||||
# builds the lint stage alone and `make test` (script/test) the test
|
||||
# stage alone, and the builder stage depends on both, so the image
|
||||
# cannot be built unless they pass. Each covers the frontend as well,
|
||||
# through a copy from a node stage. Inside them each tool is invoked
|
||||
# directly, never through make or script/, whose lint and test are
|
||||
# themselves docker builds.
|
||||
# stage alone, and the two build stages, frontend-build and builder,
|
||||
# depend on both, so the image cannot be built unless they pass. Each
|
||||
# phase covers the frontend as well, through a copy from a node stage.
|
||||
# Inside them each tool is invoked directly, never through make or
|
||||
# script/, whose lint and test are themselves docker builds.
|
||||
|
||||
# Frontend lint stage: eslint with the rules in eslint.config.js. The
|
||||
# lint phase below runs it.
|
||||
@@ -35,30 +35,26 @@ RUN golangci-lint run --config .golangci.yml ./...
|
||||
# phase run it.
|
||||
COPY --from=frontend-lint /app/yarn.lock /dev/null
|
||||
|
||||
# Frontend stage: the unit tests in test/unit/, then the production
|
||||
# build into dist/, which the runtime stage serves. The test phase below
|
||||
# runs it. The tests print a dot each; if any fails, they run again with
|
||||
# every test listed, and the step fails even if that run passes.
|
||||
# NODE_OPTIONS chooses the reporter because yarn adds its arguments
|
||||
# after the test files, where node would take a reporter option for one
|
||||
# more file.
|
||||
# Frontend test stage: the unit tests in test/unit/. The test phase
|
||||
# below runs it, and the frontend-build stage starts from it. The tests
|
||||
# print a dot each; if any fails, they run again with every test listed,
|
||||
# and the step fails even if that run passes. NODE_OPTIONS chooses the
|
||||
# reporter because yarn adds its arguments after the test files, where
|
||||
# node would take a reporter option for one more file.
|
||||
# node:22-alpine as of 2026-02-22
|
||||
FROM node@sha256:e4bf2a82ad0a4037d28035ae71529873c069b13eb0455466ae0bc13363826e34 AS frontend
|
||||
FROM node@sha256:e4bf2a82ad0a4037d28035ae71529873c069b13eb0455466ae0bc13363826e34 AS frontend-test
|
||||
WORKDIR /app
|
||||
COPY package.json yarn.lock ./
|
||||
RUN yarn install --frozen-lockfile
|
||||
# vite.config.js reads the commit for the page's footer with git.
|
||||
RUN apk add --no-cache git
|
||||
COPY . .
|
||||
RUN NODE_OPTIONS=--test-reporter=dot timeout 90 yarn --silent run test || \
|
||||
{ echo "--- Rerunning with every test listed for details ---"; \
|
||||
NODE_OPTIONS=--test-reporter=spec timeout 90 yarn --silent run test; \
|
||||
exit 1; }
|
||||
RUN yarn build
|
||||
|
||||
# Test phase: the backend's tests with the race detector and coverage,
|
||||
# and the frontend's through the copy from the frontend stage at the
|
||||
# end. -race needs cgo and so a C compiler, which the Debian Go image
|
||||
# and the frontend's through the copy from the frontend-test stage at
|
||||
# the end. -race needs cgo and so a C compiler, which the Debian Go image
|
||||
# ships and the alpine one does not. -timeout 90s is a backstop above
|
||||
# the 60-second cap on the suite. The rerun with -v only shows details:
|
||||
# the step fails however it ends, because the first run already failed.
|
||||
@@ -75,9 +71,21 @@ RUN --mount=type=tmpfs,target=/go/pkg/mod \
|
||||
go test -timeout 90s -race -cover ./... || \
|
||||
{ echo "--- Rerunning with -v for details ---"; \
|
||||
go test -timeout 90s -race -v ./...; exit 1; }
|
||||
# Nothing is wanted from the frontend stage; the copy is what makes
|
||||
# Nothing is wanted from the frontend-test stage; the copy is what makes
|
||||
# this phase run its tests.
|
||||
COPY --from=frontend /app/yarn.lock /dev/null
|
||||
COPY --from=frontend-test /app/yarn.lock /dev/null
|
||||
|
||||
# Frontend build stage: the production build into dist/, which the
|
||||
# runtime stage serves, on the yarn packages and source of the
|
||||
# frontend-test stage. Nothing is wanted from the two phases; the copies
|
||||
# are what make BuildKit build them first, so this stage cannot run
|
||||
# unless lint and test passed.
|
||||
FROM frontend-test AS frontend-build
|
||||
COPY --from=lint /src/go.sum /dev/null
|
||||
COPY --from=test /src/go.sum /dev/null
|
||||
# vite.config.js reads the commit for the page's footer with git.
|
||||
RUN apk add --no-cache git
|
||||
RUN yarn build
|
||||
|
||||
# Backend build stage. Nothing is wanted from the two phases; the copies
|
||||
# are what make BuildKit build them first, so this stage cannot run
|
||||
@@ -131,7 +139,7 @@ RUN addgroup -g 1000 -S netwatch && \
|
||||
RUN rm /etc/nginx/conf.d/default.conf
|
||||
COPY configs/nginx.conf /etc/nginx/templates/netwatch.conf.template
|
||||
COPY configs/security-headers.conf /etc/nginx/security-headers.conf
|
||||
COPY --from=frontend /app/dist /usr/share/nginx/html
|
||||
COPY --from=frontend-build /app/dist /usr/share/nginx/html
|
||||
COPY --from=builder /src/netwatch-server /usr/local/bin/netwatch-server
|
||||
COPY bin/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
|
||||
|
||||
Reference in New Issue
Block a user