File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -37,15 +37,32 @@ COPY client/public ./public
3737COPY client/src ./src
3838RUN yarn build
3939
40+ # ##################################################
41+ # Stage: test
42+ #
43+ # This stage runs the tests on the backend. This is split into a separate
44+ # stage to allow the final image to not have the test dependencies or test
45+ # cases.
46+ # ##################################################
47+ FROM base AS test
48+ COPY backend/package.json backend/yarn.lock ./
49+ RUN --mount=type=cache,id=yarn,target=/root/.yarn yarn install --frozen-lockfile
50+ COPY backend/spec ./spec
51+ COPY backend/src ./src
52+ RUN yarn test
53+
4054# ##################################################
4155# Stage: final
4256#
4357# This stage is intended to be the final "production" image. It sets up the
4458# backend and copies the built client application from the client-build stage.
59+ #
60+ # It pulls the package.json and yarn.lock from the test stage to ensure that
61+ # the tests run (without this, the test stage would simply be skipped).
4562# ##################################################
4663FROM base AS final
4764ENV NODE_ENV=production
48- COPY backend/ package.json backend /yarn.lock ./
65+ COPY --from=test /usr/local/app/ package.json /usr/local/app /yarn.lock ./
4966RUN --mount=type=cache,id=yarn,target=/root/.yarn yarn install --production --frozen-lockfile
5067COPY backend/src ./src
5168COPY --from=client-build /usr/local/app/dist ./src/static
You can’t perform that action at this time.
0 commit comments