Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
node_modules
npm-debug.log
images
images
.git
.github
coverage
packages/**/coverage
packages/frontend
packages/jobs
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.dockerignore excludes packages/frontend, but the Docker build currently runs npm ci from the repo root with npm workspaces enabled. If you address the workspace install issue by copying packages/frontend/package.json into the build stage, this ignore rule will prevent it from being available to COPY. Consider un-ignoring at least the workspace manifest(s) needed for install (e.g. add a !packages/frontend/package.json exception) or adjust the Docker build to install solely from packages/backend so other workspaces can remain ignored.

Suggested change
packages/jobs
packages/jobs
!packages/frontend/package.json
!packages/jobs/package.json

Copilot uses AI. Check for mistakes.
**/*.log
46 changes: 20 additions & 26 deletions packages/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,31 @@
FROM node:20-alpine AS build
WORKDIR /usr/src/app

# Copy root package files for workspaces
# Copy workspace and backend files required for compilation and minification.
COPY package.json package-lock.json ./
COPY tsconfig.base.json ./
COPY packages/backend/package.json ./packages/backend/
COPY packages/backend/tsconfig.json ./packages/backend/
COPY packages/backend/tsconfig.prod.json ./packages/backend/
COPY packages/backend/src ./packages/backend/src

# Build and minify backend artifact inside Docker.
RUN npm ci \
&& npm run build:prod -w @mocker/backend \
&& npm run minify -w @mocker/backend \
Comment on lines 6 to +16
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm ci is executed from the repo root, but the image only copies the backend workspace files into /usr/src/app/packages. Since the root package.json declares workspaces ("packages/*") and the repo also has packages/frontend/package.json, npm workspaces installs can fail when the other workspace manifests aren’t present in the container filesystem. Consider either copying the missing workspace package.json files (at least packages/frontend/package.json) before npm ci, or switching the Docker build to install/build from packages/backend using packages/backend/package-lock.json so the root workspaces aren’t involved.

Copilot uses AI. Check for mistakes.
&& npx esbuild /usr/src/app/packages/backend/dist/index.js --bundle --minify --platform=node --target=node20 --format=cjs --outfile=/usr/src/app/packages/backend/dist/runtime.cjs \
&& mkdir -p /usr/src/app/images

FROM gcr.io/distroless/nodejs20-debian12:nonroot AS release
ENV NODE_ENV=production \
PORT=80

# Copy backend package
COPY packages/backend/package.json packages/backend/
COPY packages/backend/tsconfig.json packages/backend/
COPY packages/backend/tsconfig.prod.json packages/backend/
COPY packages/backend/src packages/backend/src

# Install dependencies and build
RUN npm ci
RUN npm run build:prod -w @mocker/backend

FROM node:20-alpine AS release
ENV NODE_ENV=production PORT=80
WORKDIR /usr/src/app

# Copy built output
COPY --from=build /usr/src/app/packages/backend/dist ./

# Copy package files for production install
COPY --from=build /usr/src/app/package.json ./
COPY --from=build /usr/src/app/package-lock.json ./
COPY --from=build /usr/src/app/packages/backend/package.json ./packages/backend/

RUN mkdir -p /usr/src/app/images

# Install production dependencies only for the backend workspace
RUN npm pkg delete scripts.prepare && npm ci --omit=dev -w @mocker/backend --ignore-scripts
# Copy bundled runtime artifact and writable path from build stage.
COPY --from=build --chown=65532:65532 /usr/src/app/packages/backend/dist/runtime.cjs ./runtime.cjs
COPY --from=build --chown=65532:65532 /usr/src/app/images ./images
Comment on lines +26 to +28
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The release stage only copies a single bundled runtime.cjs. The backend uses TypeORM’s getConnectionOptions() and requires TYPEORM_ENTITIES to be set (see src/index.ts), which typically points to entity files on disk (e.g. dist/shared/db/models/*.js). With only runtime.cjs present, TypeORM won’t be able to load entities from the filesystem, so DB initialization is likely to fail at runtime. Either keep/copy the compiled entity files into the image and set TYPEORM_ENTITIES accordingly, or change the app configuration to pass entity classes explicitly (and avoid relying on glob paths) when running from a bundled artifact.

Copilot uses AI. Check for mistakes.

EXPOSE 80

CMD ["node", "/usr/src/app/index.js"]
CMD ["/usr/src/app/runtime.cjs"]
Loading